Need help creating a power action
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.
Code:
<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.
Code:
<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.
Code:
<!-- 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.