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() |
| 3 | + | local virtualAssistant = peripheral.find("warpdriveVirtualAssistant")
|
| 4 | ||
| 5 | - | for i = #lasers, 1, -1 do |
| 5 | + | |
| 6 | - | if peripheral.getType(lasers[i]) ~= "warpdriveLaserCamera" then |
| 6 | + | |
| 7 | - | table.remove(lasers, i) |
| 7 | + | |
| 8 | - | else |
| 8 | + | |
| 9 | - | peripheral.wrap(lasers[i]).beamFrequency(1420) |
| 9 | + | |
| 10 | ||
| 11 | print("Post Way Point in Chat to Jump Ship and Aligning the Mining Laser")
| |
| 12 | ||
| 13 | while true do | |
| 14 | ||
| 15 | while true do | |
| 16 | sleep(0.08) | |
| 17 | local state = 0 | |
| 18 | local CMD = 0 | |
| 19 | - | print("Emit Scanning Laser to Jump Ship and Aligning the Mining Laser")
|
| 19 | + | state, CMD = virtualAssistant.pullLastCommand() |
| 20 | string = string.lower(CMD) | |
| 21 | ||
| 22 | - | local event, laserName, lx, ly, lz, block, _, _, _, type, metadata, resistance = os.pullEvent() |
| 22 | + | -- Match and extract X and Z |
| 23 | local x_value, z_value = string:match("x:(%d+),%s*y:%d+,%s*z:(%d+)")
| |
| 24 | - | if event == "laserScanning" then |
| 24 | + | if state then |
| 25 | - | lastLx, lastLy, lastLz = tonumber(lx), tonumber(ly), tonumber(lz) |
| 25 | + | print("Jumpinig to X:" .. tonumber(x_value) .. ", Z:" .. tonumber(z_value))
|
| 26 | - | 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 = miningLaser.getLocalPosition() | |
| 31 | dx = x_value-mx | |
| 32 | - | dx = lastLx-mx |
| 32 | + | dz = z_value-mz |
| 33 | - | 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 | end | |
| 64 | ||
| 65 |