View difference between Paste ID: zctBaHVy and MuKVe9dy
SHOW: | | - or go back to the newest paste.
1-
-- Set up colors: black text on light gray background
1+
-- Wrap the terminal and any attached CC:Tweaked monitors as “screens”
2-
term.setTextColor(colors.black)
2+
local screens = {}
3-
term.setBackgroundColor(colors.lightGray)
3+
4-
term.clear()  -- apply background to entire screen
4+
-- Terminal wrapper
5
table.insert(screens, {
6-
print("Press M to Activate Horizontal Mining System")
6+
  clear              = function() term.clear() term.setCursorPos(1,1) end,
7-
print("           ")
7+
  getSize            = function() return term.getSize() end,
8-
print("Press J to Activate Laser Guided Warp System")
8+
  setTextColor       = term.setTextColor,
9
  setBackgroundColor = term.setBackgroundColor,
10-
-- Restore default colors for pasted scripts if they rely on them
10+
  setCursorPos       = term.setCursorPos,
11
  write              = term.write,
12-
  term.setTextColor(colors.white)
12+
})
13-
  term.setBackgroundColor(colors.black)
13+
14
-- Monitor wrappers
15
for _, side in ipairs(peripheral.getNames()) do
16-
if not fs.exists("jzc") then
16+
  if peripheral.getType(side) == "monitor" then
17-
  resetColors()
17+
    local m = peripheral.wrap(side)
18-
  shell.run("pastebin get rfXW7SiN jzc")
18+
    table.insert(screens, {
19-
  term.clear()
19+
      clear              = function() m.clear() m.setCursorPos(1,1) end,
20-
  term.setTextColor(colors.black)
20+
      getSize            = function() return m.getSize() end,
21-
  term.setBackgroundColor(colors.lightGray)
21+
      setTextColor       = function(c) m.setTextColor(c) end,
22
      setBackgroundColor = function(c) m.setBackgroundColor(c) end,
23
      setCursorPos       = function(x,y) m.setCursorPos(x,y) end,
24-
if not fs.exists("ztc") then
24+
      write              = function(txt) m.write(txt) end,
25-
  resetColors()
25+
      monitor            = m,
26-
  shell.run("pastebin get S9SW0zHJ ztc")
26+
    })
27-
  term.clear()
27+
28-
  term.setTextColor(colors.black)
28+
29-
  term.setBackgroundColor(colors.lightGray)
29+
30
-- Menu lines
31
local titleText = "Main Menu"
32
local labelOne  = "Horizontal Mining System "
33-
  local event, key = os.pullEvent("key")
33+
local labelTwo  = "Laser Guided Warp System "
34
local hintOne   = "(Press M)"
35-
    print("Booting Horizontal Mining System...")
35+
local hintTwo   = "(Press J)"
36
37
-- Auto-scale monitors so our 5‑line layout (lines 1,3,5) always fits
38-
    -- when it returns, restore our colors
38+
for _, s in ipairs(screens) do
39-
    term.clear()
39+
  if s.monitor then
40-
    term.setTextColor(colors.black)
40+
    local chosen = 0.5
41-
    term.setBackgroundColor(colors.lightGray)
41+
    for _, scale in ipairs({1, 0.5}) do
42
      s.monitor.setTextScale(scale)
43-
    print("Booting Laser Guided Warp System...")
43+
      local w,h = s.getSize()
44
      if w >= #labelOne + #hintOne and h >= 5 then
45
        chosen = scale
46-
    term.clear()
46+
        break
47-
    term.setTextColor(colors.black)
47+
      end
48-
    term.setBackgroundColor(colors.lightGray)
48+
    end
49
    s.monitor.setTextScale(chosen)
50
  end
51
end
52
53
-- Helper to run a function on all screens
54
local function forAll(fn)
55
  for _, s in ipairs(screens) do fn(s) end
56
end
57
58
-- Draw the centered menu:
59
--   • Title at Y=1 in white-on-black
60
--   • Option1 at Y=3: label in black-on-lightGray, hint in white-on-green
61
--   • Option2 at Y=5: same
62
local function drawMenu()
63
  for _, s in ipairs(screens) do
64
    -- Base background
65
    s.setTextColor(colors.black)
66
    s.setBackgroundColor(colors.lightGray)
67
    s.clear()
68
    local w,h = s.getSize()
69
70
    -- Title (line 1) white-on-black
71
    local xT = math.floor((w - #titleText)/2) + 1
72
    s.setTextColor(colors.white)
73
    s.setBackgroundColor(colors.black)
74
    s.setCursorPos(xT, 1)
75
    s.write(titleText)
76
77
    -- Option 1 (line 3)
78
    local full1 = labelOne .. hintOne
79
    local x1 = math.floor((w - #full1)/2) + 1
80
    -- label
81
    s.setTextColor(colors.black)
82
    s.setBackgroundColor(colors.lightGray)
83
    s.setCursorPos(x1, 3)
84
    s.write(labelOne)
85
    -- hint
86
    s.setTextColor(colors.white)
87
    s.setBackgroundColor(colors.green)
88
    s.write(hintOne)
89
90
    -- Option 2 (line 5)
91
    local full2 = labelTwo .. hintTwo
92
    local x2 = math.floor((w - #full2)/2) + 1
93
    s.setTextColor(colors.black)
94
    s.setBackgroundColor(colors.lightGray)
95
    s.setCursorPos(x2, 5)
96
    s.write(labelTwo)
97
    s.setTextColor(colors.white)
98
    s.setBackgroundColor(colors.green)
99
    s.write(hintTwo)
100
  end
101
end
102
103
-- Initial draw
104
drawMenu()
105
106
-- Reset to default colors & clear (for loading external scripts)
107
local function resetColors()
108
  forAll(function(s)
109
    s.setTextColor(colors.white)
110
    s.setBackgroundColor(colors.black)
111
    s.clear()
112
  end)
113
end
114
115
-- Load a pastebin script if missing, then re‑draw the menu
116
local function loadIfMissing(name,id)
117
  if not fs.exists(name) then
118
    resetColors()
119
    shell.run("pastebin get "..id.." "..name)
120
    drawMenu()
121
  end
122
end
123
124
loadIfMissing("jzc","rfXW7SiN")
125
loadIfMissing("ztc","S9SW0zHJ")
126
127
-- Main key loop
128
while true do
129
  local _, key = os.pullEvent("key")
130
  if key == keys.m then
131
    -- Feedback
132
    forAll(function(s)
133
      s.clear()
134
      s.setTextColor(colors.black)
135
      s.setBackgroundColor(colors.lightGray)
136
      s.setCursorPos(1,1)
137
      s.write("Booting Horizontal Mining System...")
138
    end)
139
    resetColors()
140
    shell.run("jzc")
141
    drawMenu()
142
143
  elseif key == keys.j then
144
    forAll(function(s)
145
      s.clear()
146
      s.setTextColor(colors.black)
147
      s.setBackgroundColor(colors.lightGray)
148
      s.setCursorPos(1,1)
149
      s.write("Booting Laser Guided Warp System...")
150
    end)
151
    resetColors()
152
    shell.run("ztc")
153
    drawMenu()
154
  end
155
end
156