Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Constants:
- local onMessage = "On"
- local offMessage = "Off"
- local y = 100
- local redNetSide = "top"
- local redSide = "bottom"
- local serverID = 5
- --Variables:
- local x = 1
- local senderId, message, distance
- --Functions
- function netClose()
- rednet.close(redNetSide)
- end
- function netOpen()
- netClose()
- rednet.open(redNetSide)
- end
- function countDown()
- if x >= y then
- x = 1
- redReset()
- else
- x=x+1
- end
- end
- function redReset()
- redOff()
- sleep(.5)
- redOn()
- end
- function redOn()
- redstone.setOutput(redSide, true)
- end
- function redOff()
- redstone.setOutput(redSide, false)
- end
- function getData()
- senderId, message, distance = rednet.receive(10)
- print("Waiting for message")
- end
- --Main Program:
- netOpen()
- while true do
- countDown()
- getData()
- print(message)
- if senderId == serverID then
- if message == onMessage then
- print("turning R off, and the spawner on")
- redOff()
- elseif message == offMessage then
- print("turning R on, and the spawner off")
- redOn()
- else
- print("message doesnt apply to me")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment