PDA

View Full Version : Setting sdource of local field - SOLVED



MadBeardMan
September 23rd, 2018, 18:12
Greetings all,

I've got a list of attacks all storing the various 'numbers' that are used to build up the final attack.

However when I'm trying to use 'onSourceUpdate' I'm not able to link the nodes local fields.


<source>
<name>skillDM</name>
<op>+</op>
</source>
<source>
<name>characteristicDM</name>
<op>+</op>
</source>
<script>
function onSourceUpdate(source)
local nValue = calculateSources();
setValue(nValue);
end
</script>

The XML is stored as such:


<id-00013>
<holder name="Greg" owner="true" />
<ammocost type="string">15</ammocost>
<attack type="number">2</attack>
<auto type="string">6</auto>
<characteristic type="string">dex_mod</characteristic>
<characteristicDM type="number">1</characteristicDM>
<cost type="string">1,000</cost>
<damage type="string">3d6</damage>
<heft type="number">0</heft>
<isidentified type="number">1</isidentified>
<magazine type="number">40</magazine>
<mass type="number">3</mass>
<name type="string">Advanced Combat Rifle</name>
<notes type="formattedtext">
<p>The ultimate evolution of the conventional firearm, advanced combat rifles are the weapon of choice for many military units. Standard equipment includes an electronic battlefield sight, incorporating both light amplification and IR abilities (see page 96), visual magnification up to 5x zoom, and a laser range finder which may also be used as a target painting device (reveals exact distance to target). The weapon is also gyroscopically stabilised during firing (as a gyroscopic stabiliser, already included in the stats).</p>
</notes>
<range type="string">Ranged (rifle)</range>
<ranged type="number">1</ranged>
<recoil type="number">0</recoil>
<recordtype type="number">9</recordtype>
<shortcut type="windowreference">
<class>item</class>
<recordname>....inventorylist.id-00024</recordname>
</shortcut>
<skill type="string">Gun Combat (Slug Rifle)</skill>
<skillDM type="number">2</skillDM>
<skilllink type="string">charsheet.id-00002.skilllist.id-00012</skilllink>
<subtype type="string">Slug Throwers</subtype>
<tl type="number">10</tl>
<type type="string">Weapon</type>
</id-00013>

The idea is if a skill is changed in value, or a characteristic then their DM's are updated, which then causes the attack value to be recalculated, however I can't seem to attach it to the local node fields.

Can anyone point out what I'm doing wrong?

Cheers,
MBM

MadBeardMan
September 23rd, 2018, 18:38
And sorted, me being daft.

The parent windowclass was a 'basic number' which doesn't allow it to be linked to other fields. Once I re-assigned the base class to 'number_linked' (and adjusted the frames for look and feel) it all worked a treat.

b00M!

Trenloe
September 23rd, 2018, 19:50
Yeah, "onSourceUpdate" is not a base FGI API event. Mentioned very recently here: https://www.fantasygrounds.com/forums/showthread.php?45670-How-to-determine-when-a-function-is-fired&p=406174&viewfull=1#post406174

MadBeardMan
September 23rd, 2018, 20:11
Yeah, "onSourceUpdate" is not a base FGI API event. Mentioned very recently here: https://www.fantasygrounds.com/forums/showthread.php?45670-How-to-determine-when-a-function-is-fired&p=406174&viewfull=1#post406174

Doesn't matter as the event fires b00M!

So works a treat once the linked class is used.

My fault though in the first place, haha, go silly me.

Trenloe
September 23rd, 2018, 20:15
Doesn't matter...
As long as you remember for next time. And the time after that. And... ;)