Log in

View Full Version : Targeting radial menu in ct effects throws exception



RosenMcStern
September 15th, 2025, 14:45
If you try to activate the right mouse button menu on the targeting menu of an effect in the combat tracker to use the options "Target all allies" and "Target all non-allies" you get a nice console error because of a nil reference.

The problem is in CoreRPG, file template_ct_entry_section.xml, lines 528 and 530. There is an acrobatic five-level indirection that is supposed to call the friendfoe control in the ct entry from the button object, but misses spectacularly and throws an NPE. Not-so-safe code. The problem appears also in D&D and the majority of rulesets that use CoreRPG.

Isn't there a Jira to report this stuff? This is quite technical.

Also, keeping chunks of code this big in the XML is not the greatest idea. This is the result you can expect in such a case. :)

LordEntrails
September 15th, 2025, 16:17
There is no public Jira.

There is nothing you can't put in Jira that you can't put here or in a technical support ticket; FGVTT Customer Support - Jira Service Management (https://fantasygroundsunity.atlassian.net/servicedesk/customer/portals)

Posting on the forums here you not only get the benefit of SmiteWorks employees reviewing your report, you also get the eyes of numerous community devs who can also take a look.

For reference, here is the entire 35 lines of code of the template:


<template name="button_ct_effect_targetadd">
<buttoncontrol name="targeting_add_button">
<anchored to="rightanchor" width="20" height="20">
<top />
<right anchor="left" relation="relative" offset="-5" />
</anchored>
<icon normal="button_targeting" pressed="button_targeting_down" />
<tooltip textres="ct_tooltip_effectdragtarget" />
<script>
function onInit()
registerMenuItem(Interface.getString("ct_menu_targeting"), "goto", 4);
registerMenuItem(Interface.getString("ct_menu_targetingfriend"), "factionfriend", 4, 3);
registerMenuItem(Interface.getString("ct_menu_targetingnonfriend"), "factionenemy", 4, 5);
end
function onMenuSelection(selection, subselection)
if selection == 4 then
if subselection == 3 then
EffectManager.setEffectFactionTargets(window.getDa tabaseNode(), window.windowlist.window.friendfoe.getValue());
elseif subselection == 5 then
EffectManager.setEffectFactionTargets(window.getDa tabaseNode(), window.windowlist.window.friendfoe.getValue(), true);
end
end
end
function onDragStart(button, x, y, draginfo)
local nodeWin = window.getDatabaseNode();
if not nodeWin then
return false;
end
draginfo.setType("effect_targeting");
draginfo.setIcon("drag_targeting");
draginfo.setShortcutData(window.getClass(), DB.getPath(nodeWin));
return true;
end
</script>
</buttoncontrol>
</template>

Moon Wizard
September 15th, 2025, 16:45
I just tried this in the 5E ruleset; and it was working just fine. Are you using any extensions?

Regards,
JPG

Trenloe
September 15th, 2025, 16:54
I can recreate the error in a 5E campaign - right click on the Targeting button in an Effect in the CT, then select Targeting -> <either option>

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=65432

RosenMcStern
September 15th, 2025, 17:15
No, no extension at all. This is very strange, it fails in my ruleset (where it could be a side effect of some tinkering) and in 5E and CoreRPG.

Steps to reproduce: drop an NPC on the ct, open the effects panel, click on the green + to create an effect. Right click on the targeting button of the effect, then select Targeting and one of the two options, friends or foes. Ka-boom.

Moon Wizard
September 16th, 2025, 04:57
Thanks; was looking at the wrong target button (creature level, not effect level). Will get a patch queued soon.

Regards,
JPG

RosenMcStern
September 16th, 2025, 07:24
Thanks. It is not a very useful feature, but having the console show up with an error gives a bad impression.

That other button, the one at creature entry level, works perfectly, instead. Although it is non-componentised. All the code is in the XML, with no template defined for the button. I inserted it successfully in the charsheet in my ruleset, but I had to copy/paste the code instead of inserting it as a component. It is a solid, tested element, it is a shame that it is not componentized.

Moon Wizard
September 16th, 2025, 17:20
I'm not sure what you are referring to as being not componentized; it is componentized under a template named "button_ct_effect_targetadd" that can is used in CoreRPG base CT effect and can be layered on top of either at the effect or template level.

Regards,
JPG

RosenMcStern
September 17th, 2025, 08:17
Yes, the button with the bug, the one in the effect subwindow, is componentized, it has a template. But the one that worked properly, the targeting button placed at creature level, is not componentized. Everything is hardcoded in the sheetdata section of the ct_section_targets window, in file ct_host_entry_section.xml. It works well but it is totally not reusable.

BTW, you fixed this in record time. When you do a hotfix, it's really hot!