MSUTeam / nested-tooltips

A framework that enables nested tooltips for the Battle Brothers game.
0 stars 0 forks source link

Dynamically generated text from target object of hyperlink #1

Open LordMidas opened 2 months ago

LordMidas commented 2 months ago

Sometimes you want to refer to a skill in a hyperlink to a nested tooltip e.g. [Stunned|Skill+stunned_effect]. However, this requires you to manually type the name of the skill as the text i.e. Stunned. If a mod or something changes the name of the actual stunned_effect to something like Stupefied then the hyperlink text doesn't know about this.

A proposal to make it possible to dynamically generate the text could be to add another flag for parseString such as [Obj/. Any hyperlinks starting from this inside parseString will be parsed with a special system:

[Obj/Name/scripts/skills/effects/stunned_effect|Skill+stunned_effect]
  1. The Obj/ starter tag tells the system that there is some script defined ahead.
  2. The next Name tells which field of the script we want.
  3. The next is the script path. This will be instantiated by the parser, and then instance.m[field] will be accessed and set as the text value where field is what's given in point 2.

Perhaps this can be made even simpler for frequently used items:

[|SkillName+stunned_effect]

We pass an empty string as text and instead of Skill we use SkillName because Name is probably the most commonly accessed field for this purpose.

This also brings me to a second point: Instead of using only filenames perhaps we should require entire script paths in the ExtraData. Because the curent system of only filename necessitates that two file names never match in the entire skills/ folder. Perhaps this is an unnecessary restriction and we can instead do: [Stunned|Skill+scripts/skills/effects/stunned_effect] and that's fine?

In this case the above problem can be solved as:

[|SkillName+scripts/skills/effects/stunned_effect]
Darxo commented 1 month ago

I like the variant of passing an empty string as the first argument, when we want the name to be fetched dynamically.

The other variants seem very unwieldy because of their length. I don't see how scripts/skills/ is needed in that path, when the Skill+ prefix already specifies where this script is roughly located.