SHARE
TWEET

creeper.lua

a guest Sep 11th, 2019 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. p = peripheral.wrap("back")
  2. m = peripheral.wrap("top")
  3. s = peripheral.wrap("right")
  4. m.open(15121)
  5. m.open(15122)
  6. m.open(15123)
  7. m.open(15124)
  8. m.open(15125)
  9. m.open(15126)
  10. p1 = false
  11. p2 = false
  12. p3 = false
  13. l1 = false
  14. l2 = false
  15. e1 = false
  16. while true do
  17.     local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  18.     if senderChannel == 15121 then
  19.         p1 = message
  20.         print("Received move X coordinate (" .. p1 .. ").")
  21.     end
  22.     if senderChannel == 15122 then
  23.         p2 = message
  24.         print("Received move Y coordinate (" .. p2 .. ").")
  25.     end
  26.     if senderChannel == 15123 then
  27.         p3 = message
  28.         print("Received move Z coordinate (" .. p3 .. ").")
  29.     end
  30.     if senderChannel == 15124 then
  31.         l1 = message
  32.         print("Received look yaw (" .. l1 .. ").")
  33.     end
  34.     if senderChannel == 15125 then
  35.         l2 = message
  36.         print("Received look pitch (" .. l2 .. ").")
  37.     end
  38.     if senderChannel == 15126 then
  39.         e1 = message
  40.         print("WARNING - RECEIVED EXPLODE COMMAND")
  41.     end
  42.     if p1 ~= false then
  43.         if p2 ~= false then
  44.             if p3 ~= false then
  45.                 x, y, z = gps.locate()
  46.                 mx = 0
  47.                 my = 0
  48.                 mz = 0
  49.                 mx = p1 - x
  50.                 my = p2 - y
  51.                 mz = p3 - z
  52.                 if mx > 32 then
  53.                     mx = 32
  54.                 elseif mx < -32 then
  55.                     mx = -32
  56.                 end
  57.                 if my > 32 then
  58.                     my = 32
  59.                 elseif my < -32 then
  60.                     my = -32
  61.                 end
  62.                 if mz > 32 then
  63.                     mz = 32
  64.                 elseif mz < -32 then
  65.                     mz = -32
  66.                 end
  67.                 p.walk(mx, my, mz)
  68.                 print("MOVING TO (" .. p1 .. ", " .. p2 .. ", " .. p3 .. ").")
  69.                 s.playNote("bell",0.1)
  70.                 p1 = false
  71.                 p2 = false
  72.                 p3 = false
  73.             end
  74.         end
  75.     end
  76.     if l1 ~= false then
  77.         if l2 ~= false then
  78.             p.look(l1, l2)
  79.             print("LOOKING AT (" .. l1 .. ", " .. l2 .. ")")
  80.             s.playNote("flute",0.1)
  81.             l1 = false
  82.             l2 = false
  83.         end
  84.     end
  85.     if e1 ~= false then
  86.         --p.explode()
  87.         e1 = false
  88.         print("WARNING - EXPLODING!")
  89.         while true do
  90.             s.playNote("pling",3)
  91.             sleep(0.1)
  92.             s.playNote("pling",3,6)
  93.             sleep(0.2)
  94.         end
  95.     end
  96. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top