Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = nil
- function main()
- print("=== Starting Mine OS ===")
- print("")
- modem = peripheral.wrap("top")
- modem.open(1)
- while true do
- print("Lisening for jobs...")
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- if message == -1 then
- sendUpdate(-1)
- else
- print("received message:"..message)
- mine(message)
- end
- end
- end
- function sleepAndUpdate(Time,Todo)
- for i=1,Time do
- sendUpdate(Todo)
- sleep(1)
- end
- end
- function sendUpdate(Todo)
- print("sendUpdate:"..Todo)
- modem.transmit(2,1,Todo)
- end
- function mine (Count)
- sendUpdate(Count)
- sleep(1)
- redstone.setOutput("right",true)
- sleepAndUpdate(10,Count)
- for i=1,Count do
- sendUpdate(Count-i)
- redstone.setOutput("left",true)
- sleepAndUpdate(1,Count-1)
- redstone.setOutput("left",false)
- sleepAndUpdate(12,Count-i)
- end
- sleepAndUpdate(5,0)
- redstone.setOutput("right",false)
- sendUpdate(-1)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement