Advertisement
star_weaver

Untitled

Mar 2nd, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.82 KB | None | 0 0
  1. local function check()
  2.   if turtle.getFuelLevel() < 5 then
  3.         turtle.select(16)
  4.         turtle.refuel(1)
  5.         turtle.select(1)
  6.   end
  7. end
  8. local function RoxSlave()
  9.   local run = 1
  10.   while run == 1 do
  11.         local scrap, message = rednet.receive()
  12. ----- Dav's addtions ---
  13. local splitData = {}
  14. local index = 1
  15. for data in string.gmatch(message, "[^,]+") do
  16.         splitData[index] = data;
  17.         index = index + 1
  18. end
  19. print(message)
  20. if type(splitData[2]) == "string" then
  21. print("splitData 2 is a string")
  22. splitData[2]= tonumber(splitData[2])
  23. end
  24. --------- Above takes rednet recieve data and makes it split the value into 2 values in the table 'splitData'
  25.         if splitData[1] == "MoveForward" then
  26.           check()
  27.           turtle.forward()
  28.         elseif splitData[1] == "MoveBack" then
  29.           check()
  30.           turtle.back()
  31.         elseif splitData[1] == "MoveLeft" then
  32.           turtle.turnLeft()
  33.         elseif splitData[1] == "MoveRight" then
  34.           turtle.turnRight()
  35.         elseif splitData[1] == "MoveUp" then
  36.           check()
  37.           turtle.up()
  38.         elseif splitData[1] == "MoveDown" then
  39.           check()
  40.           turtle.down()
  41.         elseif splitData[1] == "DigForward" then
  42.           turtle.dig()
  43.         elseif splitData[1] == "DigUp" then
  44.           turtle.digUp()
  45.         elseif splitData[1] == "DigDown" then
  46.           turtle.digDown()
  47. -------- Dav's addtions
  48.         elseif splitData[1] == "Select" then
  49.           turtle.select(splitData[2])
  50.         elseif splitData[1] == "SuckForward" then
  51.           turtle.suck()
  52.         elseif splitData[1] == "SuckUp" then
  53.           turtle.suckUp()
  54.         elseif splitData[1] == "SuckDown" then
  55.           turtle.suckDown()
  56.         elseif splitData[1] == "DropForward" then
  57.           turtle.drop()
  58.         elseif splitData[1] == "DropUp" then
  59.           turtle.dropUp()
  60.         elseif splitData[1] == "DropDown" then
  61.           turtle.dropDown()
  62.         elseif splitData[1] == "PlaceForward" then
  63.           turtle.place()
  64.         elseif splitData[1] == "PlaceUp" then
  65.           turtle.placeUp()
  66.         elseif splitData[1] == "PlaceDown" then
  67.           turtle.placeDown()
  68. -----------
  69.         elseif splitData[1] == "EndTurtle" then
  70.           run = 0
  71.           rednet.close("right")
  72.           textutils.slowPrint("Console ended program.")
  73.         elseif splitData[1] == "EndBoth" then
  74.           run = 0
  75.           rednet.close("right")
  76.           textutils.slowPrint("Console ended program.")
  77.         end
  78.   end
  79. end
  80. rednet.open("right")
  81. term.clear()
  82. textutils.slowPrint("Rox Remote Control Turtle \(RoxRCT\)")
  83. print("---------------------------------------")
  84. print("Receiver ready. Awaiting command from")
  85. print("the console.")
  86. print("Fuel is used from slot 16.")
  87. print("---------------------------------------")
  88. RoxSlave()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement