PDA

View Full Version : Is there a way to apply User.getRulesetName() filter on a chunk of XML code?



SilentRuin
September 16th, 2020, 17:04
I have a generic extension that I wish to add a non generic piece for a specific ruleset - but if I try to just modify the windowclass with a merge statement I get an error in rulesets that don't support it. I know in lua code I can use



if User.getRulesetName() == "5E" then


Type of check to filter out doing things for rulesets that don't support things - but how do I do that in XML's where I'm grafting on logic into an XML file (that exists in all rulesets I support) which does not support the particular windowclass I'm trying to merge stuff into (only exists in certain rulesets)?

Moon Wizard
September 16th, 2020, 17:35
I'm not following exactly what you are trying to do. Simple examples are always best when sharing ideas and issues. I'm going to take a stab without knowing exactly what you are after.

There is a "ruleset" attribute you can add to top-level tags in extensions that will limit top-level XML tags to being processed in one specific ruleset. It does not work within assets, only at the top-level. (Similar to version tag.) This is a very simple option, and does not provide if...else, wildcard, or any other logic.

If that doesn't work for you, then you'll most likely need to handle dynamically in script code.

Regards,
JPG

SilentRuin
September 16th, 2020, 17:51
I'm not following exactly what you are trying to do. Simple examples are always best when sharing ideas and issues. I'm going to take a stab without knowing exactly what you are after.

There is a "ruleset" attribute you can add to top-level tags in extensions that will limit top-level XML tags to being processed in one specific ruleset. It does not work within assets, only at the top-level. (Similar to version tag.) This is a very simple option, and does not provide if...else, wildcard, or any other logic.

If that doesn't work for you, then you'll most likely need to handle dynamically in script code.

Regards,
JPG

That is in extension.xml and limits only what extension can be used if its the one I'm thinking of - that is not what I want. The example would be as follows in record_npc.xml (which exists in many rulesets). If I add this to my generic extension the merge will generate errors for versions of record_npc.xml that do not have "npc_combat" - which I think is only in "5E" - so I'd want to not have this do anything for those other rulesets. You mention a "ruleset" attribute and if I'm right that is something I use already as is for the entire extension - not what I want here.



<!-- Only present in 5E - support dropping weapons into NPC actions -->
<windowclass name="npc_combat" merge="join">
<sheetdata>
<list_npcactions name="actions" merge="join">
<script>
function onDrop(x, y, draginfo)
if draginfo.isType("shortcut") then
local sClass = draginfo.getShortcutData();
Debug.console("npc_combat drop: " .. tostring(sClass));
if sClass == "reference_weapon" or sClass == "reference_magicitem" or sClass == "reference_armor" or sClass == "item" then
local nodeSource = draginfo.getDatabaseNode();
MapParcelManager.addItemDrop(getDatabaseNode(), nodeSource);
return true;
end
end
end
</script>
</list_npcactions>
</sheetdata>
</windowclass>


Also, if you get a chance I'm desperate for an answer to this question:

https://www.fantasygrounds.com/forums/showthread.php?61722-How-to-set-user-radial-menu-option-on-token-in-map

Moon Wizard
September 16th, 2020, 17:53
Yeah, you would need to add the ruleset tag to the windowclass tag in your example. Then, it would only be parsed if the ruleset="5E".

Regards,
JPG

SilentRuin
September 16th, 2020, 17:58
Yeah, you would need to add the ruleset tag to the windowclass tag in your example. Then, it would only be parsed if the ruleset="5E".

Regards,
JPG

I'll give it a try assuming its literally ruleset="5E" - thanks.

SilentRuin
September 16th, 2020, 18:03
Yeah, you would need to add the ruleset tag to the windowclass tag in your example. Then, it would only be parsed if the ruleset="5E".

Regards,
JPG

Awesome - wish I could do something for you in turn! Superficial test seems to show it works great - time will tell for sure but THANKS!