phone-app-mine.lua

46 lines · 1000 B

Open raw

PHONE APP MINE--

Copy & run

wget https://perlytiara.github.io/turtles.tips/raw/programs/perlytiara/BigBaemingGamers/phone/phone-app-mine.lua
1--PHONE APP MINE--
2
3local SERVER_PORT = 420
4local PHONE_PORT = 69
5
6local modem = peripheral.wrap("back")
7---@class Vec3
8---@field x number
9---@field y number
10---@field z number
11local size = { x = 0, y = 0, z = 0 }
12
13if (#arg == 3) then
14 local ax = tonumber(arg[1])
15 local ay = tonumber(arg[2])
16 local az = tonumber(arg[3])
17 if not (ax and ay and az) then
18 print("Invalid size numbers")
19 os.exit()
20 end
21 ---@cast ax number
22 ---@cast ay number
23 ---@cast az number
24 size.x = ax
25 size.y = ay
26 size.z = az
27else
28 print("NO SIZE GIVEN")
29 os.exit(1)
30end
31
32local gx, gy, gz = gps.locate()
33if not gx then
34 print("GPS not available")
35 os.exit(1)
36end
37local target = vector.new(gx, gy, gz)
38local payloadMessage = string.format("%d %d %d %d %d %d %d",
39 target.x, target.y - 1, target.z,
40 size.x, size.y, size.z,
41 1
42)
43
44print(string.format("Targetting %d %d %d", target.x, target.y, target.z))
45modem.transmit(SERVER_PORT, PHONE_PORT, payloadMessage)
46