View difference between Paste ID: qs4SAcmL and cjCftN4q
SHOW: | | - or go back to the newest paste.
1-
-- Wrap the terminal and any attached CC:Tweaked monitors as “screens”
1+
-- Laser‑Guided Warp System (“ztc”) with H/I/O prompts and O‑key to run otc
2
3
-- 1) Wrap terminal + any attached monitors
4
local screens = {}
5
6-
  clear              = function() term.clear() term.setCursorPos(1,1) end,
6+
7
table.insert(screens, {
8
  clear              = function() term.clear(); term.setCursorPos(1,1) end,
9
  getSize            = function() return term.getSize() end,
10
  setTextColor       = term.setTextColor,
11
  setBackgroundColor = term.setBackgroundColor,
12
  setCursorPos       = term.setCursorPos,
13
  write              = term.write,
14
})
15
16
-- Monitor wrappers
17
for _, side in ipairs(peripheral.getNames()) do
18
  if peripheral.getType(side) == "monitor" then
19-
      clear              = function() m.clear() m.setCursorPos(1,1) end,
19+
20
    table.insert(screens, {
21
      clear              = function() m.clear(); m.setCursorPos(1,1) end,
22
      getSize            = function() return m.getSize() end,
23
      setTextColor       = function(c) m.setTextColor(c) end,
24
      setBackgroundColor = function(c) m.setBackgroundColor(c) end,
25
      setCursorPos       = function(x,y) m.setCursorPos(x,y) end,
26
      write              = function(txt) m.write(txt) end,
27
      monitor            = m,
28
    })
29
  end
30-
-- Menu content
30+
31-
local titleText      = "Main Menu"
31+
32-
local optionOneText  = "Horizontal Mining System "
32+
-- 2) Auto‑scale monitors so at least 7 lines will fit
33-
local optionOneKey   = "(Press M)"
33+
34-
local optionTwoText  = "Laser Guided Warp System "
34+
35-
local optionTwoKey   = "(Press J)"
35+
    local best = 0.5
36
    for _, scale in ipairs({1, 0.5}) do
37-
-- Determine total option lengths
37+
38-
local optionOneTotal = optionOneText .. optionOneKey
38+
39-
local optionTwoTotal = optionTwoText .. optionTwoKey
39+
      if w >= 40 and h >= 7 then
40
        best = scale
41-
-- Auto-scale monitors so our 5-line layout (lines 1,3,5) fits
41+
42
      end
43
    end
44-
    local chosen = 0.5
44+
    s.monitor.setTextScale(best)
45
  end
46
end
47
48-
      if w >= #optionTwoTotal and h >= 5 then
48+
-- 3) Helpers
49-
        chosen = scale
49+
local function forAll(fn) for _,s in ipairs(screens) do fn(s) end end
50
51
-- Clear every screen to lightGray
52
local function clearAll()
53-
    s.monitor.setTextScale(chosen)
53+
54
    s.setTextColor(colors.black)
55
    s.setBackgroundColor(colors.lightGray)
56
    s.clear()
57-
-- Helper: apply fn to every screen
57+
58-
local function forAll(fn)
58+
59-
  for _, s in ipairs(screens) do fn(s) end
59+
60
-- 4) Static texts
61
local titleText     = "Laser Guided Warp System"
62-
-- Draw the centered menu:
62+
local subtitleText  = "Emit Scanning Laser to Warp"
63-
--   • Title at Y=1 in white-on-black
63+
local offsetText    = "Mining Laser Offset ( I ): "
64-
--   • OptionOne at Y=3: preText black-on-lightGray, key white-on-lime
64+
local proximityText = "3D Proximity Offset ( O ): "
65-
--   • OptionTwo at Y=5: same styling
65+
local promptH       = "Press H for Main Menu"
66-
local function drawMenu()
66+
local promptI       = "Press I to Toggle Laser Miner Offset"
67-
  for _, s in ipairs(screens) do
67+
local promptO       = "Press O to Toggle 3D Proximity Offset"
68-
    -- clear to light gray base
