This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
thedorkknight91's profile picture

Noob questions about capacitor banks

Started by thedorkknight91, 26 January 2017 - 04:28 AM
thedorkknight91 #1
Posted 26 January 2017 - 05:28 AM
so im guessing this is a pretty simple issue, as i am just learning code in general and computercraft. but i was trying to make a nifty monitering program that oversees all my bigreactors stuff, and i had some spare room, so i wanted to put in some info on the capacitor banks i use from enderio, but when i try to display something from them, i get "not enough arguments, first missing: direction"

the capacitor is on a modem, so im thinking its trying to figure outside i have the capacitor attached to the computer?? i dont know, like i said, im a newb.

this is the part you probably care about:


mon.setTextColor(colors.black)

mon.setCursorPos(30,10)

mon.write("Cap 1")

mon.setCursorPos(30,12)

mon.setTextColor(colors.white)

--mon.write("Battery is ")

mon.setTextColor(colors.red)

mon.write(cap1.getEnergyStored())

mon.setTextColor(colors.white)

--mon.write("% full.")

i followed the same outline for peripherials that i used with big reactors. so maybe thats the issue? i have a couple thoughts, but really no idea. here is the entirety of my program if you need a more in depth look, i would love some creative critism and tips, but i only ask if your gonna say something negitive, at least include something insightful and usefull.

sorry if my stuff is messy, damn newbies.


Edit by BB: Please use pastebin for giant swathes of code! http://pastebin.com/ZgYUBSsS
Edited on 26 January 2017 - 11:56 PM
Bomb Bloke #2
Posted 27 January 2017 - 01:06 AM
And the line throwing that error is….?
thedorkknight91 #3
Posted 27 January 2017 - 10:08 AM
And the line throwing that error is….?

mon.write(cap1.getEnergyStored())

my current guess is the paripheal im trying to call is being typed wrong…


that line of code is

local cap1 = peripheral.wrap("tile_enderio_blockcapacitorbank_name_0")
Bomb Bloke #4
Posted 27 January 2017 - 11:25 AM
my current guess is the paripheal im trying to call is being typed wrong…

Nah, if you failed to name a valid peripheral, then peripheral.wrap() would return nil. This'd lead to an "attempt to index nil" error when you tried to index into "cap1" to get functions such as "getEnergyStored".

Rather, the error is telling you that one of the functions you've successfully called doesn't like the way you've called it. We know that mon.write() doesn't want a "direction" passed to it, so that means cap1.getEnergyStored() does.

ComputerCraft doesn't directly support EnderIO capacitor banks as peripherals, which means that support is probably being added by a separate mod called OpenPeripherals. This script provides an easy way to read through the documentation for peripherals from that mod.
thedorkknight91 #5
Posted 27 January 2017 - 09:14 PM
I was wondering if it was something to do with direction, but i didnt know what to try since its attached via a modem. and i havent tried the opdoc, but it looks much nicer, and more informative that my getMethods script, so i will definitely utilize that.
thedorkknight91 #6
Posted 29 January 2017 - 05:25 AM
so im still having an issue


mon.write(cap1.getEnergyStored()) comes back saying not enough arguments, first missing: slot… what exactly am i missing, ive seen in other peoples program that this works, but atlas, utter confusion for me ;)/>
Edited on 29 January 2017 - 04:26 AM
blunty666 #7
Posted 29 January 2017 - 08:07 AM
This is an OpenPeripherals provided method, you'll need to pass the argument "unknown" as the first argument. (don't ask me why though!)


mon.write(cap1.getEnergyStored("unknown"))

Also note that this will only give you the energy stored in the single capacitor block the modem is connected to. If you have a multiblock capacitor you'll need to multiple the number you get by the number of capacitors in the mutliblock structure :)/>
thedorkknight91 #8
Posted 29 January 2017 - 12:27 PM
This is an OpenPeripherals provided method, you'll need to pass the argument "unknown" as the first argument. (don't ask me why though!)


mon.write(cap1.getEnergyStored("unknown"))

Also note that this will only give you the energy stored in the single capacitor block the modem is connected to. If you have a multiblock capacitor you'll need to multiple the number you get by the number of capacitors in the mutliblock structure :)/>

ahh, thank you. i will give that a try when i get onto games. i had a feeling i might have to do some math… well more math, i have three or four cap banks i want to tie all together for a total rf power bar below the monitor im working on. i actually figured out a couple of things i was wondering how id go about doing trying to figure this out, just from random poking around online.
thedorkknight91 #9
Posted 30 January 2017 - 04:19 AM
that was it!! i still feel like that was a lot of effort for a very simple issue. thanks for your time, i really do appreciate it!