Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- HRZN Staff Server Display v0.1
- -- _ _ _____ ______ _ _
- -- | | | | | __ \ |___ / | \ | |
- -- | |__| | | |__) | / / | \| |
- -- | __ | | _ / / / | . ` |
- -- | | | | | | \ \ / /__ | |\ |
- -- |_| |_| |_| \_\ /_____| |_| \_|
- --
- -- https://hrznstudio.com
- -- Script by JoeZwet
- -- CONFIG (c_mod_var)
- local c_global_display_time = 10 -- Seconds
- local c_ae2_1k_count = 12
- local c_ae2_4k_count = 1
- local c_ae2_16k_count = 0
- local c_ae2_64k_count = 0
- local c_ec2_256k_count = 0
- local c_ec2_1024k_count = 0
- local c_ec2_4096k_count = 0
- local c_ec2_16384k_count = 0
- -- General Init
- local bRunning = true
- local monitor = peripheral.find("monitor")
- local g_tabs = {"ME", "GC"}
- local g_w, g_h = term.getSize()
- term.setBackgroundColor(colors.black)
- term.clear()
- print("Press `q` to exit.")
- term.redirect(monitor)
- term.clear()
- -- AE2 Init
- local ae2_cell = (c_ae2_1k_count * 1024) + (c_ae2_4k_count * 4096) + (c_ae2_16k_count * 16384) + (c_ae2_64k_count * 65536) + (c_ec2_256k_count * 262144) + (c_ec2_1024k_count * 1048576) + (c_ec2_4096k_count * 4194304) + (c_ec2_16384k_count * 16777216)
- local ae2_bridge = peripheral.find("meBridge")
- local ae2_kilo = 1024
- local ae2_units = {"B", "KiB", "MiB", "GiB", "TiB"}
- -- Display functions
- function ae2_draw_line( text, amount )
- local magnitude = math.floor(math.log(amount) / math.log(ae2_kilo))
- local str = tostring(amount / ae2_kilo ^ magnitude):match("^(%d+%.?%d?%d?)%d*0*$") .. ae2_units[magnitude + 1]
- return str
- end
- function draw_text( x, y, text, color, bg )
- term.setCursorPos( x, y )
- term.setTextColor( color )
- term.setBackgroundColor( bg )
- term.write(text)
- end
- function d_ae2()
- local totalSize = 0
- for number, item in pairs(ae2_bridge.listItems()) do
- totalSize = totalSize + item.amount
- totalSize2 = number
- end
- draw_text(2, 5, "HDD: "..ae2_cell, colors.white, colors.black)
- draw_text(2, 6, "Byte Used: "..totalSize, colors.white, colors.black)
- draw_text(2, 7, "Type: "..totalSize2*513, colors.white, colors.black)
- end
- function draw_border( index )
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.yellow)
- for pos, data in ipairs(g_tabs) do
- if pos == index + 1 then
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.yellow)
- else
- term.setBackgroundColor(colors.yellow)
- term.setTextColor(colors.gray)
- end
- term.write(" "..data.." ")
- end
- for i=term.getCursorPos(),g_w do
- term.setBackgroundColor(colors.yellow)
- term.write(" ")
- end
- term.setBackgroundColor(colors.black)
- end
- function update( index )
- draw_border( index )
- if index == 0 then
- draw_text(2, 6, "Coded add", colors.white, colors.black)
- draw_text(2, 7, "PeripheralsPlusOne", colors.white, colors.black)
- elseif index == 1 then
- draw_text(2, 6, "Joe finish", colors.white, colors.black)
- draw_text(2, 7, "GC CC bridge", colors.white, colors.black)
- end
- end
- -- Main Loop
- local m_pages = 2
- local m_index = 0
- local m_loop = 0
- update( 0 )
- local m_timer = os.startTimer(c_global_display_time)
- local m_timer_update = os.startTimer(1)
- while bRunning do
- local event, p1 = os.pullEvent()
- if event == "monitor_touch" or (event == "timer" and p1 == m_timer) then
- m_index = m_index + 1
- if m_index >= m_pages then m_index = 0 end
- m_timer = os.startTimer(c_global_display_time)
- term.clear()
- elseif event == "timer" and p1 == m_timer_update and m_index == 0 then
- update( m_index )
- elseif event == "monitor_resize" then
- local w, h = term.getSize()
- g_w = w
- g_h = h
- elseif event == "key" and p1 == 16 then
- bRunning = false
- end
- update( m_index )
- end
- term.setBackgroundColor(colors.black)
- term.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement