Advertisement
wv1106

airstrike compact computer computercraft

Apr 17th, 2021
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. rednet.open("back")
  2. local cords = {}
  3. local id = 0
  4. local conf = false
  5. local loc = "here"
  6. function location()
  7.     term.clear()
  8.     term.setCursorPos(2, 6)
  9.     write(">here<     other ")
  10.     while conf == false do
  11.         term.setCursorPos(2, 6)
  12.         local event, key, isHeld = os.pullEvent("key")
  13.         if key == keys.left then
  14.             write(">here<     other ")
  15.             loc = "here"
  16.         elseif key == keys.right then
  17.             write(" here     >other<")
  18.             loc = "other"
  19.         end
  20.         if key == keys.enter then
  21.             conf = true
  22.         end
  23.     end
  24. end
  25. function question(text)
  26.     term.clear()
  27.     term.setCursorPos(1, 1)
  28.     print(text)
  29. end
  30.  
  31. while true do
  32.    
  33.     question("what's the pincode?")
  34.     table.insert(cords, 1, read("*"))
  35.     question("what turtle do you want to send?")
  36.     id = tonumber(read())
  37.     location()
  38.     if loc == "here" then
  39.         cords[2], cords[3], cords[4] = gps.locate()
  40.     elseif loc == "other" then
  41.         question("what's the x cord?")
  42.         cords[2] = read()
  43.         question("what's the y cord the turtle should bomb on?")
  44.         cords[3] = read()
  45.         question("what's the z cord?")
  46.         cords[4] = read()
  47.     end
  48.     question("how much tnt should be dropped?")
  49.     cords[5] = read()
  50.  
  51.     local message = textutils.serialise(cords)
  52.  
  53.     rednet.send(id, message, "airstrike")
  54.  
  55.     local id, feedback = rednet.receive("airstrike")
  56.     print(feedback)
  57.     print("press backspace to exit and press a key to continiue")
  58.     local event, key, isHeld = os.pullEvent("key")
  59.    
  60.     if key == keys.backspace then
  61.         os.reboot()
  62.     end
  63. end
  64.  
  65.  
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement