Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Basics --
- -- KOGA --
- local t,txt = term, textutils
- local w,h = t.getSize()
- local clr, cls, cp, st, sb, paint, m = t.clear, colors, t.setCursorPos, t.setTextColor, t.setBackgroundColor, paintutils, math
- local ser, unser = txt.serialize, txt.unserialize
- local ms = function(a,b) st(a) sb(b) end -- Multi-Set Text and Color
- -- Functions --
- local status_ref = {
- {color = colors.green, icon = string.char(3)}, -- Status of 1 (Good)
- {color = colors.yellow, icon = string.char(7)}, -- Status of 2 (Degrade)
- {color = colors.red, icon = string.char(19)}, -- Status of 3 (Fail)
- {color = colors.purple, icon = string.char(21)}, -- Status of 4 (Lost / Disconnected)
- }
- local function connectBasics()
- local list, connected = peripheral.getNames(), {}
- for i=1, #list do
- connected[#connected+1] = {term = peripheral.wrap(list[i]), name = peripheral.getType(list[i]), id = list[i], status = 1}
- end
- return connected
- end
- local connected = connectBasics()
- local function drawMainMenu()
- local sel, scroll = 1, 0
- local item_display_max = 6
- while true do
- paint.drawBox(0,0,11,7,colors.gray) sb(colors.black)
- cp(1,1)
- for i=1, math.min(#connected, item_display_max) do
- if sel == i+scroll then write(string.char(187)) else write(" ") end
- st(status_ref[connected[i+scroll].status].color) write(status_ref[connected[i+scroll].status].icon)
- st(colors.white) write("["..i+scroll.."] "..string.sub(connected[i+scroll].name,1,3).."\n")
- end
- a,b,x,y = os.pullEvent()
- if a == "mouse_click" then
- --
- elseif a == "monitor_touch" then
- --
- elseif a == "key" then
- if b == keys.w or b == keys.up then
- sel = sel-1 if sel < 1 then sel = #connected end
- elseif b == keys.s or b == keys.down then
- sel = sel+1 if sel > #connected then sel = 1 end
- elseif b == keys.enter or b == keys.e then
- --
- elseif b == keys.q then
- break
- elseif b == keys.delete then
- --
- end
- end
- if sel > scroll+item_display_max then scroll = sel-item_display_max end
- if sel <= scroll then scroll = math.max(0, sel-1) end
- end
- end
- clr()
- drawMainMenu()
- sleep(.5)
Advertisement
Add Comment
Please, Sign In to add comment