Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RADIO="right"
- controller = nil
- function checkLavaOn()
- return turtle.compareTo(2)
- end
- function processMessage(data)
- if data["action"] == "acknowledge" or (data["action"] == "announce" and data["device"] == "controller") then
- controller = data["computer_id"]
- if data["action"] == "announce" then
- rednet.send(data["computer_id"], textutils.serialize({action="acknowledge", type="multimob", device="lavabot"}))
- end
- elseif data["action"] == "lava" then
- if data["state"] == "on" then
- if checkLavaOn() then
- turtle.place()
- end
- rednet.send(controller, textutils.serialize({action="lava", state="on", type="multimob", device="lavabot"}))
- elseif data["state"] == "off" then
- if not checkLavaOn() then
- turtle.place()
- end
- rednet.send(controller, textutils.serialize({action="lava", state="off", type="multimob", device="lavabot"}))
- end
- end
- end
- if peripheral.isPresent(RADIO) and peripheral.getType(RADIO) == "modem" then
- rednet.open(RADIO)
- rednet.broadcast(textutils.serialize({action="announce", type="multimob", device="lavabot"}))
- else
- print("Modem not found")
- return
- end
- while true do
- ev,p1,p2,p3 = os.pullEvent()
- if ev == "rednet_message" then
- data = textutils.unserialize(p2)
- if data["type"] == "multimob" then
- data["computer_id"] = p1
- processMessage(data)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement