Senior Member
Join Date: Jun 2007
Posts: 273
|
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 by tkarn; June 4th, 2014 at 04:34 AM. |
#1 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
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. |
#2 |
Senior Member
Join Date: Jun 2007
Posts: 273
|
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) 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. |
#3 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
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) |
#4 |
Senior Member
Join Date: Jun 2007
Posts: 273
|
OK.
You use a <it_tagpick> instead the <it_linkage> in the editor to determine the appropriate attribute? |
#5 |
Senior Member
Join Date: Jun 2007
Posts: 273
|
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> Code:
Attr = altthing.findchild[Attribute,text].field[attFinal].value What is wrong? |
#6 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
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 by Mathias; June 6th, 2014 at 08:39 AM. |
#7 |
|
|