Hermes
dziwki kola gramy w lola
Hi there .
I have extended my skills in LUA scripting with simple for loops.
Now my imagination goes further and now I have request for more advanced loop usage.
1. I have table.
And I want to get variables "name" and "value", but those variables must depend on "number".
Humm, let me give you example of script that might use those items from table.
Ofcourse I can use something like this:
But it's cleaner with table, right?
2. Second question is.. what's the main difference between loop "in pairs()" and "in ipairs()"?
Thanks in advance & regards,
Hermes
I have extended my skills in LUA scripting with simple for loops.
Now my imagination goes further and now I have request for more advanced loop usage.
1. I have table.
Code:
local table = {
{number = 1, name = "One", value = 11},
{number = 2, name = "Two", value = 22},
{number = 3, name = "Three", value = 33}
}
Humm, let me give you example of script that might use those items from table.
Code:
local table = {I have posted table up.}
function text()
--perhaps here should be loop for table
broadcastMessage(number .. ", " .. name .. " and " .. value)
return TRUE
end
Ofcourse I can use something like this:
Code:
if(number == 1) then
name = "One"
value = 11
elseif(number == 2) then
name = "Two"
value = 22
elseif(number == 3) then
name = "Three"
value = 33
end
2. Second question is.. what's the main difference between loop "in pairs()" and "in ipairs()"?
Thanks in advance & regards,
Hermes
Last edited: