• 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

Coding a Prereq condition

tkarn

Well-known member
Coding a Prereq condition - Help needed

I have a spell component.

I have a link to the heroes Attributes (zattrib) and a minimum value of this Attribut (AttrWert). I want to check as a prereq if the hero has the required attribute value.

I tryed this:

@valid = 0
if (linkage[zattrib].field[attFinal].value >= field[AttrWert].value) then
@valid = 1
endif

but I got the following error: "Script reference is invalid under this circumstances"

If I use this for a eval script if works fine, but not for the prereq.

Any hints, what I do wrong?
 
Last edited:
What's the initial context of an Eval script?

Does that differ from the initial context of a prereq?

(The answer is in post 8 of this thread: http://forums.wolflair.com/showthread.php?t=21663)

Once you've figured out how the initial context differs, ask yourself how that affects where "field[AttrWert].value" is looking for a field's value.
 
Ah, thank you. I the problem. Now I tried:

Code:
var AWert as number
var Attr as number

if (@ispick <> 0) then
 AWert=altpick.field[AttrWert].value
 Attr = altpick.linkage[zattrib].field[attFinal].value
else
 AWert=altthing.field[AttrWert].value
 Attr = altthing.linkage[zattrib].field[attFinal].value
endif


 validif (Attr >= AWert)

But I have still problems with the linkage part.
When my spell is picked, the expression works correct. My spell is colored red if my atrribute value is not high enough.
But when the spell is not picked, my prereq error message is always there.
 
You may not be able to use linkages until something is a pick.

Personally, I've stopped using linkages when I code a game system - I use identity tags, and then use findchild to establish a focus to the target item:

Code:
var AWert as number
var Attr as number

if (@ispick <> 0) then
 AWert=altpick.field[AttrWert].value
 Attr = altpick.field[use a field on this component to store the value of the attribute once it's a pick].value
else
 AWert=altthing.field[AttrWert].value
 Attr = altthing.findchild[Attribute,altthing.tagids[AttrLink.?,"|"]].field[attFinal].value
endif


 validif (Attr >= AWert)
 
OK.

You use a <it_tagpick> instead the <it_linkage> in the editor to determine the appropriate attribute?
 
Thank you for your helpful answers.


So I changed the script to:

Code:
      <validate><![CDATA[
	    var AWert as number
        var Attr as number
        var text as string


  
        if (@ispick <> 0) then
           AWert= altpick.field[AAttrWert].value
           Attr = altpick.field[AttrWert].value
        else
		   text = altthing.tagids[AttrLink.?,"|"]
           AWert= altthing.field[AAttrWert].value
           Attr = altthing.findchild[Attribute,text].field[attFinal].value
        endif
        validif (Attr >= AWert)]]></validate>

but for the

Code:
           Attr = altthing.findchild[Attribute,text].field[attFinal].value

I get the error: Reference to an undeclared variable: 'altthing'

What is wrong?
 
Sorry about that mistake. findchild can only be called from a container context, but altthing is a thing context.

So, you want to use:
Code:
hero.findchild[Attribute,altthing.tagids[AttrLink.?,"|"]].field[attFinal].value
 
Last edited:
Back
Top