PDA

View Full Version : What does a self-referential "source=" imply?



Varsuuk
July 18th, 2020, 04:27
I have seen this in a few places as I work on a MoreCore ext:



<!-- Frame Anchor point and Label -->
<string_useredit_bold name="combat_label" source="combat_label">
<anchored to="combatframe" />
<default>Combat</default>
<tooltip textres="label_editable_stats" />
</string_useredit_bold>


The stringfield instance is named "combat_label" and it says the data comes from "combat_label" - I thought you used source to indicate if it comes from somewhere OTHER than the same name in the XML? Is this just not needed or is it saying something that I am missing?

celestian
July 18th, 2020, 04:29
I have seen this in a few places as I work on a MoreCore ext:



<!-- Frame Anchor point and Label -->
<string_useredit_bold name="combat_label" source="combat_label">
<anchored to="combatframe" />
<default>Combat</default>
<tooltip textres="label_editable_stats" />
</string_useredit_bold>


The stringfield instance is named "combat_label" and it says the data comes from "combat_label" - I thought you used source to indicate if it comes from somewhere OTHER than the same name in the XML? Is this just not needed or is it saying something that I am missing?

Thats my general understanding. If you wanted to reference some other part of the db node then you would use source. I'm not sure what the above accomplishes.

damned
July 18th, 2020, 04:49
You are both correct.

Varsuuk
July 22nd, 2020, 07:33
Welp, I got bit lol cos I wasn't thinking right when was the error saying "aac" is nil

(paraphrased)


I was setting in onInit() some controls to make them disabled/invis. Called aac.armour.setEnabled(false) ... got the error. Yet, it MUST be in scope... aac_label (another control) worked!

Then finally realized ... name="aac.armour" source="aac.armour" issue. I didn't catch on right away since after reading this, I removed all the redundant "source="s so when saw name="aac.armour" it didn't stand out as much.

changing it to: <xxxx name="aac_armour" source="aac.armour"> ... took care of it ;) and of course aac_armour.setEnabled(false) did what I wanted.


The POINT of source is to let you refer to nested stuff like that and name it without the "." ;) ooops


Just a tip, if you are using controls from MoreCore with a "." in name that you will not be able to reference them in the way >I< tried - more experienced folks can tell us if there is another way to reference a dotted name where it works correctly.

Varsuuk
July 22nd, 2020, 15:49
Actually - my mistake, these were new fields added in Old_School_Essentials_MoreCore. Will alert him there.