Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Thanks for downloading the Nebulae API!
- -- You can change this API any way you want as long as you leave this in
- -- Made by GamerNebulae
- data = peripheral.getNames(side)
- for i,j in pairs(data) do
- type_peripheral = peripheral.getType(j)
- if type_peripheral == "monitor" then
- mon = peripheral.wrap(data[i])
- elseif type_peripheral == "nuclearReader" then
- information_reader = peripheral.wrap(data[i])
- end
- end
- mon.clear()
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- function clear()
- mon.clear()
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- end
- function dataTable(name, slot, heading, liquid)
- dataTable = {}
- dataTable[name] = {}
- dataTable[name]["side"] = side
- dataTable[name]["slot"] = slot
- dataTable[name]["heading"] = heading
- dataTable[name]["liquid"] = liquid
- drawBar(dataTable)
- end
- function drawBar(info)
- for name, progress_bar in pairs(info) do
- Math(progress_bar)
- if (length_bar >= begin_text) then
- before_text = begin_text - 1
- after_text = begin_text + #text
- for i = 1, before_text do
- mon.setBackgroundColor(colors.blue)
- mon.setCursorPos(i, y_bar)
- mon.write(" ")
- end
- if (length_bar >= begin_text and length_bar <= end_text) then
- splitText(text)
- else
- mon.write(text)
- end
- for j = after_text, length_bar do
- mon.setBackgroundColor(colors.blue)
- mon.setCursorPos(j, y_bar)
- mon.write(" ")
- end
- else
- for i = 1, length_bar do
- mon.setBackgroundColor(colors.blue)
- mon.setCursorPos(i, y_bar)
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(begin_text, y_text)
- mon.write(text)
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- function Math(progress_bar)
- mon_size_x, mon_size_y = mon.getSize()
- y_bar = 2 * progress_bar["slot"]
- x_heading = math.floor(((mon_size_x - #progress_bar["heading"]) / 2) + 1)
- y_heading = 2 * progress_bar["slot"] - 1
- mon.setCursorPos(x_heading, y_heading)
- mon.write(progress_bar["heading"])
- if progress_bar["liquid"] then
- a, b, c, data = information_reader.get(progress_bar["slot"])
- value = math.floor((data.amount / data.capacity) * 100)
- else
- a, b, c, data = information_reader.get(progress_bar["slot"])
- value = math.floor((data.energyL / data.maxStorageL) * 100)
- end
- begin_text = math.floor(((mon_size_x - #(value.."%")) / 2) + 1)
- end_text = math.floor((begin_text + #(value.."%")) - 1)
- y_text = y_bar
- text = tostring(value).."%"
- length_bar = math.floor(mon_size_x * (value / 100))
- end
- function splitText(text)
- colored_text = length_bar - begin_text + 1
- dataText = {}
- for k,v in text:gmatch"." do
- dataText[#dataText + 1] = tostring(k)
- end
- if colored_text <= #dataText then
- mon.setCursorPos(begin_text, y_text)
- for i = 1, colored_text do
- mon.setBackgroundColor(colors.blue)
- mon.write(dataText[i])
- end
- if colored_text < #dataText then
- for j = colored_text + 1, #dataText do
- mon.setBackgroundColor(colors.black)
- mon.write(dataText[j])
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment