Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local drone = component.proxy(component.list("drone")())
- local leash = component.proxy(component.list("leash")())
- local modem = component.proxy(component.list("modem")())
- local port = 36
- modem.open(port)
- modem.setWakeMessage("ohshit")
- local dx = 0
- local dy = 0
- local dz = 0
- local way = false
- local waytoY = false
- commands = {
- ["w"] = function() nz = dz + 1 drone.move(dx, dy, nz) end,
- ["a"] = function() nx = dx + 1 drone.move(nx, dy, dz) end,
- ["s"] = function() nz = dz - 1 drone.move(dx, dy, nz) end,
- ["d"] = function() nx = dx - 1 drone.move(nx, dy, dz) end,
- ["e"] = function() ny = dy + 1 drone.move(dx, ny, dz) end,
- ["r"] = function() ny = dy - 1 drone.move(dx, ny, dz) end,
- ["p"] =
- function(toY, x, z, toX, toZ)
- way = true
- if dy ~= 0 then toY = toY + dy end
- drone.move(toX - x, toY, toZ - z)
- end,
- ["v"] = function() computer.shutdown(false) end,
- ["c"] = function() leashPig() end,
- ["z"] = function() leash.unleash() end,
- ["onpos"] = function() computer.beep(1000, 2) commands["reload"]() end,
- ["toY"] = function(toY) if dy ~= 0 then toY = toY + dy end drone.move(dx, toY, dz) waytoY = true end,
- ["reload"] = function() computer.shutdown(true) end
- }
- function leashPig()
- for i = 0, 5 do
- if leash.leash(i) then return end
- end
- end
- while true do
- event, _, _, _, _, msg, toY, x, z, toX, toZ = computer.pullSignal(1)
- if event == "modem_message" then
- if msg == "p" then
- commands["p"](toY, x, z, toX, toZ)
- elseif msg == "toY" then
- commands["toY"](toY)
- elseif commands[msg] then
- commands[msg]()
- end
- end
- if waytoY then if drone.getOffset() <= 1 then modem.broadcast(port, "onY") waytoY = false end end
- if way then if drone.getOffset() <= 1 then modem.broadcast(port, "onpos") way = false end end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement