Posted 24 December 2014 - 12:14 PM
hey, im trying to make my computer detect any keystroke from the keyboard so it breaks a loop but i want it to keep going through the loop while its detecting if i pressed a key. my code goes something like this:
function rsAnalog()
local rsread = rsRead()
while true do
clear()
monClear()
local rsIn = rs.getAnalogInput("back")
if rsIn <= tonumber(rsread) then
rs.setOutput("right", true)
sleep(3)
else rs.setOutput("right",false)
end
rsRead is another function that returns a key that i press to make the rsIn output redstone signal until the redstone power thats behind it is = to that number i put in. im trying to make the computer exit this loop upon keypress and since i have while true do function rsAnalog() at the bottom it will just enter the loop again and ask me for a number. thats my end goal, have it restart this rsAnalog loop upon keypress
function rsAnalog()
local rsread = rsRead()
while true do
clear()
monClear()
local rsIn = rs.getAnalogInput("back")
if rsIn <= tonumber(rsread) then
rs.setOutput("right", true)
sleep(3)
else rs.setOutput("right",false)
end
rsRead is another function that returns a key that i press to make the rsIn output redstone signal until the redstone power thats behind it is = to that number i put in. im trying to make the computer exit this loop upon keypress and since i have while true do function rsAnalog() at the bottom it will just enter the loop again and ask me for a number. thats my end goal, have it restart this rsAnalog loop upon keypress