Question about a problem with a script
Posted: 16 Jul 2012, 16:58
Hi,
I’ve got a problem with a script. Unfortunately my tries have failed.
The problem is:
To execute a chunk of code only if a unit belongs to a certain list by name or by object name.
-- if the condition is true
if IsSkirm(ud)==true then
-- the following code to be executed:
IsSkirm(ud) -- the function returns true if the unit is in the list
local function IsSkirm(ud1)
for i, v in pairs(unitArray) do
if (v==ud1.objectname) then
return true
end
end
return false
end
-- the list:
local unitArray = {
"CORCV",
"CORCOM",
"ARMCOM",
"ARMCK",
}
I’ve got a problem with a script. Unfortunately my tries have failed.
The problem is:
To execute a chunk of code only if a unit belongs to a certain list by name or by object name.
-- if the condition is true
if IsSkirm(ud)==true then
-- the following code to be executed:
IsSkirm(ud) -- the function returns true if the unit is in the list
local function IsSkirm(ud1)
for i, v in pairs(unitArray) do
if (v==ud1.objectname) then
return true
end
end
return false
end
-- the list:
local unitArray = {
"CORCV",
"CORCOM",
"ARMCOM",
"ARMCK",
}