Hi guys I wonder how i can return 2 values and assign them to a 2 varuables on a new function.
How I can do this?
4 replies to this topic
#1
Posted 07 January 2014 - 03:33 PM
#2
Posted 07 January 2014 - 03:39 PM
This is a pretty basic Lua question. Have you tried using the documentation? You just use multiple comma-separated values in your function's return statement:
return "one", 2, true
#3
Posted 07 January 2014 - 03:52 PM
Lyqyd, on 07 January 2014 - 03:39 PM, said:
This is a pretty basic Lua question. Have you tried using the documentation? You just use multiple comma-separated values in your function's return statement:
return "one", 2, true
Belive it or not, I did use google and such for it
And yes I have done that, I have changed the code on the read of the redstone energy cell, so I only need to change the statement on the for, and the rest It will get it automatic:
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 cell_total = cell.getMaxEnergyStored() return cell_stored, cell_total end
Now I'm returning the mj on the energy cells and the total that it can store, now what I was asking is how I can access to it
I have this function to it
function mj()
os.loadAPI("energia/read_mj")
-- want to put cell_stored into one variable and cell_total into another here
os.unloadAPI("energia/read_mj")
end
Thanks
Edited by camadas, 07 January 2014 - 03:53 PM.
#4
Posted 07 January 2014 - 04:02 PM
The same general way.
local first, second = func()
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











