9 posts
Location
Strona (BI) - Italy
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!!
23 posts
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
1220 posts
Location
Earth orbit
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
8543 posts
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")
7083 posts
Location
Tasmania (AU)
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>
656 posts
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")
9 posts
Location
Strona (BI) - Italy
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!!
8543 posts
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.
9 posts
Location
Strona (BI) - Italy
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