View difference between Paste ID: 022CgTyM and 91KgEFeB
SHOW: | | - or go back to the newest paste.
1
local ship = peripheral.find("warpdriveShipCore")
2-
local miningLaser = peripheral.find("warpdriveMiningLaser")
2+
3
4
for i = #lasers, 1, -1 do
5
    if peripheral.getType(lasers[i]) ~= "warpdriveLaserCamera" then
6
        table.remove(lasers, i)
7
    else
8
        peripheral.wrap(lasers[i]).beamFrequency(1420)
9
    end
10
end
11
12
          ship_front, ship_right, ship_up = ship.dim_positive()
13
  		  ship_back, ship_left, ship_down = ship.dim_negative()
14
		  ship_isInHyper = ship.isInHyperspace()
15
		  ship_movement = { ship.movement() }
16
  		  ship_rotationSteps = ship.rotationSteps()
17
18
print("Emit Scanning Laser to Jump Ship and Aligning the Mining Laser")
19
20
while true do
21
    local event, laserName, lx, ly, lz, block, _, _, _, type, metadata, resistance = os.pullEvent()
22
23
    if event == "laserScanning" then
24
        lastLx, lastLy, lastLz = tonumber(lx), tonumber(ly), tonumber(lz)
25
        print("Jumpinig to X:" .. tonumber(lx) .. ", Z:" .. tonumber(lz))
26
        
27
        local rx, ry, rz = ship.getOrientation()
28
        minForwardBack = math.abs(ship_front+ship_back+1)
29
        minLeftRight = math.abs(ship_left+ship_right+1)
30
		local mx, my, mz = ship.getLocalPosition()
31-
		local mx, my, mz = miningLaser.getLocalPosition()
31+
32
            dz = lastLz-mz
33
        
34
        forwardBackMov = 0
35
        leftRightMov = 0
36
 
37
        if rx == 1 then
38
            forwardBackMov = dx
39
            leftRightMov = dz
40
        elseif rx == -1 then
41
            forwardBackMov = -dx
42
            leftRightMov = -dz
43
        elseif rz == 1 then
44
            forwardBackMov = dz
45
            leftRightMov = -dx
46
        elseif rz == -1 then
47
            forwardBackMov = -dz
48
            leftRightMov = dx
49
        end
50
 
51
        if math.abs(forwardBackMov) < minForwardBack and math.abs(leftRightMov) < minLeftRight then
52
            print("The movement is too small!")
53
		else
54
    
55
 
56
        leftRightMov = leftRightMov*1
57
            ship.movement(forwardBackMov, 0, leftRightMov)
58
            ship.rotationSteps(0)
59
            ship.command("MANUAL", true)
60
 end
61
        end
62
    end
63
64