• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Syntax/variable issue.

Warmonger

Well-known member
Grrrr, this is where an actual example of scripting in the docs would be awesome.

I have an issue with a unit, that takes a child. The child then takes an option that needs to modify the parent units stat with an eval script.

here's what I have currently: (Shields is a text field)

if (parent.unit.stat[Shields] = "1") then
parent.stat[Shields] = "1/2"
endif

I've tried parent.stat, unit.parent, parent.unit they all say undeclared variable! What is the correct sytax here?!?!?!
 
Try root.stat[] or possibly uplevel.stat[]...I thought it should be root but when trying for something effecting the top level unit I was pointed to uplevel...
 
I was questioning if those would work, as it is effectively like this:

Squad.Ship.Leader.Option

And the option needs to change the ship level of the context.
 
At 01:48 PM 6/3/2005 -0400, you wrote:

>Grrrr, this is where an actual example of scripting in the docs would be
>awesome.
>
>I have an issue with a unit, that takes a child. The child then takes an
>option that needs to modify the parent units stat with an eval script.
>
>here's what I have currently: (Shields is a text field)
>
>if (parent.unit.stat[Shields] = "1") then
>parent.stat[Shields] = "1/2"
>endif
>
>I've tried parent.stat, unit.parent, parent.unit they all say undeclared
>variable! What is the correct sytax here?!?!?!


I think the problem is that you can't use = with a string variable - you
have to use the 'compare' intrinsic. Try this:


var result as number
result = compare(parent.unit.stat[Shields], "1")
if (result = 0) then
parent.stat[Shields] = "1/2"
endif
 
Beautiful! Thanks much! Didn't even know about the compare, as everything else I have worked with has all been numeric stats.
 
Back
Top