Posted 07 June 2013 - 04:06 PM
HI
I made my first lua program that i would like to share with you.
It is very simple but extremly usefull, you can modyfy it to keep running your rotary macerator or other mashines in specified time (ie: only during your time spend on server) or use it as it is, to light redstone lamps during night.
I found loop with exit possibility by Lettuce, but i dont know why it just runs the program once and then waits for my input.
If anyone could point the error here i would be very greatefull :)/>
oryginal loop code
–your whole looping code
end
function quit()
while true do
input = io.read()
if input == "stop" then
break
end
end
end
parallel.waitForAll(quit, run)
my oryginal code without exit possibilty (works!)
local time = os.time()
local signal = false
if time>17 or time<6 then
signal = true
end
rs.setOutput("left", signal)
os.queueEvent("randomEvent")
os.pullEvent()
end
I made my first lua program that i would like to share with you.
It is very simple but extremly usefull, you can modyfy it to keep running your rotary macerator or other mashines in specified time (ie: only during your time spend on server) or use it as it is, to light redstone lamps during night.
I found loop with exit possibility by Lettuce, but i dont know why it just runs the program once and then waits for my input.
If anyone could point the error here i would be very greatefull :)/>
function run()
local time = os.time()
local signal = false
if time>17 or time<6 then
signal = true
end
rs.setOutput("left", signal)
end
function quit()
while true do
input = io.read()
if input == "stop" then
rs.setOutput("left", false)
break
end
end
end
print ("type 'stop' to quit program")
parallel.waitForAll(quit, run)
oryginal loop code
Spoiler
function run()–your whole looping code
end
function quit()
while true do
input = io.read()
if input == "stop" then
break
end
end
end
parallel.waitForAll(quit, run)
my oryginal code without exit possibilty (works!)
Spoiler
while true dolocal time = os.time()
local signal = false
if time>17 or time<6 then
signal = true
end
rs.setOutput("left", signal)
os.queueEvent("randomEvent")
os.pullEvent()
end