Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("zeppelinapi")
- handle = fs.open("options", "r")
- options = textutils.unserialize(handle.readAll())
- handle.close()
- bridge = peripheral.wrap(options.bridgeside)
- carriage = peripheral.wrap(options.carriagecontroller)
- if not fs.exists("currtask") then
- e, msg, d, b, c = os.pullEvent("chat_command")
- words = {}
- for word in msg:gmatch('%S+') do
- table.insert(words, word)
- end
- gox = words[2]
- goy = words[3]
- goz = words[4]
- --Calculate differences in x, y, and z and store them in a table for later use
- goto = {}
- goto.x = gox - options.x
- goto.y = goy - options.y
- goto.z = goz - options.z
- handle = fs.open("currtask", "w")
- handle.write(textutils.serialize(goto))
- handle.close()
- end
- goto = nil
- handle = fs.open("currtask", "r")
- goto = textutils.unserialize(handle.readAll())
- if goto.x or goto.y or goto.z ~= 0 then
- for k,pos in pairs(goto) do
- local numtype = zeppelinapi.checkpos(pos)
- if k == "x" and numtype == "pos" then
- dir = 5
- coord = "x"
- elseif k == "x" and numtype == "neg" then
- dir = 4
- coord = "x"
- elseif k == "z" and numtype == "pos" then
- dir = 3
- coord = "z"
- elseif k == "z" and numtype == "pos" then
- dir = 2
- coord = "z"
- elseif k == "y" and numtype == "pos" then
- dir = 1
- coord = "y"
- elseif k == "y" and numtype == "neg" then
- dir = 0
- coord = "y"
- end
- carriage.move(dir,false,false)
- if coord == "x" and numtype == "pos" then
- goto.x = goto.x - 1
- elseif coord == "x" and numtype == "neg" then
- goto.x = goto.x + 1
- elseif coord == "z" and numtype == "pos" then
- goto.z = goto.z - 1
- elseif coord == "z" and numtype == "neg" then
- goto.z = goto.z + 1
- elseif coord == "y" and numtype == "pos" then
- goto.y = goto.y - 1
- elseif coord == "y" and numtype == "neg" then
- goto.y = goto.y + 1
- end
- handle = fs.open("currtask", "w")
- handle.write(textutils.serialize(goto))
- handle.close()
- end
- else
- fs.delete("currtask")
- os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement