SHOW:
|
|
- or go back to the newest paste.
1 | local ship = peripheral.find("warpdriveShipCore") | |
2 | local miningLaser = peripheral.find("warpdriveMiningLaser") | |
3 | - | local virtualAssistant = peripheral.find("warpdriveVirtualAssistant") |
3 | + | local chat = peripheral.find("warpdriveVirtualAssistant") |
4 | ||
5 | --Define Name | |
6 | chat.name("[name") | |
7 | ||
8 | ship_front, ship_right, ship_up = ship.dim_positive() | |
9 | ship_back, ship_left, ship_down = ship.dim_negative() | |
10 | ship_isInHyper = ship.isInHyperspace() | |
11 | ship_movement = { ship.movement() } | |
12 | ship_rotationSteps = ship.rotationSteps() | |
13 | ||
14 | ||
15 | - | while true do |
15 | + | |
16 | print("Post Way Point in Chat to Jump Ship and Aligning the Mining Laser") | |
17 | ||
18 | while true do | |
19 | - | state, CMD = virtualAssistant.pullLastCommand() |
19 | + | |
20 | sleep(0.08) | |
21 | local state = 0 | |
22 | local CMD = 0 | |
23 | - | local x_value, z_value = string:match("x:(%d+),%s*y:%d+,%s*z:(%d+)") |
23 | + | state, CMD = chat.pullLastCommand() |
24 | string = string.lower(CMD) | |
25 | - | print("Jumpinig to X:" .. tonumber(x_value) .. ", Z:" .. tonumber(z_value)) |
25 | + | |
26 | -- Match and extract X and Z | |
27 | local x_value, y_value, z_value = string:match("x:(%d+),%s*y:(%d+),%s*z:(%d+)") | |
28 | ||
29 | if state then | |
30 | - | local mx, my, mz = miningLaser.getLocalPosition() |
30 | + | |
31 | --lastLx, lastLy, lastLz = tonumber(x_value), tonumber(y_value), tonumber(z_value) | |
32 | --print("Jumpinig to X:" .. tonumber(x_value) .. ", Z:" .. tonumber(z_value)) | |
33 | ||
34 | local rx, ry, rz = ship.getOrientation() | |
35 | minForwardBack = math.abs(ship_front+ship_back+1) | |
36 | minLeftRight = math.abs(ship_left+ship_right+1) | |
37 | local mx, my, mz = miningLaser.getLocalPosition() | |
38 | dx = x_value-mx | |
39 | dz = z_value-mz | |
40 | ||
41 | forwardBackMov = 0 | |
42 | leftRightMov = 0 | |
43 | ||
44 | if rx == 1 then | |
45 | forwardBackMov = dx | |
46 | leftRightMov = dz | |
47 | elseif rx == -1 then | |
48 | forwardBackMov = -dx | |
49 | leftRightMov = -dz | |
50 | elseif rz == 1 then | |
51 | forwardBackMov = dz | |
52 | leftRightMov = -dx | |
53 | elseif rz == -1 then | |
54 | forwardBackMov = -dz | |
55 | leftRightMov = dx | |
56 | end | |
57 | ||
58 | if math.abs(forwardBackMov) < minForwardBack and math.abs(leftRightMov) < minLeftRight then | |
59 | print("The movement is too small!") | |
60 | - | end |
60 | + | |
61 | ||
62 | ||
63 | - | end |
63 | + | |
64 | ship.movement(forwardBackMov, 0, leftRightMov) | |
65 | - | |
65 | + | |
66 | ship.command("MANUAL", true) | |
67 | ||
68 | end | |
69 | end | |
70 | end |