Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wait ( time )
- local timer = os.startTimer(time)
- while true do
- local event = {os.pullEvent()}
- if (event[1] == "timer" and event[2] == timer) then
- break
- elseif event[1] == "monitor_touch" then
- print("Other event catched")
- end
- end
- end
- function turnOffEngine()
- redstone.setOutput("right", true)
- wait(2)
- redstone.setOutput("right", false)
- end
- function turnOnEngine()
- redstone.setOutput("left", true)
- wait(8)
- redstone.setOutput("left", false)
- end
- function getEvent()
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- --print("I just received a message on channel: "..senderChannel)
- --print("The message was: "..message)
- -- Tells to turn on engine
- if message == "turn_on" then
- turnOnEngine()
- -- Turn off the engine
- elseif message == "turn_off" then
- turnOffEngine()
- end
- getEvent()
- end
- engine_number = tonumber(arg[1])
- modem = peripheral.wrap("top")
- modem.open(engine_number)
- getEvent()
Advertisement
Add Comment
Please, Sign In to add comment