Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   HL - Authoring Kit (http://forums.wolflair.com/forumdisplay.php?f=58)
-   -   Why Can't Foreach Loops be Used in Creation Scripts? (http://forums.wolflair.com/showthread.php?t=50613)

sincla September 6th, 2014 05:56 PM

Why Can't Foreach Loops be Used in Creation Scripts?
 
The following code:

Code:

<creation><![CDATA[
              var level as number
              foreach pick in hero where "ClassLevel.?"
                level += eachpick.tagvalue[ClassLevel.?]
                nexteach
              level += 1
              perform this.assignstr["ClassLevel." & level]
              ]]></creation>

gave me the following error:

Quote:

Syntax error in 'creation' script for Component 'Class' on line 3
--> Reference to undeclared variable: foreach

RavenX September 6th, 2014 07:32 PM

Code:

  foreach pick in hero from component where "the tags"
Look at your script, it's missing something...

sincla September 6th, 2014 08:17 PM

I added in the component:

Code:

foreach pick in hero from Class where "ClassLevel.?"
and I get the same error.

I didn't know the from Component was required. The wiki example doesn't have it:

Code:

foreach pick in hero where "group.tag"
            debug "id: " & eachpick.idstring
            nexteach

and I've succesfully executed foreach loops without it, even in the skeleton code there are examples such as:

Code:

foreach pick in hero where "system_tag.minion"
Was that not what you were getting at? Did I totally miss your point?

RavenX September 6th, 2014 08:30 PM

Usually specifying the component is important, otherwise you're searching through all the picks on the actor having the tag...

I'd say lookup foreach context in the kitwiki and read it. I'm not sure if you can use a foreach loop during a creation script, as you usually set field limitations and default user values with a creation script. I think creation scripts are for preadvancement phase characters. Once a character is locked for advancement those scripts are done running.

What are you trying to do specifically with your foreach loop? What are you trying to tell the compiler to do?

sincla September 6th, 2014 08:53 PM

1 Attachment(s)
Oh this is just one of my convoluted schemes to try and get sequential ordering of the class rows in the level column of the class level table like the d20 system. I was trying to make class picks not unique, give each one a separate level tag for the character level at which it was added, and display that in the level portal of the table dynamic.

To be completely clear about the ultimate goal, I've attached a screenshot. I hope it's helpful.

RavenX September 6th, 2014 11:32 PM

Table Dynamic Element in the wiki

look for:
orderfield=""

You don't need a foreach loop for that...

sincla September 7th, 2014 09:21 AM

Quote:

Originally Posted by RavenX (Post 192432)
Table Dynamic Element in the wiki

look for:
orderfield=""

You don't need a foreach loop for that...

Thank you. I feel chastened once again that it was something with a dedicated feature I was overlooking.

RavenX September 7th, 2014 02:59 PM

Quote:

Originally Posted by sincla (Post 192451)
Thank you. I feel chastened once again that it was something with a dedicated feature I was overlooking.

It took me awhile to figure out, its not so easy to figure out honestly. I've had to ask for help many times.

sincla September 8th, 2014 10:12 PM

Thanks, that makes me feel a little less of an idiot :).


All times are GMT -8. The time now is 12:18 PM.

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