@Uveso
Thanks! Do you know how to deal with the error?
WARNING: Error running lua script: attempt to get as number a table value
stack traceback:
[C]: in function `DrawLine'
...me commander - forged alliance\maps\11\11_script.lua(31): in function <...me commander - forged alliance\maps\11\11_script.lua:8>
VECTOR3( {2684.5, 63.96, 489.5} ) is the position of BUFFAREA_1 and VECTOR3( {2682.5, 63.96, 514.5} )is the position of BUFFAREA_2
- Code: Select all
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
function OnPopulate()
ScenarioUtils.InitializeArmies()
ForkThread(DrawBoundaryLine)
end
function DrawBoundaryLine(self)
local location
local entities
local unitsA
local unitsB
local ArmyBrain
while true do
for k = 1, 3 do
location = ScenarioUtils.MarkerToPosition('BuffArea_' .. k)
entities = GetUnitsInRect( Rect(location[1]-11, location[3]-11, location[1]+11, location[3]+11) )
if entities then
unitsA = EntityCategoryFilterDown(categories.MOBILE, entities)
unitsB = EntityCategoryFilterDown(categories.HYDROCARBON + categories.MASSEXTRACTION, entities)
end
if unitsB then
-- check first if the trigger unit is still present
if unitsB[1] and not unitsB[1].Dead and not unitsB[1]:BeenDestroyed() then
ArmyBrain = unitsB[1]:GetAIBrain() -- unitsB[1] is the first unit inside the unitsB table
for _, instigator in unitsA do
if VDist3(instigator:GetPosition(), location) <= 8 then
if instigator:GetAIBrain()== ArmyBrain then
DrawLine( VECTOR3( {2684.5, 63.96, 489.5} ), VECTOR3( {2682.5, 63.96, 514.5} ), 'ff00ff00' )
end
end
end
end
end
end
WaitSeconds(5) -- waits 5 second. Can be reduced to 1 tick if needed
end
end