Advertisement
SirBaconBitz

Here's the code causing it.

May 25th, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1. os.loadAPI("zeppelinapi")
  2. handle = fs.open("options", "r")
  3. options = textutils.unserialize(handle.readAll())
  4. handle.close()
  5.  
  6. bridge = peripheral.wrap(options.bridgeside)
  7. carriage = peripheral.wrap(options.carriagecontroller)
  8.  
  9. if not fs.exists("currtask") then
  10.   e, msg, d, b, c = os.pullEvent("chat_command")
  11.   words = {}
  12.   for word in msg:gmatch('%S+') do
  13.     table.insert(words, word)
  14.   end
  15.   gox = words[2]
  16.   goy = words[3]
  17.   goz = words[4]
  18.   --Calculate differences in x, y, and z and store them in a table for later use
  19.   goto = {}
  20.   goto.x = gox - options.x
  21.   goto.y = goy - options.y
  22.   goto.z = goz - options.z
  23.   handle = fs.open("currtask", "w")
  24.   handle.write(textutils.serialize(goto))
  25.   handle.close()
  26. end
  27.  
  28. goto = nil
  29. handle = fs.open("currtask", "r")
  30. goto = textutils.unserialize(handle.readAll())
  31. if goto.x or goto.y or goto.z ~= 0 then
  32.   for k,pos in pairs(goto) do
  33.     if pos ~= 0 then
  34.       local numtype = zeppelinapi.checkpos(pos)
  35.       if k == "x" and numtype == "pos" then
  36.         dir = 5
  37.         coord = "x"
  38.       elseif k == "x" and numtype == "neg" then
  39.         dir = 4
  40.         coord = "x"
  41.         elseif k == "z" and numtype == "pos" then
  42.         dir = 3
  43.         coord = "z"
  44.       elseif k == "z" and numtype == "pos" then
  45.         dir = 2
  46.         coord = "z"
  47.       elseif k == "y" and numtype == "pos" then
  48.         dir = 1
  49.         coord = "y"
  50.       elseif k == "y" and numtype == "neg" then
  51.         dir = 0
  52.         coord = "y"
  53.       end
  54.    
  55.       carriage.move(dir,false,false)
  56.    
  57.       if coord == "x" and numtype == "pos" then
  58.         goto.x = goto.x - 1
  59.       elseif coord == "x" and numtype == "neg" then
  60.         goto.x = goto.x + 1
  61.       elseif coord == "z" and numtype == "pos" then
  62.         goto.z = goto.z - 1
  63.       elseif coord == "z" and numtype == "neg" then
  64.         goto.z = goto.z + 1
  65.       elseif coord == "y" and numtype == "pos" then
  66.         goto.y = goto.y - 1
  67.       elseif coord == "y" and numtype == "neg" then
  68.         goto.y = goto.y + 1
  69.       end
  70.      
  71.       handle = fs.open("currtask", "w")
  72.       handle.write(textutils.serialize(goto))
  73.       handle.close()
  74.     end
  75.   end
  76. else
  77.   fs.delete("currtask")
  78.   os.reboot()
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement