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

Get information from another program

Started by camadas, 07 January 2014 - 11:59 AM
camadas #1
Posted 07 January 2014 - 12:59 PM
Hi guys, I'm in need of some help, so thats why I have come here for it :D/>.

I have created a program to get the information of the total energy that I have on my "Redstone Energy Cell".


local e_cell = "redstone_energy_cell_"

function read_energy_cell()
  cell_stored = 0
  for i=4,15 do
	cell = peripheral.wrap(e_cell..i)
	cell_stored = cell_stored + cell.getEnergyStored()
  end
  return cell_stored
end

Now I wanted to create a new program ( lets called the main program ) to get the information from the others that I have created, like the one above.

But when I try to get the info from it, I only get a bolean ( True ) and not the result of the return.


moni = peripheral.wrap("left)
moni.clear()
local mj_avai = os.loadAPI("energia/read_energy")
moni.write(mj_avai)

What can i do here to improved?
Lyqyd #2
Posted 07 January 2014 - 01:34 PM
os.loadAPI returns true or false based on whether the API loaded successfully or not. You should actually call the function after you load it.


os.loadAPI("energia/read_energy")
local mj_avail = read_energy.read_energy_cell()
camadas #3
Posted 07 January 2014 - 01:39 PM
os.loadAPI returns true or false based on whether the API loaded successfully or not. You should actually call the function after you load it.


os.loadAPI("energia/read_energy")
local mj_avail = read_energy.read_energy_cell()

Thanks for the help :D/>