Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Need help with using arithmetic's on a table?

Asked by
7_c 37
5 years ago

So I want to make this script that creates like 40 multiples of 3 and stores it in a table. How would I go about doing that? This is what I want to happen.

local number_Table = {3}

for i =1, 60 do
for i,v in ipairs(number_Table) do
table.insert(number_Table, + 3) 
end 
end
0
No problem! User#21908 42 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

first of all to help yourself out you should really work on indenting your code properly. Now we get on to your question. The easiest way to do what you are asking I think is to use an empty table like so:

local number_Table = {}
-- then do the for loop
for i = 1, 60 do
    table.insert(number_Table, i * 3) -- this way we can get 3 times every number up to sixty
end

0
thank you for answering my question, i was so confused. 7_c 37 — 5y
Ad

Answer this question