Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function count(table)
- local num = 0;
- for _ in pairs(table) do num = num + 1 end
- return num
- end
- function call(port, command)
- local begun = false
- local pending = {}
- local modem = peripheral.wrap("left")
- modem.open(port)
- modem.transmit(port, port, command)
- print("Start message sent...")
- repeat
- local a, b, c, sender, message, d = os.pullEvent("modem_message")
- if message == "start" then
- pending[sender] = true
- print("#"..sender.." starting ("..count(pending).." running)")
- begun = true
- end
- if message == "finish" then
- pending[sender] = nil
- print("#"..sender.." finished ("..count(pending).." running)")
- end
- until count(pending) == 0 and begun
- print("...all done!")
- end
- function pulse(side)
- redstone.setOutput(side, true)
- sleep(0.4)
- redstone.setOutput(side, false)
- sleep(0.4)
- end
- function move()
- pulse("back")
- sleep(0.2)
- pulse("right")
- sleep(0.2)
- end
- function cycle()
- move()
- call(8080, "cycle")
- sleep(4)
- end
- function run()
- while true do
- if redstone.getInput("top") == true then
- cycle()
- end
- sleep(2)
- end
- end
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement