Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- masterCode
- local isRunning = true
- local clientId = 0
- local fLevel = 0
- function screenClear()
- shell.run("clear")
- print("Master Computer")
- print("-----------------------------------------------")
- print("Keys: W: Forward, A: Left, D: Right")
- print(" Q: Up, E: Down, 1: Dig, 2: DigDown")
- print(" 3: DigUp, 5: Tunnel 5, 6: Excavate 10")
- print(" R: Refuel All, C: Checks Items In Slot 16")
- print("-----------------------------------------------")
- print("Fuel Level: "..fLevel)
- print("-----------------------------------------------")
- print("Waiting For Commands . . .")
- end
- function checkFuel()
- while true do
- event, senderId, message = os.pullEvent("rednet_message")
- if event == "rednet_message" and senderId == clientId then
- fLevel = message
- break
- else
- print("\nPCID is false . . .")
- break
- end
- end
- --fLevel = 98
- if fLevel <= 100 then
- print("\nWARNING! Fuel Level is LOW!")
- end
- end
- function tForward()
- screenClear()
- print("Moving Turtle Forward")
- rednet.send(clientId, "w")
- checkFuel()
- end
- function tTurnLeft()
- screenClear()
- print("Turning Turtle Left")
- rednet.send(clientId, "a")
- end
- function tTurnRight()
- screenClear()
- print("Turning Turtle Right")
- rednet.send(clientId, "d")
- end
- function tUp()
- screenClear()
- print("Moving Turtle Up")
- rednet.send(clientId, "q")
- checkFuel()
- end
- function tDown()
- screenClear()
- print("Moving Turtle Down")
- rednet.send(clientId, "e")
- checkFuel()
- end
- function tDig()
- screenClear()
- print("Turtle Is Digging In Front")
- rednet.send(clientId, "1")
- checkFuel()
- end
- function tDigUp()
- screenClear()
- print("Turtle Is Digging Up")
- rednet.send(clientId, "3")
- checkFuel()
- end
- function tDigDown()
- screenClear()
- print("Turtle Is Digging Down")
- rednet.send(clientId, "2")
- checkFuel()
- end
- function tTunnel()
- screenClear()
- print("Turtle Is Running From Shell(tunnel 5)")
- rednet.send(clientId, "5")
- while true do
- event, senderId, message = os.pullEvent("rednet_message")
- if event == "rednet_message" and senderId == clientId and message == "done" then
- print("\nShell Program Completed!")
- break
- else
- print("\nPCID is false . . .")
- break
- end
- end
- checkFuel()
- end
- function tExcavate()
- screenClear()
- print("Turtle Is Running From Shell(excavate 10)")
- rednet.send(clientId, "6")
- end
- function tRefuel()
- message = ""
- screenClear()
- print("Turtle Is Running From Shell(refuel all)")
- rednet.send(clientId, "r")
- while true do
- event, senderId, message = os.pullEvent("rednet_message")
- if event == "rednet_message" and senderId == clientId then
- print("\n"..message)
- break
- else
- print("\nPCID is false . . .")
- break
- end
- end
- end
- function tCheckInv()
- screenClear()
- print("Turtle Is Checking Slot 16")
- rednet.send(clientId, "c")
- while true do
- event, senderId, message = os.pullEvent("rednet_message")
- if event == "rednet_message" and senderId == clientId then
- print("\n"..message)
- break
- else
- print("\nPCID is false . . .")
- break
- end
- end
- end
- if not rednet.isOpen("right") then
- rednet.open("right")
- end
- screenClear()
- while isRunning == true do
- event, scancode = os.pullEvent()
- if event == "key" and scancode == 17 then
- tForward()
- elseif event == "key" and scancode == 30 then
- tTurnLeft()
- elseif event == "key" and scancode == 32 then
- tTurnRight()
- elseif event == "key" and scancode == 16 then
- tUp()
- elseif event == "key" and scancode == 18 then
- tDown()
- elseif event == "key" and scancode == 2 then
- tDig()
- elseif event == "key" and scancode == 4 then
- tDigUp()
- elseif event == "key" and scancode == 3 then
- tDigDown()
- elseif event == "key" and scancode == 6 then
- tTunnel()
- elseif event == "key" and scancode == 7 then
- tExcavate()
- elseif event == "key" and scancode == 19 then
- tRefuel()
- elseif event == "key" and scancode == 46 then
- tCheckInv()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment