Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ship = peripheral.find("warpdriveShipController")
- local chat = peripheral.find("warpdriveVirtualAssistant")
- -- Define chat name
- chat.name("[name")
- local ship_front, ship_right, ship_up = ship.dim_positive()
- local ship_back, ship_left, ship_down = ship.dim_negative()
- local ship_isInHyper = ship.isInHyperspace()
- local ship_movement = { ship.movement() }
- local ship_rotationSteps = ship.rotationSteps()
- print("Post Way Point in Chat to Jump Ship and Aligning the Mining Laser")
- while true do
- sleep(0.08)
- local state = 0
- local CMD = 0
- state, CMD = chat.pullLastCommand()
- string = string.lower(CMD)
- -- Match and extract X and Z
- local x_value, y_value, z_value = string:match(".*x:(%-?%d+),%s*y:(%-?%d+),%s*z:(%-?%d+)")
- if state then
- if not (x_value and y_value and z_value) then
- print("Error: Coordinates not found in command.")
- else
- local lastLx = tonumber(x_value)
- local lastLy = tonumber(y_value) -- if needed for future use
- local lastLz = tonumber(z_value)
- print("Jumping to X:" .. lastLx .. ", Z:" .. lastLz)
- local rx, ry, rz = ship.getOrientation()
- local minForwardBack = math.abs(ship_front + ship_back + 1)
- local minLeftRight = math.abs(ship_left + ship_right + 1)
- local mx, my, mz = ship.getLocalPosition()
- local dx = lastLx - mx
- local dz = lastLz - mz
- local forwardBackMov = 0
- local leftRightMov = 0
- -- Determine movement based on ship's orientation.
- if rx == 1 then
- forwardBackMov = dx
- leftRightMov = dz
- elseif rx == -1 then
- forwardBackMov = -dx
- leftRightMov = -dz
- elseif rz == 1 then
- forwardBackMov = dz
- leftRightMov = -dx
- elseif rz == -1 then
- forwardBackMov = -dz
- leftRightMov = dx
- end
- if math.abs(forwardBackMov) < minForwardBack and math.abs(leftRightMov) < minLeftRight then
- print("The movement is too small!")
- else
- ship.movement(forwardBackMov, 0, leftRightMov)
- ship.rotationSteps(0)
- ship.command("MANUAL", true)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement