Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --config
- capacitorNum = 2 --the number of capicitorbanks.
- glass = peripheral.find("openperipheral_bridge")--id or side of bridge.
- capacitor = peripheral.find("tile_blockcapacitorbank_name") --id or side of capacitorbank.
- pName = "dragontamerfred"--put your name here.(not in use now)
- --functions
- --dont edit expert only
- function timeDis()--draw text
- time = textutils.formatTime(os.time(),true)
- glass.addText(630,2,time,0xFF0000)
- end
- function chatCommand()
- while true do
- local event, side, name, uuid, msg = os.pullEvent()
- if event == "glasses_chat_command" then
- if msg == "energy on" then
- energy = "true"
- elseif msg == "energy off" then
- energy = "false"
- end
- end
- end
- end
- function drawHud()--draw the hud
- glass.addBox(1,1,677,10,0xFFFFFF,0.2)
- if energy == "true" then--draw the energy bar
- glass.addBox(1,30,50,125,0x000001,0.2)
- local sEnergy = capacitor.getEnergyStored("UNKNOWN")
- local sEnergy = sEnergy*capacitorNum
- local mEnergy = capacitor.getMaxEnergyStored("UNKNOWN")
- local mEnergy = mEnergy*capacitorNum
- local pEnergy = math.floor((sEnergy/mEnergy)*100)
- print ("energy stored: "..pEnergy.."%")
- glass.addText(6,140,pEnergy.."%",0x09FF00)
- glass.addBox(6,35,15,100-pEnergy,0xFDFF00,0.2)
- glass.addBox(6,35,15,100,0x990000,0.5)
- end
- end
- --main loop
- function start()
- while true do
- glass.clear()
- drawHud()
- timeDis()
- glass.sync()
- sleep(.1)
- end
- end
- --the program
- parallel.waitForAll(start, chatCommand)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement