Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- print("Pocket")
- rednet.open("back")
- xmax = 4
- ymax = 4
- function keytostop()
- print(phase, " en cours, appuyez sur une touche pour stop")
- os.pullEvent("key")
- end
- function placement()
- local sID, msg, prot = rednet.receive("New Slave", 60)
- if msg == nil then
- print("Error: Slave not responding")
- return false
- elseif msg == "New Slave" then
- print("Send Master Instruction")
- rednet.send(sID, {"Master", xmax, ymax}, "New Slave Wait")
- end
- end
- function minage(distance)
- rednet.broadcast({"Mining", distance}, "Instruction")
- end
- function config()
- print("X max ?")
- xmax = tonumber(io.read())
- print("Y max ?")
- ymax = tonumber(io.read())
- end
- function main()
- while true do
- shell.run("clear")
- print("Placement: p")
- print("Mining: m")
- print("Looting: l")
- print("Recuperation: r")
- print("Config: c")
- input = io.read()
- if input == "p" then
- phase = "Placement"
- parallel.waitForAny(placement, keytostop)
- elseif input == "m" then
- phase = "Minage"
- print("Quelle distance ?")
- minage(tonumber(io.read()))
- elseif input == "l" then
- rednet.broadcast({"Looting"},"Instruction")
- elseif input == "r" then
- rednet.broadcast({"Recup"},"Instruction")
- elseif input == "s" then
- rednet.broadcast({"Shutdown"},"Instruction")
- elseif input == "c" then
- config()
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement