PDA

View Full Version : What exactly is self.target?



darrenan
November 20th, 2015, 18:01
I was working on a ruleset last night, and was porting some templates over from the 3.5e ruleset, when I hit a problem I couldn't figure out. Specifically, the action() function on the template used for the ability bonuses tries get the attribute name using "self.target[1]". In my ruleset, when I double click on the control I get an error that target is nil and can't figure out what the difference is that is causing this.

I walked up the template inheritence chain, checked the control references in the wiki, and scoured my lua book, but couldn't find 'target' anywhere. I was wondering if someone could briefly explain where this field comes from and what I can expect to find in it (how many elements, where do they come from, etc.)?

Thanks.

Trenloe
November 20th, 2015, 18:21
target[1] will more than likely be a tag in the XML for the control. See "Accessing XML parameters from script" here: https://www.fantasygrounds.com/modguide/scripting.xcp

Trenloe
November 20th, 2015, 18:29
For example, the template <template name="number_npc_ability"> includes the code ActionAbility.performRoll(draginfo, rActor, self.target[1]);

A control using this template will have a <target> section defining which piece of data/action to use as the target for the roll, for example in record_npc.xml:


<number_npc_ability name="strength">
<anchored width="25" height="20">
<top parent="columnanchor" anchor="bottom" relation="relative" offset="20" />
<left offset="97" />
</anchored>
<target>strength</target>
</number_npc_ability>

The strength ability check control has a target of strength that is used by the ActionAbility.performRoll function.

darrenan
November 20th, 2015, 18:52
Okay, I looked for such elements, but it was late and I probably just missed it. Thanks!