Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("button")
- m = peripheral.wrap("left")
- m.clear()
- f = false
- H = false
- T = false
- FH = false
- M1 = false
- isCoal = true
- isTorch = true
- Turtleid = 0
- MID1 = 53 --First turtle
- MID2 = 0 --Second turtle
- MID3 = 0 --Third turtle
- MID4 = 0 --Fourth turtle
- function fillTable()
- button.setTable("Miner1", 1, 3,5,3,5)
- button.setTable("Miner2", 2, 7,9,3,5)
- button.setTable("Miner3", 3, 11,13,3,5)
- button.setTable("Miner4", 4, 15,17,3,5)
- button.screen()
- end
- function Check()
- if f == true then
- button.toggleButton("50")
- f = false
- rednet.send(Turtleid,"mine50")
- elseif H == true then
- button.toggleButton("100")
- H = false
- rednet.send(Turtleid,"mine100")
- elseif T == true then
- button.toggleButton("200")
- T= false
- rednet.send(Turtleid,"mine200")
- elseif FH == true then
- button.toggleButton("500")
- FH = false
- rednet.send(Turtleid,"mine500")
- end
- end
- function MoveCheck()
- if M1 == true then
- button.toggleButton("Move")
- M1 = false
- rednet.send(Turtleid, "move")
- end
- end
- function Miner1()
- button.toggleButton("Miner1")
- Turtleid = MID1
- Check()
- MoveCheck()
- end
- function Miner2()
- button.toggleButton("Miner2")
- Turtleid = MID2
- Check()
- MoveCheck()
- end
- function Miner3()
- button.toggleButton("Miner3")
- Turtleid = MID3
- Check()
- MoveCheck()
- end
- function Miner4()
- button.toggleButton("Miner4")
- Turtleid = MID4
- Check()
- MoveCheck()
- end
- function Fifty()
- button.toggleButton("50")
- f = true
- end
- function Hundred()
- button.toggleButton("100")
- H = true
- end
- function TwoHund()
- button.toggleButton("200")
- T = true
- end
- function FiveHund()
- button.toggleButton("500")
- FH = true
- end
- function Reset()
- button.flash("Reset")
- if f == true then
- button.toggleButton("50")
- f = false
- elseif H == true then
- button.toggleButton("100")
- H = false
- elseif T == true then
- button.toggleButton("200")
- T = false
- elseif FH == true then
- button.toggleButton("500")
- FH = false
- end
- end
- function Coal()
- print("Don't touch!")
- end
- function Torch()
- print("Don't touch!")
- end
- function Move1()
- button.toggleButton("Move")
- M1 = true
- end
- function MoveReset()
- button.flash("Move Reset")
- if M1 == true then
- button.toggleButton("Move")
- M1 = false
- end
- end
- rednet.open("right")
- fillTable()
- button.heading("Miner Controller")
- while true do
- local event, Turtleid, par2, par3 = os.pullEvent()
- if event == "rednet_message" and par2 == "done" then
- if Turtleid == MID1 then
- button.toggleButton("Miner1")
- elseif Turtleid == MID2 then
- button.toggleButton("Miner2")
- elseif Turtleid == MID3 then
- button.toggleButton("Miner3")
- elseif Turtleid == MID4 then
- button.toggleButton("Miner4")
- end
- elseif event == "rednet_message" and par2 == "cFalse" then
- if Turtleid == MID1 or MID2 or MID3 or MID4 then
- if isCoal == true then
- button.toggleButton("C")
- isCoal = false
- elseif isCoal == false then
- end
- end
- elseif event == "rednet_message" and par2 == "cTrue" then
- if Turtleid == MID1 or MID2 or MID3 or MID4 then
- if isCoal == false then
- button.toggleButton("C")
- isCoal = true
- elseif isCoal == true then
- end
- end
- elseif event == "rednet_message" and par2 == "tFalse" then
- if Turtleid == MID1 or MID2 or MID3 or MID4 then
- if isTorch == true then
- button.toggleButton("T")
- isTorch = false
- elseif isTorch == false then
- end
- end
- elseif event == "rednet_message" and par2 == "tTrue" then
- if Turtleid == MID1 or MID2 or MID3 or MID4 then
- if isTorch == false then
- button.toggleButton("T")
- isTorch = true
- elseif isTorch == true then
- end
- end
- elseif event == "monitor_touch" then
- button.checkxy(par2,par3)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment