Scrap Mechanic

Scrap Mechanic

ScriptableComputer
lusty 30 Aug, 2023 @ 12:51am
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
< >
Showing 1-2 of 2 comments
waffle (mkel) 29 Mar, 2024 @ 6:08pm 
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 @ 11:10pm 
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.
< >
Showing 1-2 of 2 comments
Per page: 1530 50