I'm having an issue hooking into nested variables/properties (unsure of the correct terminology, so I'll use variable in this post).
I can hook normally into variables that are only nested inside once; example given:
if bp.Categories
and table.find(bp.Categories,'STRUCTURE')
and not table.find(bp.Categories,'HYDROCARBON')
and table.find(bp.Categories,'ENERGYPRODUCTION') then
if bp.Economy then
if bp.Economy.ProductionPerSecondEnergy then
bp.Economy.ProductionPerSecondEnergy = bp.Economy.ProductionPerSecondEnergy * energy
end
end
end
In this case, the variable I'm modifying ProductionPerSecondEnergy is nested inside Economy and this works perfectly.
However, if there is another nested layer; example given:
if bp.Categories
and table.find(bp.Categories,'STRUCTURE') then
if bp.Display then
if bp.Display.Tarmacs then
if bp.Display.Tarmacs.Width then
bp.Display.Tarmacs.Width = bp.Display.Tarmacs.Width * tarwmod
end
end
end
In this case, the variable I'm modifying Width is first nested under Tarmacs and then under Display. This code doesn't change the Width variable.
There is another example which is slightly different as well:
if bp.Categories
and table.find(bp.Categories,'STRUCTURE')
and table.find(bp.Categories,'ANTIMISSILE') then
if bp.Weapon then
if bp.Weapon.MaxRadius then
bp.Weapon.MaxRadius = bp.Weapon.MaxRadius * tmdefrange
end
end
end
In this case, the variable I'm modifying is MaxRadius, but in the original .bp file for the structure the bp.Weapon has a set of extra { } enclosing many of it's variables, which I believe is why I cannot access these with hooks.
If I try and change the variables inside bp.Weapons by creating a "mod_units.bp" and manually specifying the units and the variable it works - but this is a very time consuming process if I wish to go through every structure that has Tarmacs.Width and Tarmacs.Length.
Anyone with more experience have any ideas how to get these extra nested hooks working? I must be missing something obvious.
Regards, Hey Babe