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

energy cell peripheral

Started by manuwar, 18 June 2014 - 08:11 PM
manuwar #1
Posted 18 June 2014 - 10:11 PM
Hi everyone!!
I'm trying to setup a cc control for my energy, i've start to play with a computer and an energy cell, connected by modem and networking cable, now the thing i want to do is use the function getEnergyStored, i've tried with the code below but i return the error "parameter slot is missing" at line 31
I've got lot of problems with peripheral and i can't find a good tutorial if you know one can you link it please?


    local per =  peripheral.getNames()
    local cell = {}
	
    function findCell()
	  local index = 1
	  for k, v in pairs(per) do
	
	    if string.find(v, "energycell") then
		  cell[index] = v
	    end
	    index = index + 1
	  end
    end
	
    findCell()
	
    for i = 1, #cell do
	 print(cell[i])
    end
    print()
	
    local met = peripheral.getMethods(cell[1])
	
    for k, v  in pairs(met) do
    print(v)
    end
   
    local list = peripheral.call(cell[1], "getEnergyStored")

Thanks everybody!!
TheGreekMan2 #2
Posted 19 June 2014 - 02:19 AM
I may be wrong but I dont think energy cells can be used as a peripheral, however comparators emit redstone signal based on the amount of energy in the cell
additionally, you can use redstone to prevent the output/input of a cell
Dog #3
Posted 19 June 2014 - 02:57 AM
To add to TheGreekMan2's observations, I noticed that the code you posted only has 28 lines, yet your error code is on line 31. In the future, please post the entire code (or use Pastebin if it's long) - that'll go a long way toward helping others help you :)/>
Edited on 19 June 2014 - 12:58 AM
Lyqyd #4
Posted 19 June 2014 - 02:57 AM
They can be used as peripherals if one has OpenPeripheral installed, which he does, judging by the error message.

OP, try using "unknown" as the parameter:


local list = peripheral.call(cell[1], "getEnergyStored", "unknown")
Bomb Bloke #5
Posted 19 June 2014 - 03:28 AM
Failing that, you should be able to get more info on the expected parameters by calling OpenPeripheral's documentation from the prompt:

openp/docs <side> <methodname>
flaghacker #6
Posted 19 June 2014 - 05:43 AM
I have dealt with this issue before, and you need to specify witch side you want to check. So if your energy cell outputs to the left (relative to the energy cell, check the settings tab) you need to use cell.getEnergyStored("left")
manuwar #7
Posted 19 June 2014 - 09:41 AM
To add to TheGreekMan2's observations, I noticed that the code you posted only has 28 lines, yet your error code is on line 31. In the future, please post the entire code (or use Pastebin if it's long) - that'll go a long way toward helping others help you :)/>
you're right sorry… however that was the entire program, i've only erased some blank line.

They can be used as peripherals if one has OpenPeripheral installed, which he does, judging by the error message.

OP, try using "unknown" as the parameter:


local list = peripheral.call(cell[1], "getEnergyStored", "unknown")

Thanks this is working ;)/>

Failing that, you should be able to get more info on the expected parameters by calling OpenPeripheral's documentation from the prompt:

openp/docs <side> <methodname>

this can be very usefull, but i can make it work… does the peripheral need to be on a side of the computer or it can work even with a modem?


thanks a lot to everybody!!
Lyqyd #8
Posted 19 June 2014 - 03:32 PM
When you are seeking help, it is important not to change the code at all from the code you are using. If the problem was any more difficult to spot, the line numbers not matching up would have made it very difficult for us to help you. Just something to keep in mind for the future.

You can used networked peripherals with their documentation program, I believe. You'd just use the peripheral name ("monitor_0", for instance) instead of the side name.
manuwar #9
Posted 19 June 2014 - 03:47 PM
When you are seeking help, it is important not to change the code at all from the code you are using. If the problem was any more difficult to spot, the line numbers not matching up would have made it very difficult for us to help you. Just something to keep in mind for the future.

You can used networked peripherals with their documentation program, I believe. You'd just use the peripheral name ("monitor_0", for instance) instead of the side name.

I know my mistake :(/> i forgot to change the line error when i copied it…
And yes it work, :)/>

ps: i'm the only here that often hate lua? XD

thanks a lot