Page 1 of 1

Units on Fire - Modding Question

Posted: 14 Aug 2008, 07:59
by REVENGE
I took the lateset units_on_fire luarule from CA, and now I'm trying to mod it so that instead of looking at the 'weapontype', it'll try and find the keyword "Flame" in the weapon category 'name' instead.

My (non-working) code:

Code: Select all

local flamerWeaponDefs = {}
for i=1,#WeaponDefs do
  if (WeaponDefs[i].name:find("Flame")) then --// == flamethrower
     --// 0.5 cus we want to differ trees an metal/tanks 
     --// (fireStarter-tag: 1.0->always flame trees, 2.0->always flame units/buildings too)
    flamerWeaponDefs[i]=WeaponDefs[i].fireStarter
  end
end
vs.
CA Original Code:

Code: Select all

local flamerWeaponDefs = {}
for i=1,#WeaponDefs do
  if (WeaponDefs[i].type=="Flame") then --// == flamethrower
     --// 0.5 cus we want to differ trees an metal/tanks 
     --// (fireStarter-tag: 1.0->always flame trees, 2.0->always flame units/buildings too)
    flamerWeaponDefs[i]=WeaponDefs[i].fireStarter
  end
end

Re: Units on Fire - Modding Question

Posted: 14 Aug 2008, 19:54
by REVENGE
My issue has been resolved by changing to the following:

Code: Select all

if (WeaponDefs[i].name:find("flame")) then --// == flamethrower
That, and I believe my search pattern was just wrong. :oops:

Re: Units on Fire - Modding Question

Posted: 14 Aug 2008, 20:05
by REVENGE
Actually, my search pattern was fine.

For the weapondefs table,

'name' refers to the [weaponname] in the tdf file
'description' refers to the "name" tag in the tdf file.

So nothing really means what it seems to mean... :evil: