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

Lua tables help

Started by Mendoza, 04 April 2014 - 01:46 PM
Mendoza #1
Posted 04 April 2014 - 03:46 PM
I have a table created (ls = {}) with 100 spaces (ls[1] to ls[100]) with numbers inside and i want to obtain a number by adding up all the numbers without doing this: ls[1] + ls[2]…..

Thanks
Edited on 04 April 2014 - 01:46 PM
Anavrins #2
Posted 04 April 2014 - 03:58 PM
I guess something like this

local sums = 0
for i = 1, #ls do
    sums = sums + ls[i]
end
Mendoza #3
Posted 04 April 2014 - 07:34 PM
yes, thanks