Scrap Mechanic

Scrap Mechanic

ScriptableComputer
lusty 30. aug. 2023 kl. 0:51
how to get number input from the modpack?
i have been trying to figure out how to get number input from lets say number blocks for example as they just transfer the data, but anyways it hasn't been very clear how i can get a number input, color works but i would like to have something like

if input(1) then
out(3)
else
out(0)
end
< >
Viser 1-2 af 2 kommentarer
waffle (mkel) 29. mar. 2024 kl. 18:08 
thingamalang = tostring(getreg("thingamalangInput1")) -- so, "thingamalangInput1" is the name of
-- the writer. the number input will be in a string. the writer needs to be named thingamalangInput1
-- now, thingamlang is whatever number the "thingamalangInput1" writer is in string.
-- if you wanted to display this text on a display, use:

-- display = getDisplays()[1]
-- display.clear()
-- display.drawText(1, 1, thingamalang)
-- display.forceFlush()
-- display.flush()
-- and just put this below the tostring(getreg( line
waffle (mkel) 30. mar. 2024 kl. 23:10 
New updated version for 4 digits:
display = getDisplays()[1]

N1 = tostring(getreg("N1"))
N2 = tostring(getreg("N2"))
N3 = tostring(getreg("N3"))
N4 = tostring(getreg("N4"))

ENN = N1 + N2*10 + N3*100 + N4*1000

display.clear()
display.drawText(1,1, ENN)
display.flush()

function callback_loop()
if _endtick then
display.clear()
display.forceFlush()
end
end

so, you need 4 writers named "N1", "N2", "N3", and "N4"
add a counter block, and add the number blocks with the 4 digits coloured for numbers in the thousands. connect the first digit to the "N1" writer, second to "N2", and so on.
add a number into the counter, and turn the computer off and then back on. it will show that number in the display.
< >
Viser 1-2 af 2 kommentarer
Per side: 1530 50