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 lasers = peripheral.getNames()
- for i = #lasers, 1, -1 do
- if peripheral.getType(lasers[i]) ~= "warpdriveLaserCamera" then
- table.remove(lasers, i)
- else
- peripheral.wrap(lasers[i]).beamFrequency(1420)
- end
- end
- 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("Emit Scanning Laser to Jump Ship and Aligning the Mining Laser")
- while true do
- local event, laserName, lx, ly, lz, block, _, _, _, type, metadata, resistance = os.pullEvent()
- if event == "laserScanning" then
- lastLx, lastLy, lastLz = tonumber(lx), tonumber(ly), tonumber(lz)
- print("Jumpinig to X:" .. tonumber(lx) .. ", Z:" .. tonumber(lz))
- 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 = lastLx-mx
- dz = lastLz-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