Questions about using CC to display 8 Ener...
starwind 23 Jun 2014
Hey there
Im just wondering if there is a way to have computercraft to show the power information of 8 energy cell combined on a monitor?
to make it so i can see how much power i have left without having to go down and clicking on every cell
maybe even getting it to show on those open pheriperal glasses aswell
Altho i'm very new to computercraft and dont really know how to write code, im wondering if this is even possible and if it is, is this something hard to learn to do?
perhaps there even is code upploaded somewhere, ( have been google'ing around abit with no luck )
Im just wondering if there is a way to have computercraft to show the power information of 8 energy cell combined on a monitor?
to make it so i can see how much power i have left without having to go down and clicking on every cell
maybe even getting it to show on those open pheriperal glasses aswell
Altho i'm very new to computercraft and dont really know how to write code, im wondering if this is even possible and if it is, is this something hard to learn to do?
perhaps there even is code upploaded somewhere, ( have been google'ing around abit with no luck )
GamerNebulae 23 Jun 2014
It is possible, yes. It's actually very easy to do that. The problem is the way you want to visualize it. It's going to be very long and if an error occurs and you didn't make it "trial-and-error"-style, then you are going to have a bad time. If you upload some code, I will help you with that. If you want to see what methods are available, put a computer on the side of an energy cell, and type this (please change the side variable to the side the energy cell is on):
peripheral.getMethods(side)That will print a table and you can pick two of the methods that have a very obvious name to what you wanna do.
starwind 23 Jun 2014
Yeah have done that
getAdvancedMethodsData
getEnergyStored
getMaxEnergyStored
Problem is its 50 million RF or something in each energy cell, so printing the numbers would be a mess, maybe a bar would be better, but harder to do again i guess
getAdvancedMethodsData
getEnergyStored
getMaxEnergyStored
Problem is its 50 million RF or something in each energy cell, so printing the numbers would be a mess, maybe a bar would be better, but harder to do again i guess
GamerNebulae 23 Jun 2014
I made an API for drawing bars on monitors... If you want it, grab it here on pastebin. Instructions on how to use:
Now, let's go over the variables:
ID: Needs to be a string, can be called whatever you want. DO NOT NAME DIFFERENT BARS THE SAME ID!
Title: Needs to be a string.
yTitle: Height of the title in numbers. DO NOT GIVE TWO BARS THE SAME Y VALUE!
titleColor: Needs to be a string and needs to be a color in the color-spectrum of CC.
value: For this, use <peripheralName>.getEnergyStored(). You can also use the peripheral.call() function.
maximum. For this, use <peripheralName>.getMaxEnergyStored(). You can also use the peripheral.call() function.
yBar: Height of the bar in numbers. DO NOT GIVE TWO BARS THE SAME Y VALUE!
barColor: Needs to be a string and needs to be a color in the color-spectrum of CC.
os.loadAPI("/<program title>") --#Depends on you program title and where you stored it <program title>.mCreateProgressBar("ID", "title", yTitle, "titleColor", value, maximum, yBar, barColor)
Now, let's go over the variables:
ID: Needs to be a string, can be called whatever you want. DO NOT NAME DIFFERENT BARS THE SAME ID!
Title: Needs to be a string.
yTitle: Height of the title in numbers. DO NOT GIVE TWO BARS THE SAME Y VALUE!
titleColor: Needs to be a string and needs to be a color in the color-spectrum of CC.
value: For this, use <peripheralName>.getEnergyStored(). You can also use the peripheral.call() function.
maximum. For this, use <peripheralName>.getMaxEnergyStored(). You can also use the peripheral.call() function.
yBar: Height of the bar in numbers. DO NOT GIVE TWO BARS THE SAME Y VALUE!
barColor: Needs to be a string and needs to be a color in the color-spectrum of CC.
cptdeath58 23 Jun 2014
You could make a percentile of how much energy is stored to max energy allowed.
But if you use his API ^
Edited by cptdeath58, 23 June 2014 - 11:38 PM.
But if you use his API ^
cell = peripheral.wrap("Side") local refreshRate = 5 -- change to any number while true do energy = cell.getEnergyStored max = cell.getMaxEnergyStored <program>.mCreateProgressBar("ID","Energy Stored", 1, "red", energy, max, 2, colors.blue ) sleep(refreshRate) endIf that is how that works.
Edited by cptdeath58, 23 June 2014 - 11:38 PM.
starwind 23 Jun 2014
ahh thank you!
But how do i get all 8 or something cells to show as one bar? just hook up modem to all 8 and drag cable or wireless up to a computer with monitors attached?
But how do i get all 8 or something cells to show as one bar? just hook up modem to all 8 and drag cable or wireless up to a computer with monitors attached?
Lyqyd 24 Jun 2014
Yep, wired modems should allow you to deal with all of them. You'll still have to write the code to handle getting and presenting all of the data, of course.