Advertisement
SirBaconBitz

Yeah...

May 24th, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.08 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.     local numtype = zeppelinapi.checkpos(pos)
  34.     if k == "x" and numtype == "pos" then
  35.       dir = 5
  36.       coord = "x"
  37.     elseif k == "x" and numtype == "neg" then
  38.       dir = 4
  39.       coord = "x"
  40.       elseif k == "z" and numtype == "pos" then
  41.       dir = 3
  42.       coord = "z"
  43.     elseif k == "z" and numtype == "pos" then
  44.       dir = 2
  45.       coord = "z"
  46.     elseif k == "y" and numtype == "pos" then
  47.       dir = 1
  48.       coord = "y"
  49.     elseif k == "y" and numtype == "neg" then
  50.       dir = 0
  51.       coord = "y"
  52.     end
  53.    
  54.     carriage.move(dir,false,false)
  55.     if coord == "x" and numtype == "pos" then
  56.       goto.x = goto.x - 1
  57.     elseif coord == "x" and numtype == "neg" then
  58.       goto.x = goto.x + 1
  59.     elseif coord == "z" and numtype == "pos" then
  60.       goto.z = goto.z - 1
  61.     elseif coord == "z" and numtype == "neg" then
  62.       goto.z = goto.z + 1
  63.     elseif coord == "y" and numtype == "pos" then
  64.       goto.y = goto.y - 1
  65.     elseif coord == "y" and numtype == "neg" then
  66.       goto.y = goto.y + 1
  67.     end
  68.      
  69.     handle = fs.open("currtask", "w")
  70.     handle.write(textutils.serialize(goto))
  71.     handle.close()
  72.   end
  73. else
  74.   fs.delete("currtask")
  75.   os.reboot()
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement