phone_server.lua
27 lines · 594 B
PHONE APP MINE--
Copy & run
wget https://perlytiara.github.io/turtles.tips/raw/programs/Maengorn/phone_server.lua
| 1 | --PHONE APP MINE-- |
| 2 | |
| 3 | local SERVER_PORT = 420 |
| 4 | local PHONE_PORT = 69 |
| 5 | |
| 6 | modem = peripheral.wrap("back") |
| 7 | local size = vector.new() |
| 8 | |
| 9 | if (#arg == 3) then |
| 10 | size.x = tonumber(arg[1]) |
| 11 | size.y = tonumber(arg[2]) |
| 12 | size.z = tonumber(arg[3]) |
| 13 | else |
| 14 | print("NO SIZE GIVEN") |
| 15 | os.exit(1) |
| 16 | end |
| 17 | |
| 18 | local target = vector.new(gps.locate()) |
| 19 | local payloadMessage = string.format("%d %d %d %d %d %d %d", |
| 20 | target.x, target.y - 1, target.z, |
| 21 | size.x, size.y, size.z, |
| 22 | 1 |
| 23 | ) |
| 24 | |
| 25 | print(string.format("Targetting %d %d %d", target.x, target.y, target.z)) |
| 26 | modem.transmit(SERVER_PORT, PHONE_PORT, payloadMessage) |
| 27 |