Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ship = peripheral.find("warpdriveShipCore")
- local miningLaser = peripheral.find("warpdriveMiningLaser")
- local chat = peripheral.find("warpdriveVirtualAssistant")
- --Define Name
- chat.name("[name")
- ship_front, ship_right, ship_up = ship.dim_positive()
- ship_back, ship_left, ship_down = ship.dim_negative()
- ship_isInHyper = ship.isInHyperspace()
- ship_movement = { ship.movement() }
- 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
- --lastLx, lastLy, lastLz = tonumber(x_value), tonumber(y_value), tonumber(z_value)
- --print("Jumpinig to X:" .. tonumber(x_value) .. ", Z:" .. tonumber(z_value))
- local rx, ry, rz = ship.getOrientation()
- minForwardBack = math.abs(ship_front+ship_back+1)
- minLeftRight = math.abs(ship_left+ship_right+1)
- local mx, my, mz = miningLaser.getLocalPosition()
- dx = x_value-mx
- dz = z_value-mz
- forwardBackMov = 0
- leftRightMov = 0
- 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
- leftRightMov = leftRightMov*1
- ship.movement(forwardBackMov, 0, leftRightMov)
- ship.rotationSteps(0)
- ship.command("MANUAL", true)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement