Lyqyd, on 29 July 2012 - 01:04 AM, said:
I couldn't remember whether or not the print function would complain about being passed a boolean instead of a string.
It converts anything to a string, since it uses tostring on every parameter. The only thing that it doesn't print is nil (and everything after a nil), since it stops when there's one.
Xenthera, on 29 July 2012 - 01:06 AM, said:
Lyqyd, on 29 July 2012 - 01:00 AM, said:
Why not just use an actual boolean instead of 1 or 0? Change "side" to whichever side you want to accept input on.
local toggle = false
while true do
os.pullEvent("redstone")
toggle = rs.getInput("side")
if toggle then
print("true")
else
print("false")
end
end
That code works as well, thank you. But now it's an issue of using a button, the redstone "sticks" and the code is able to loop through it twice in the amount of time the redstone stays on. I know there's physical ways to get around that (Redstone Pulser) But I'd rather do it inside the code. I got around it using the sleep() function, but it's not exactly reliable.
os.pullEvent("redstone") will make it wait for a change in redstone (turn on or off), so it can't loop twice with the same "pulse", unless there's another input that changes.