Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function setTurtleID(x)
- if turtleID == nil or x == 1 then
- print("Enter ID of receiver (WLAN turtle):")
- turtleID = read()
- turtleID = tonumber(turtleID)
- print("Thanks!\n")
- end
- return turtleID
- end
- function sendcmd(cmd)
- print(turtleID.." -> "..cmd)
- t = rednet.send(turtleID, cmd)
- -- print(t)
- x,y,z = rednet.receive()
- print("received:"..y)
- end
- function menu()
- print("\nJassens Commander V1.20\n")
- print("-- M E N U --\n")
- print("1 - single commands")
- print("2 - commands file")
- print("3 - single command list")
- print("4 - info")
- print("5 - execute command")
- print("6 - change receiver")
- print("7 - change monitor side")
- print("8 - exit\n")
- end
- function info()
- print("Current receiver is: "..tostring(turtleID))
- end
- function multiCmd()
- xy = 0
- while xy == 0 do
- sendcmd("left 4")
- sleep(2)
- end
- end
- function readFile(file)
- datei = io.open(file, "r")
- if datei == nil then
- print("File not found!")
- return
- end
- zeile = "xxx"
- counter = 1
- while zeile ~= "" do
- zeile = datei:read()
- --print("debug:".."-"..zeile.."-")
- if zeile ~= nil then
- print("Line Nr: "..counter)
- sendcmd(zeile)
- counter = counter + 1
- else
- print("- End of command-file -")
- return
- end
- end
- datei:close()
- end
- function connectModen(positionx)
- if rednet.isOpen(positionx) then
- print("Modem found and ready for communication!")
- else
- rednet.open(positionx)
- if rednet.isOpen(positionx) then
- print("Modem found and connected")
- else
- print("Modem NOT found! Install to right side!")
- exit()
- end
- end
- end
- function writeMonitor(output)
- monitor.write(output.."\n")
- end
- function intallMonitor(side)
- if side == nil or side == 1 then
- print("Enter side of monitor to connect to (right,left,back,top ...):")
- print("... or press enter to skip")
- side2 = read()
- if side2 == "" then
- return ""
- end
- monitor = peripheral.wrap(side2)
- print("Thanks!\n")
- writeMonitor("Thanks!"..">")
- writeMonitor("test!"..">")
- end
- return side2
- end
- function main()
- menu()
- input = read()
- if input == "1" then
- print("Enter a command like: up 1")
- comd = read()
- sendcmd(comd)
- elseif input == "2" then
- print("Enter a command-file please!")
- comd = read()
- readFile(comd)
- elseif input == "3" then
- print("\n-- Commandlist --\n")
- print("fwd + Anzahl = Vorwaerts")
- print("up + Anzahl = Hoch")
- print("down + Anzahl = Runter")
- print("left = links")
- print("right = rechts")
- print("...enter for next site")
- read()
- print("startmatrix [argument] begin with newmatrix")
- print(" - argument: 0 - digs and collects all items expect the items in slots 1-4")
- print(" - argument: 1 - build with items in all slots where matrix not nil")
- print(" - argument: 4 - build with 4 different items matrix 1 for slots 1-4")
- print(" matrix 2 for slots 5-8, matrix 3 for slots 9-12 .... aso")
- print("matrix [argumentrow] - builds a blox for each argument.")
- print(" - argument: 0 - empty - 1 set a block of type 1 .... 2 ste a block of type 2 ...aso")
- print("newlayer - sends the turtle to begin of next layer")
- print("endmatrix - sets turtle to first layer at position -1 of the matrix")
- print("...enter back to menu")
- read()
- elseif input == "4" then
- info()
- elseif input == "5" then
- print("Enter a command to execute on your receiver")
- comd = read()
- sendcmd("execute "..comd)
- elseif input == "6" then
- turtleID = setTurtleID(1)
- elseif input == "7" then
- side = intallMonitor(1)
- elseif input == "8" then
- return "leave"
- else
- print("Error - Unknown command!\n")
- end
- end
- connectModen("right")
- turtleID = setTurtleID(2)
- monitor = ""
- side = intallMonitor()
- while abc == nil do
- what = main()
- if what == "leave" then
- return 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment