@jip Thank you.
Latest posts made by HeyBabe
-
RE: Modding - hooking into bp.Display.Tarmacs.Width for example
@slicknixon
This is an amazing explanation, I'm very grateful! I just started 3 days ago and got lost pretty quickly. -
RE: Modding - hooking into bp.Display.Tarmacs.Width for example
I solved it, it seems when confronted with { internal variables } you have to loop through all the preceding level to find these inside, then you can just change them, like this:
if bp.Weapon then for k,v in bp.Weapon do if v.MaxRadius then v.MaxRadius = v.MaxRadius * artyrangemodexample
-
RE: Modding - hooking into bp.Display.Tarmacs.Width for example
Small correction, but this is important. I checked the Display.Tarmac.Width and Legth variables and, it is the exact same way that the Weapon.MaxRadius is enclosed in an extra pair of { }, so this is two examples of - not of a similar, but - exactly the same problem.
-
Modding - hooking into bp.Display.Tarmacs.Width for example
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