1
-- Laser‐Guided Warp System ("ztc") with clean, scaled UI and full X,Y,Z reporting
2
3
-- 1) Wrap terminal + any attached monitors
4 -
5 -
for i = #lasers, 1, -1 do
5 +
6 -
if peripheral.getType(lasers[i]) ~= "warpdriveLaserCamera" then
7 -
table.remove(lasers, i)
7 +
table.insert(screens, {
8 +
clear = function() term.clear() term.setCursorPos(1,1) end,
9 -
peripheral.wrap(lasers[i]).beamFrequency(1420)
9 +
getSize = function() return term.getSize() end,
10
setTextColor = term.setTextColor,
11
setBackgroundColor = term.setBackgroundColor,
12
setCursorPos = term.setCursorPos,
13 -
print("Emit Scanning Laser to Set Jump Target Without Y Movements")
14 -
15
16 -
local event, laserName, lx, ly, lz, block, _, _, _, type, metadata, resistance = os.pullEvent()
17 -
17 +
for _, side in ipairs(peripheral.getNames()) do
18 -
if event == "laserScanning" then
18 +
if peripheral.getType(side) == "monitor" then
19 -
-- Convert the laser scanning coordinates to numbers and store them
19 +
local m = peripheral.wrap(side)
20 -
local lastLx = tonumber(lx)
20 +
table.insert(screens, {
21 -
local lastLy = tonumber(ly)
21 +
clear = function() m.clear(); m.setCursorPos(1,1) end,
22 -
local lastLz = tonumber(lz)
22 +
getSize = function() return m.getSize() end,
23 -
23 +
setTextColor = function(c) m.setTextColor(c) end,
24 -
24 +
setBackgroundColor = function(c) m.setBackgroundColor(c) end,
25 -
print("Laser Target: X:" .. lastLx .. " Y:" .. lastLy .. " Z:" .. lastLz)
25 +
setCursorPos = function(x,y) m.setCursorPos(x,y) end,
26
write = function(txt) m.write(txt) end,
27 -
-- Package the coordinates into a table (you can also send a formatted string)
28 -
local data = { x = lastLx, y = lastLy, z = lastLz }
29 -
30 -
-- Broadcast the coordinates using a custom protocol ("coordBroadcast")
30 +
31 -
rednet.broadcast(data, "HorizontalJumpBroadcast")
31 +
32
-- 2) Auto‐scale monitors so 5 lines fit (lines 1,3,5)
33
for _, s in ipairs(screens) do
36
for _, scale in ipairs({1,0.5}) do
37
s.monitor.setTextScale(scale)
38
local w,h = s.getSize()
39
if w >= 40 and h >= 5 then
44
s.monitor.setTextScale(best)
47
49
local function forAll(fn) for _,s in ipairs(screens) do fn(s) end end
50
local function clearAll() forAll(function(s) s.clear() end) end
51
52
-- 4) Header & Subtitle
53
local titleText = "Laser Guided Warp System"
54
local subtitleText = "Emit Scanning Laser to Warp"
55
56
local function drawHeader()
58
local w,_ = s.getSize()
60
-- Title (line 1): white on black
61
local xT = math.floor((w - #titleText)/2) + 1
62
s.setTextColor(colors.white)
63
s.setBackgroundColor(colors.black)
66
-- Subtitle (line 3): black on lightGray
67
local xS = math.floor((w - #subtitleText)/2) + 1
68
s.setTextColor(colors.black)
69
s.setBackgroundColor(colors.lightGray)
74
75
-- 5) Setup peripherals
77
local lasers = peripheral.getNames()
79
if peripheral.getType(lasers[i]) ~= "warpdriveLaserCamera" then
80
table.remove(lasers,i)
82
peripheral.wrap(lasers[i]).beamFrequency(1420)
85
89
90
-- 7) Dynamic coordinate line on row 5 (full X, Y, Z)
91
local function updateCoords(x,y,z)
92
local line = string.format("Target: X:%d Y:%d Z:%d", x, y, z)
94
local w,_ = s.getSize()
95
-- clear entire line 5
96
s.setTextColor(colors.black)
97
s.setBackgroundColor(colors.lightGray)
99
s.write(string.rep(" ", w))
101
local xs = math.floor((w - #line)/2) + 1
106
107
-- 8) Main loop: listen for laserScanning
109
local event, side, lx, ly, lz = os.pullEvent("laserScanning")
110
local tx = tonumber(lx)
111
local ty = tonumber(ly)
112
local tz = tonumber(lz)
113
updateCoords(tx, ty, tz)
114
rednet.broadcast({ x = tx, y = ty, z = tz }, "HorizontalJumpBroadcast")
116