68+
69
-- Draw title, subtitle, offset‑state and proximity‑state lines
70
local function drawStatic()
71
  forAll(function(s)
72
    local w,_ = s.getSize()
73
    -- Title (line 1): white on black
74-
    -- Title (line 1) in white-on-black
74+
75
    s.setTextColor(colors.white)
76
    s.setBackgroundColor(colors.black)
77
    s.setCursorPos(xT,1)
78-
    s.setCursorPos(xT, 1)
78+
79
80
    -- Subtitle (line 3): black on lightGray
81-
    -- Option 1 (line 3)
81+
    local xS = math.floor((w - #subtitleText)/2) + 1
82-
    local x1 = math.floor((w - #optionOneTotal)/2) + 1
82+
83-
    s.setCursorPos(x1, 3)
83+
84-
    -- preText
84+
    s.setCursorPos(xS,3)
85
    s.write(subtitleText)
86
87-
    s.write(optionOneText)
87+
    -- Mining Laser Offset (line 4)
88-
    -- key portion
88+
    local fullOffset = offsetText.."ON"
89
    local xO = math.floor((w - #fullOffset)/2) + 1
90
    s.setTextColor(colors.black)
91-
    s.write(optionOneKey)
91+
92
    s.setCursorPos(1,4)
93-
    -- Option 2 (line 5)
93+
    s.write(string.rep(" ", w))
94-
    local x2 = math.floor((w - #optionTwoTotal)/2) + 1
94+
    s.setCursorPos(xO,4)
95-
    s.setCursorPos(x2, 5)
95+
    s.write(offsetText)
96
    s.setTextColor(colors.white)
97
    s.setBackgroundColor(colors.lime)
98-
    s.write(optionTwoText)
98+
    s.write("ON")
99
100
    -- 3D Proximity Offset (line 5)
101-
    s.write(optionTwoKey)
101+
    local fullProx = proximityText.."OFF"
102
    local xP = math.floor((w - #fullProx)/2) + 1
103
    s.setTextColor(colors.black)
104
    s.setBackgroundColor(colors.lightGray)
105-
-- Initial draw
105+
    s.setCursorPos(1,5)
106-
drawMenu()
106+
    s.write(string.rep(" ", w))
107
    s.setCursorPos(xP,5)
108-
-- Reset to default colors & clear (for loading external scripts)
108+
    s.write(proximityText)
109-
local function resetColors()
109+
110
    s.setBackgroundColor(colors.red)
111
    s.write("OFF")
112
  end)
113
end
114
115
-- Draw prompts on the bottom three rows
116
local function drawPrompt()
117-
-- Load a pastebin script if missing, then re‑draw the menu
117+
118-
local function loadIfMissing(name,id)
118+
119-
  if not fs.exists(name) then
119+
    -- line h-2: O prompt
120-
    resetColors()
120+
121-
    shell.run("pastebin get "..id.." "..name)
121+
    s.setBackgroundColor(colors.blue)
122-
    drawMenu()
122+
    s.setCursorPos(1,h-2)
123
    s.write(string.rep(" ", w))
124
    local xO = math.floor((w - #promptO)/2) + 1
125
    s.setCursorPos(xO,h-2)
126-
loadIfMissing("jzc","Lv1SHsGc")
126+
    s.write(promptO)
127-
loadIfMissing("ztc","qs4SAcmL")
127+
    -- line h-1: H prompt
128-
loadIfMissing("itc","fXLxQmpe")
128+
129-
loadIfMissing("otc","0bWu4YgN")
129+
    s.setBackgroundColor(colors.blue)
130
    s.setCursorPos(1,h-1)
131-
-- Main key loop
131+
    s.write(string.rep(" ", w))
132
    local xH = math.floor((w - #promptH)/2) + 1
133-
  local _, key = os.pullEvent("key")
133+
    s.setCursorPos(xH,h-1)
134-
  if key == keys.m then
134+
    s.write(promptH)
135-
    -- Feedback
135+
    -- line h: I prompt
136-
    forAll(function(s)
136+
    s.setBackgroundColor(colors.blue)
137-
      s.clear()
137+
    s.setCursorPos(1,h)
138-
      s.setTextColor(colors.black)
138+
    s.write(string.rep(" ", w))
139-
      s.setBackgroundColor(colors.lightGray)
139+
    local xI = math.floor((w - #promptI)/2) + 1
140-
      s.setCursorPos(1,1)
140+
    s.setCursorPos(xI,h)
141-
      s.write("Booting Horizontal Mining System...")
141+
    s.write(promptI)
142-
    end)
142+
143-
    resetColors()
143+
144-
    shell.run("jzc")
144+
145-
    drawMenu()
145+
-- 5) Set up warpdriveLaserCamera peripherals
146
rednet.open("top")
147-
  elseif key == keys.j then
147+
local cams = peripheral.getNames()
148-
    forAll(function(s)
148+
for i=#cams,1,-1 do
149-
      s.clear()
149+
  if peripheral.getType(cams[i]) ~= "warpdriveLaserCamera" then
150-
      s.setTextColor(colors.black)
150+
    table.remove(cams,i)
151-
      s.setBackgroundColor(colors.lightGray)
151+
  else
152-
      s.setCursorPos(1,1)
152+
    peripheral.wrap(cams[i]).beamFrequency(1420)
153-
      s.write("Booting Laser Guided Warp System...")
153+
154-
    end)
154+
155-
    resetColors()
155+
156-
    shell.run("ztc")
156+
-- 6) Initial draw (blank coords)
157-
    drawMenu()
157+
clearAll()
158
drawStatic()
159
drawPrompt()
160
161
-- 7) Coords line, accepts nil → blanks before first scan
162
local function updateCoords(x,y,z)
163
  local sx = x and tostring(x) or "    "
164
  local sy = y and tostring(y) or "    "
165
  local sz = z and tostring(z) or "    "
166
  local coordLine = string.format("Target: X:%s   Y:%s   Z:%s", sx, sy, sz)
167
  forAll(function(s)
168
    local w,_ = s.getSize()
169
    s.setTextColor(colors.black)
170
    s.setBackgroundColor(colors.lightGray)
171
    s.setCursorPos(1,6)
172
    s.write(string.rep(" ", w))
173
    local cx = math.floor((w - #coordLine)/2) + 1
174
    s.setCursorPos(cx,6)
175
    s.write(coordLine)
176
  end)
177
end
178
179
-- draw initial blanks (on line 6)
180
updateCoords(nil,nil,nil)
181
182
-- 8) Main loop: scan + key handling
183
while true do
184
  local ev,k,b,c,d = os.pullEventRaw()
185
  if ev == "laserScanning" then
186
    local tx = tonumber(b)
187
    local ty = tonumber(c)
188
    local tz = tonumber(d)
189
    updateCoords(tx,ty,tz)
190
local data = { x = tx, y = ty, z = tz }
191
    rednet.broadcast(data, "HorizontalJumpMinerBroadcast")
192
193
  elseif ev == "key" then
194
    if k == keys.h then
195
      os.reboot()
196
    elseif k == keys.i then
197
      shell.run("itc")
198
      clearAll(); drawStatic(); updateCoords(tx,ty,tz); drawPrompt()
199
    elseif k == keys.o then
200
      shell.run("otc")
201
      clearAll(); drawStatic(); updateCoords(tx,ty,tz); drawPrompt()
202
    end
203
  end
204
end
205