Posted 28 October 2012 - 09:05 AM
Read down below for more
I got a question about a program i'm trying to make. I put all my functions before the main program to make sure that they load first. But, as the program moves down lines, it comes across a while loop in the function and seems to get stuck in that loop before the main program starts and calls that function. How do I make it so the while loop will not start unless the function (in this case readASCII) is called? Hopefully this makes enough sense for someone to answer my question.
Here is my code:
I got a question about a program i'm trying to make. I put all my functions before the main program to make sure that they load first. But, as the program moves down lines, it comes across a while loop in the function and seems to get stuck in that loop before the main program starts and calls that function. How do I make it so the while loop will not start unless the function (in this case readASCII) is called? Hopefully this makes enough sense for someone to answer my question.
Here is my code:
function readASCII()
num = redstone.getBundledInput( bUSide )
if num == 4 then
return end
end
num = tostring( num )
append = readVal( num )
--msg = msg..append
rs.setOutput( cSide, true )
while true do
os.pullEvent( "redstone" )
if rs.getInput( aSide ) == true then
rs.setOutput( cSide, false )
return true
else
sleep( 1 )
aCount = aCount+1
if aCount == 10 then
return false
end
end
end