PDA

View Full Version : Need help creating a power action



Diablobob
September 5th, 2019, 17:34
I am trying to create a new power action item in 5e sort of like the cast, damage, heal, or effect box... Just adding it to the list and trying to add a new feature for my players.

I am having issues with it displaying properly, and adding the new entry appropriately.

What I am seeing on expanding the power, is the previously existing power actions as well as the new power action layered directly ontop of the existing one... for ALL of the existing entries.

Code thus far: I will split it into chunks for easier breakdown.
Intent of the code: This chunk adds the menu item to the radial menu, while trying to preserve the original functionality.
<windowclass name="power_action" merge="join">
<script file="campaign/scripts/power_action.lua" />
<script>
function onInit()
if super.onInit then
super.onInit();
end
registerMenuItem(Interface.getString("power_menu_addtoken"), "portrait", 3, 1);
end

function onMenuSelection(selection, subselection)
if super.onMenuSelection then
super.onMenuSelection(selection, subselection);
end

if selection == 3 then
if subselection == 1 then
Debug.chat("testing script");
end
end
end
</script>What this chunk does: This chunk adds the menu item correctly to the radial menu. and when the #1 position is selected, what is expected to happen occurs. When any of the other options are selected, that is where thinks start going wrong. When any selection in any other position is selected, it adds ONLY a new custom entry, instead of the cast damage heal or effect entry.


Onto the next part.
Intent of the code: IN THE FUTURE - when the subselection 1 is chosen this is supposed to add the custom power action.

<sheetdata>
<hn name="order" />
<hs name="type">
<script>
function onValueChanged()

local node = window.getDatabaseNode();
local sType = DB.getValue(node, "type", "");

local bShowCustom= (sType == "custom");

custombutton.setVisible(bShowCustom);
customlabel.setVisible(bShowCustom);
customviewlabel.setVisible(bShowCustom);
typeview.setVisible(bShowCustom);
sizeviewlabel.setVisible(bShowCustom);
sizeview.setVisible(bShowCustom);
customdetail.setVisible(bShowCustom);
end
</script>
</hs>
What this chunk does: This chunk isn't even supposed to be active, however; it seams to be activated when any subselection OTHER than 1 is chosen. Additionally when adding an existing action like "cast" I get an error saying attempt to index 'custombutton' (a nil value)

NEXT CHUNK:
Intent of the code: The actual action displayed.

<!-- TOKEN -->
<button_poweraction name="custombutton">
<anchored position="insidetopleft" offset="2,2" />
<icon normal="button_custom_power" pressed="button_custom_power_down" />
<subroll>token</subroll>
</button_poweraction>
<label name="customlabel">
<anchored to="custombutton" position="righthigh" offset="5,0" />
<static textres="power_label_spell_custom_custom" />
</label>

<label name="typeviewlabel">
<anchored to="customlabel" position="righthigh" offset="20,0" />
<static textres="power_label_spell_custom_type" />
</label>
<string_poweractionview name="typeview">
<anchored to="typeviewlabel" position="righthigh" offset="10,0" width="70" />
<subroll>type</subroll>
</string_poweractionview>

<label name="sizeviewlabel">
<anchored to="typeview" position="righthigh" offset="20,0" />
<static textres="power_label_spell_custom_size" />
</label>
<string_poweractionview name="sizeview">
<anchored to="sizeviewlabel" position="righthigh" offset="10,0" width="70" />
<subroll>size</subroll>
</string_poweractionview>

<button_poweractioneditor name=""customdetail">
<editor>power_spell_custom_editor</editor>
</button_poweractioneditor>

</sheetdata>
</windowclass>
What this chunk does: For the parts that are displayed, it appears as though the spacing and such are correct.

Obviously it's not working correctly. And it seams there are several issues going on at once. I have tried several things to try to resolve the issues, however the only thing I have managed to do is cause more errors or to cause nothing to happen.

Any assistance would be greatly appreciated.

Diablobob
September 9th, 2019, 16:48
Ok... so I've not made any progress... this is very frustrating to me because I thought I had an understanding of what I needed to do... Any assistance at all would be greatly appreciated!!!

I also decided I should break everything up into smaller steps instead of the whole shebang together.

Step 1: I am trying to add an item to the sub-selection of a previously existing radial menu. I can add the item, however the actions the previously existing items in the sub-selection no longer work correctly.

Do I need to recreate the entire radial menu? entire sub-selections?

I will worry about the other problems when this gets resolved. So I only need to focus on one thing at a time.

Please! Any help would be highly appreciated!

Trenloe
September 9th, 2019, 16:55
Step 1: I am trying to add an item to the sub-selection of a previously existing radial menu. I can add the item, however the actions the previously existing items in the sub-selection no longer work correctly.

Do I need to recreate the entire radial menu? entire sub-selections?
You need to register the options (with registerMenuItem) and then you need to code the options in the handler (onMenuSelection).

See here: https://www.fantasygrounds.com/refdoc/windowinstance.xcp#registerMenuItem and here: https://www.fantasygrounds.com/refdoc/windowinstance.xcp#onMenuSelection

Diablobob
September 9th, 2019, 16:58
So I need to recapture the entire selection/sub selection?

Like if it's selection 3,3 that I want to add... but 3,1 and 3,2 already exist... I would need to provide the scribpt for 3,1 and 3,2 and 3,3? aka - the entire list of sub-selections?

Diablobob
September 9th, 2019, 17:00
It's not the registerMenuItem I am having issues with... it's the onMenuSelection...

onMenuSelection 3,3 works as intended... but 3,1 and 3,2 are broken

Trenloe
September 9th, 2019, 17:00
So I need to recapture the entire selection/sub selection?

Like if it's selection 3,3 that I want to add... but 3,1 and 3,2 already exist... I would need to provide the scribpt for 3,1 and 3,2 and 3,3? aka - the entire list of sub-selections?
If the code already exists for those original options (i.e. it's not a right-click option built into the FG control), and you're overriding the LUA script that the original windowclass used, then yes - you need to include all of the original code in the functions that you're overriding. There's no merging of LUA code - you need to either include all the code, or get into potentially complex super script implementations.