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