PDA

View Full Version : Stumped on calling Global I thought method in control <script> handler



Varsuuk
July 27th, 2020, 22:49
I am getting this console error:


Runtime Notice: s'Calling onValueChanged() for HD'
Runtime Notice: s'1d6+'
Runtime Notice: nil
Runtime Notice: nil
Runtime Notice: nil
Runtime Notice: s'SAVING THROW='
Runtime Notice: #0
Script Error: [string "hd"]:1: attempt to call field 'savingThrow' (a nil value)


The to be called code was setup in the extensions.xml prior to the xml file which uses it (if that matters)
data_swwb_monster.lua


function hdType()
return "d6"
end


function savingThrow(sHD)

local nHD, sDice, _ = Parser.parseHDInfo(sHD)
-- ADD CODE TO CHECK IF < 1d6
return math.floor(19 - nHD)

end



The caller is a control I inherited from OSE work on MoreCore:
record_npc.xml


<string_column_half name="hd">
<script>
function onValueChanged()
local rActor = ActorManager.getActor("npc", window.getDatabaseNode());

Debug.console("Calling onValueChanged() for HD")
local sHD = DB.getValue(rActor.sCreatureNode..".hd", "")

if not sHD then
Debug.console("HD cannot be empty")
return
end

local num, dice, mod = Parser.parseHDInfo(sHD)
Debug.console(sHD)
Debug.console(num)
Debug.console(dice)
Debug.console(mod)

local nSavingThrow = DB.getValue(rActor.sCreatureNode..".saving_throw", nil, 0)
Debug.console("SAVING THROW=")
Debug.console(nSavingThrow)
Debug.console(Monster_SWWB.savingThrow(sHD))
end



Not at all seeing why "savingThrow" is nil. Ideas?

Varsuuk
July 28th, 2020, 01:01
Also - forgot extension.xml:


...
<!-- Campaign templates -->
<includefile source="campaign/template_npc.xml" />

<!-- Rulesets -->
<script name="Monster" file="scripts/rulesets/data_monster.lua" />
<script name="Monster_SWWB" file="scripts/rulesets/whitebox/data_swwb_monster.lua" />

<!-- Campaign overrides -->
<includefile source="campaign/record_char.xml" />
<includefile source="campaign/record_char_more__modded_morecore.xml" />
<includefile source="campaign/record_char_more.xml" />
...



Post dinner, still not seeing it. It has to be a face-palm, but still working on it.

Varsuuk
July 28th, 2020, 01:04
ARGGGGH - FACE-PALM...

white_box ... not whitebox.

My kingdom for more inherent error reporting :) and of course better eye-brain coordination.