Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Authoring Kit
Register FAQ Community Today's Posts Search

Notices

Reply
 
Thread Tools Display Modes
tkarn
Senior Member
 
Join Date: Jun 2007
Posts: 273

Old June 4th, 2014, 04:14 AM
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.
tkarn is offline   #1 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,213

Old June 4th, 2014, 07:30 AM
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.
Mathias is offline   #2 Reply With Quote
tkarn
Senior Member
 
Join Date: Jun 2007
Posts: 273

Old June 4th, 2014, 10:05 PM
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.
tkarn is offline   #3 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,213

Old June 5th, 2014, 06:49 AM
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)
Mathias is offline   #4 Reply With Quote
tkarn
Senior Member
 
Join Date: Jun 2007
Posts: 273

Old June 5th, 2014, 08:15 AM
OK.

You use a <it_tagpick> instead the <it_linkage> in the editor to determine the appropriate attribute?
tkarn is offline   #5 Reply With Quote
tkarn
Senior Member
 
Join Date: Jun 2007
Posts: 273

Old June 5th, 2014, 10:21 PM
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?
tkarn is offline   #6 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,213

Old June 6th, 2014, 07:12 AM
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.
Mathias is offline   #7 Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 08:21 PM.


Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.