Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function welcomeMessage ()
- shell.run("clear")
- if turtle then
- if term.isColor() then
- term.setTextColor(colors.lime)
- end
- print[[---------------------------------------
- Welcome to NanoTurtle V3.0
- ---------------------------------------]]
- else
- if term.isColor() then
- term.setTextColor(colors.lime)
- end
- print[[---------------------------------------------------
- Welcome to NanoTurtle V3.0
- ---------------------------------------------------
- ]]
- end
- if term.isColor() then
- term.setTextColor(colors.white)
- end
- end
- function firstQuestion()
- welcomeMessage()
- print("Do you want to transmit or receive from this device?")
- input=read()
- if input=="receive" then
- receiving=true
- os.setComputerLabel("Remote Turtle")
- secondQuestion(receiving)
- elseif input=="transmit" then
- receiving=false
- os.setComputerLabel("Remote Transmitter")
- secondQuestion(receiving)
- else
- print("Incorrect Input!")
- firstQuestion()
- end
- end
- function secondQuestion(receiving)
- welcomeMessage()
- shell.run("id")
- for id, side in pairs(rs.getSides()) do
- if peripheral.getType(side) == "modem" then
- rednet.open(side)
- end
- end
- print("")
- print("Which ID would you like to link to?")
- otherID=tonumber(read())
- if receiving==true then
- receiveFunction()
- elseif receiving==false then
- transmitFunction()
- end
- end
- function receiveFunction()
- welcomeMessage()
- print("Awaiting signals...")
- running=true
- while running do
- id,message=rednet.receive()
- if id==otherID then
- firstSpace=string.find(message," ")
- if firstSpace~=nil then
- command=string.sub(1,firstSpace-1)
- timesToExecute=tonumber(string.gsub(message,command.." ",""))
- else
- command=message
- timesToExecute=1
- end
- turtleFunction(command,timesToExecute)
- end
- end
- end
- function turtleFunction(command,timesToExecute)
- for i=1,timesToExecute do
- if turtle.getFuelLevel() <200 then
- shell.run("refuel")
- end
- if command=="r" then
- shell.run("refuel")
- elseif command=="w" then
- turtle.forward()
- elseif command=="a" then
- turtle.turnLeft()
- turtle.forward()
- elseif command=="s" then
- turtle.turnRight()
- turtle.turnRight()
- turtle.forward()
- elseif command=="d" then
- turtle.turnRight()
- turtle.forward()
- elseif command=="q" then
- turtle.up()
- elseif command=="z" then
- turtle.down()
- elseif command=="x" then
- turtle.dig()
- elseif command=="xup" then
- turtle.digUp()
- elseif command=="xdown" then
- turtle.digDown()
- elseif command=="turnLeft" then
- turtle.turnLeft()
- elseif command=="turnRight" then
- turtle.turnRight()
- elseif command=="clear" then
- os.setComputerLabel("")
- running=false
- elseif command=="f" then
- turtle.attack()
- elseif command=="fup" then
- turtle.attackUp()
- elseif command=="fdown" then
- turtle.attackDown()
- elseif command=="reboot" then
- os.reboot()
- elseif command=="shutdown" then
- os.shutdown()
- elseif command=="addCommand" then
- addCommandFunction()
- elseif command=="stop" then
- running=false
- end
- end
- end
- function addCommandFunction()
- end
- function transmitFunction()
- running=true
- while running do
- welcomeMessage()
- print("")
- print("type 'help' for a list of commands")
- print("")
- write("Command : ")
- command=string.lower(read())
- if command=="help" then
- print("r --> refuel (This should be done automaticly)")
- print("w/a/s/d --> movement")
- print("q/z --> up/down")
- print("x --> dig")
- print("xup --> dig up")
- print("xdown --> dig down")
- print("turnleft/turnright --> turn left/ turn right")
- print("f --> attack")
- print("fup/fdown --> attacks up/down")
- print("shutdown --> Shuts down transmitter and receiver")
- print("reboot --> reboots transmitter and receiver")
- print("stop --> Stops using this program")
- print("clear --> Clear Memory after picking up")
- print("")
- print("Press enter when you wish to return to controlling the turtle.")
- input=read()
- --print("addCommand --> Allows you to add commands")
- elseif command=="addcommand" then
- --NYI
- elseif command=="stop" then
- running=false
- else
- rednet.send(otherID,command)
- end
- end
- end
- welcomeMessage()
- firstQuestion()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement