Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Define dimension builders
- local dbs = {
- {material = "Redstone-Erz", peri = peripheral.wrap("dimension_builder_0")},
- {material = "Yellorit-Erz", peri = peripheral.wrap("dimension_builder_1")},
- {material = "Quarzblock", peri = peripheral.wrap("dimension_builder_2")},
- {material = "Goldblock", peri = peripheral.wrap("dimension_builder_3")},
- {material = "Drakonisches Erz", peri = peripheral.wrap("dimension_builder_4")},
- {material = "Diamant-Erz", peri = peripheral.wrap("dimension_builder_5")},
- {material = "Glowstone", peri = peripheral.wrap("dimension_builder_6")},
- {material = "Certusquarz", peri = peripheral.wrap("dimension_builder_7")},
- {material = "Eisen-Erz", peri = peripheral.wrap("dimension_builder_8")}
- }
- local mon = peripheral.wrap("monitor_1")
- mon.setTextScale(0.5)
- local m_w, m_h = mon.getSize()
- local left_offset = 1
- local block_size = 18
- local num_blocks = math.floor(m_w / block_size)
- -- Function to draw a vertical bar
- local function drawBar(x, y, height, value, max_value, color)
- local fill_height = math.floor(height * value / max_value)
- for i = 0, height - 1 do
- mon.setCursorPos(x, y + i)
- if i < fill_height then
- mon.setBackgroundColor(color)
- mon.write(" ")
- else
- mon.setBackgroundColor(colors.black)
- mon.write(" ")
- end
- end
- end
- -- Main drawing function
- local function drawMonitor()
- mon.clear()
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- for i, db in ipairs(dbs) do
- if i > num_blocks then break end
- local x = left_offset + (i - 1) * block_size
- -- Write material name
- mon.setCursorPos(x, 1)
- mon.write(db.material:sub(1, block_size - 1))
- -- Get values
- local building_percentage = db.peri.getBuildingPercentage()
- local dimension_power = db.peri.getDimensionPower()
- -- Draw BuildingPercentage bar
- drawBar(x, 3, m_h - 2, building_percentage, 100, colors.gray)
- -- Draw DimensionPower bar
- drawBar(x + block_size / 2, 3, m_h - 2, dimension_power, 40000000, colors.green)
- end
- end
- while true do
- drawMonitor()
- sleep(1) -- Update every second
- end
Advertisement
Add Comment
Please, Sign In to add comment