Advertisement
Shaka01

turtle Remote Sender

Mar 18th, 2023 (edited)
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. receiverTurtle = 40
  2. buildmode = false
  3.  
  4. rednet.open("left")
  5.  
  6. function sendRednetMessage()
  7.   local sides = {"top", "bottom", "left", "right", "front", "back"} -- List of all possible sides
  8.   for _, side in ipairs(sides) do -- Loop through each side
  9.     while rs.getInput(side) do
  10.         if side == "left" and rs.getInput("bottom") then
  11.             buildmode = false
  12.             sleep(0.5)
  13.             rednet.send(receiverTurtle, "right")
  14.             return
  15.         elseif side == "right" and rs.getInput("bottom") then
  16.             buildmode = true
  17.             sleep(0.5)
  18.             rednet.send(receiverTurtle, "left")
  19.             return
  20.         end
  21.       if buildmode == false then
  22.         rednet.send(receiverTurtle, side)
  23.       else
  24.         rednet.send(receiverTurtle, side, "build")
  25.       end
  26.       local sender, message = rednet.receive("moveConfirm", 3)
  27.       if message == nil then
  28.         term.clear()
  29.         term.setCursorPos(1,1)
  30.         print("No connection!")
  31.         --key = os.pullEvent("key")
  32.       else
  33.         print(side)
  34.       end
  35.       sleep(0.4)
  36.       end
  37.   end
  38. end
  39.  
  40.  
  41. while true do
  42. waitPlz = os.pullEvent("redstone")
  43. sendRednetMessage()
  44. end
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement