Senior Member
Join Date: May 2012
Posts: 206
|
Hi there
I'm trying to set a procedure up that is passed a tag name in the string format which then tags the target (in this case unit.children). Running tests on it it works fine with the following: var tagRet as number tagRet = unit.assignstr("xxxxx.xxxx") As soon as I change it to: var tagRet as number tagRet = unit.children.assignstr("xxxxx.xxxx") I get an "Unexpected exception thrown during script evaluation" message. The file compiles with no issues and it is only when the procedure runs this is created. The scenario is for a Division unit that can be assigned different nationalities, each of these affects the units that can be taken and the options each unit has. Being able to use a procedure where the tag name is passed as a string would mean one procedure rather than lots of repeated lines of code that tag and change the unit name *edit* The format of set up within AB is the Division is a unit, it then has options that set the nationality. This script is being called from these options and is acting to change the name of the division, and tag child units of the division. Child units are controlled by live tags for each nationality, the units then have various options controlled by live tags for nationality Any ideas with the exception thing or does assignstr not work to a unit.children level? I checked the authoring kit pdf and it does not mention assignstr thanks Last edited by Harkan_again; December 8th, 2012 at 07:54 AM. |
#1 |
Senior Member
Lone Wolf Staff
Join Date: Dec 2008
Posts: 4,690
|
Hi Harkan,
Sorry for the late reply on this. I took a look into the code, and it appears that the "str" versions of the tag targets weren't implemented on the "children" transition, even though they're documented and it compiles properly - this is a bug in Army Builder that I'll log for fixing. There are often better ways of doing things than using the "str" versions of tag targets. Instead of using a string, could you do something like: Code:
if (tagis[nationality.nat1] <> 0) then perform unit.children.assign[nattags.nat1] elseif (tagis[nationality.nat2] <> 0) then perform unit.children.assign[nattags.nat2] (etc etc) |
#2 |
Senior Member
Join Date: May 2012
Posts: 206
|
That's the way I ended up going with it, was just hoping I could end up using a procedure passed a string to deal with it to create less lines of code as there are a lot of nationalities that the division can be
cheers as always |
#3 |
|
|