PDA

View Full Version : Buttons no longer working...



Blackfoot
October 8th, 2023, 05:22
I had set up buttons for various equipment types.. armor.. weapons.. mirroring the 3.5 setup for my HERO System ruleset.. and they were working just fine.. now they give the following error..

[ERROR] Script execution error: [string "C:masterindex_buttons:button_custom3"]:8: attempt to call field 'init' (a nil value)

I'm not sure what I need to change to get this working again.
I get this same error with my NPC buttons as well.

Moon Wizard
October 8th, 2023, 06:07
I'm not sure what "button_custom3" is, since it looks like your own template. You'll have to see what it is inheriting from.

In the 3.5E ruleset, those templates look like this:


<template name="button_npc_byletter">
<button_masterindex_option_view>
<recordtype>npc</recordtype>
<recordview>byletter</recordview>
<recordpath>reference.npcdatabyletter</recordpath>
</button_masterindex_option_view>
</template>


Regards,
JPG

Blackfoot
October 8th, 2023, 06:41
button_custom <number>
is created by your code.. in masterindex_window.lua


function setupButtons()
local aIndexButtons = LibraryData.getIndexButtons(self.getRecordType());
if #aIndexButtons > 0 then
sub_buttons.setValue("masterindex_buttons", "");
for k,v in ipairs(aIndexButtons) do
sub_buttons.subwindow.createControl(v, "button_custom" .. k);
end
end

local aEditButtons = LibraryData.getEditButtons(self.getRecordType());
if #aEditButtons > 0 then
for k,v in ipairs(aEditButtons) do
local c = createControl(v, "button_edit" .. k);
if c then
c.setVisible(true);
table.insert(_tEditControls, c);
end
end
end
endA CoreRPG thing.

Moon Wizard
October 8th, 2023, 18:02
True, thanks for seeing that.

However, none of the button templates in the CoreRPG ruleset have an "init" function, including the default template for those buttons. So, you must be passing a named template via aGMListButtons in the data library script for your ruleset that is defining scripts which are making an "init" function call.

Here are the default templates for master index buttons from CoreRPG currently


<template name="button_masterindex_option">
<button_text_sm>
<anchored to="buttonanchor" width="80">
<top />
<left anchor="right" relation="relative" offset="5" />
</anchored>
</button_text_sm>
</template>
<template name="button_masterindex_option_view">
<button_masterindex_option>
<script>
....
</script>
</button_masterindex_option>
</template>


You should make sure that any templates that you are defining for master index buttons use one of those two templates. If view use the second one; otherwise, use the first and define onButtonPress/onDragStart events.

Regards,
JPG