44 posts
Posted 14 June 2015 - 01:10 AM
I'm planning my base in modded smp, and I want my programs ready to go. I want to build a program that can tell me how much power I have in the main Ender IO capacitor bank, and that I can use to turn off and on certain banks of machines. How do I draw info from an ender io capacitor to a computer monitor, example: peripheral.getPower (This is probably a bad example, haven't done CC in a while, but it should be understandable). Thanks! BTW, if it helps I have extra peripherals, haven't ever messed around with that tho sadly, but I can figure it out.
7083 posts
Location
Tasmania (AU)
Posted 14 June 2015 - 02:16 AM
If you
wrap a monitor, then pretty much all the functions in the
term API become available to the wrapped monitor. Eg:
local mon = peripheral.wrap("top") -- Or where ever the monitor is attached.
mon.setCursorPos(4,5)
mon.write("whatever")
Some commands, such as "print" and the functions in the paintutils API, only work on the "current" terminal. You can select the current terminal by
redirecting to it:
local oldTerm = term.current() -- Record the identity of the original terminal.
local mon = peripheral.wrap("top")
term.redirect(mon) -- The monitor is now the current terminal.
print("Hello") -- Prints on the monitor.
term.redirect(oldTerm) -- Back to the original terminal.
print("World") -- Prints on the computer's own display.
44 posts
Posted 14 June 2015 - 05:43 AM
Yes, I know how to use monitors and regular computercraft peripherals like disk drives. I'm asking about the api and integration of ender io capacitor banks. That is all.
EDIT: ok, I see where I confused you. When I said I wanted to draw info from the capacitor to the monitor, I left out that I know how to do the monitor part. I just need the computer to be able to tell it the information, and all I need to know to get that is how to connect the capacitor to the computer. Also, it would help to know what code I can do to get the info I need (i.e. peripheral.getPower or something). Thanks, hope I cleared it up.
Edited on 14 June 2015 - 03:48 AM
81 posts
Posted 14 June 2015 - 06:41 AM
Never used that mod myself so can't help directly, but if you know the side of the peripheral you can do peripheral.get methods(side) which will give you a table of the function names, more than likely if such a function exists it would have a logical name which can be seen in that list just by reading it?
7083 posts
Location
Tasmania (AU)
Posted 14 June 2015 - 06:45 AM
Odds are your capacitor block, if it's supported as a peripheral, will be handled by OpenPeripheral. To see what functions that gives you access to, run its documentation script along with the name of the peripheral (as per the name you'd use to wrap it):
openp/docs <name>
For specific info on given functions, follow that up with:
openp/docs <name> <functionname>
See here for more general info on peripherals. You'll likely also need to read up on
tables, too, assuming you're not already familiar with them.
209 posts
Location
Denmark
Posted 14 June 2015 - 10:00 AM
a short program that puts energy stored on a monitor
local mon = peripheral.wrap(*put whatever side it is on/name if connected by modem*)
local bank = peripheral.wrap(*whatever side it is on/name if connected by modem*)
mon.clear()
while true do
local ener = bank.getEnergyStored()
mon.setCursorPos(1,1)
mon.clearLine()
mon.write("Energy Stored: "..ener)
sleep(1)
end
that there just shows the energy stored :)/>
feel free to ask for a more indepth program, as i have made a few of these, and atm working on another one, that can do a bit more, including a few buttons to switch between main display (just an overview of the different banks i have) and a more indepth detail about them
44 posts
Posted 14 June 2015 - 02:30 PM
Thanks!