Advertisement
Guest User

ComputerCraft remote controller program

a guest
Oct 19th, 2012
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. rcmdlst = {
  2.     [0] = "bmb",[79] = "place",[80] = "back",[81] = "ddn",[75] = "turnLeft",[76] = "tnl",
  3.     [77] = "turnRight",[71] = "placeUp",[72] = "dfd",[73] = "dup",[82] = "placeDown",
  4.     [83] = "drop",[74] = "refuel",[78] = "slct",[181] = "gpshst",[55] = "gpslct",[28] = "pckup",
  5.     [210] = "place",[211] = "dig",[199] = "dropUp",[207] = "dropDown",[201] = "up",[209] = "down",
  6.     [200] = "forward",[208] = "back",[203] = "turnLeft",[205] = "turnRight",[26] = "digUp",
  7.     [27] = "digDown",[51] = "suckUp",[52] = "suckDown",[45] = "trmn8RC",
  8. }
  9. local cldt = {}
  10. function opnmdm()
  11.     for i,v in pairs(rs.getSides()) do 
  12.         if peripheral.getType(v) == "modem" then
  13.             if not rednet.isOpen(v) then rednet.open(v) end
  14.         return true end
  15.     end
  16. return false end
  17.  
  18. shell.run('clear')
  19. if not opnmdm() then print("Modem Access Error") return false end
  20. repeat
  21.     print("Enter confirmation password for remote turtle control")
  22.     rednet.broadcast(io.read())
  23.     cldt[1],cldt[2] = rednet.receive(2)
  24.     if cldt[1] then print(cldt[1]..": "..cldt[2]) end
  25. until cldt[2] == "password accepted"
  26. print("Use numberpad to control turtleID"..cldt[1].."\n"..[[284693 for dig-moves, 5 to tunnel
  27. 170 to place[Up/Down]
  28. '.' Home End, to drop[Up/Down]
  29. Enter, <, >, to suck[Up/Down]
  30. Del, [, ] to dig [Up/Down] without moving
  31. Direction Keys and PgUp/Dn to move
  32. Press x to end Remote Control]])
  33. cldt[3] = false
  34. repeat
  35.     cldt[4],cldt[5],cldt[6] = os.pullEvent()
  36.     if cldt[4] == "key" and rcmdlst[cldt[5]] then rednet.broadcast(rcmdlst[cldt[5]])
  37.         if cldt[5] == 45 then cldt[3] = true end
  38.     elseif cldt[4] == "rednet_message" then print(cldt[5]..": "..cldt[6])
  39.         if string.find(cldt[6],"^send") then rednet.send(cldt[5],io.read()) end
  40.     elseif cldt[5] == "S" then write("Enter message> ") rednet.broadcast(io.read()) end
  41. until cldt[3]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement