-
May 16th, 2021, 14:21 #1
attempt to call global getDatabaseNode (a nil value)
I have an extension that modifies campaign/scripts/spell.lua from 3.5E.
I have this windowclass merge:
Code:<windowclass name="spell_item" merge="join"> <script file="campaign/scripts/spell.lua" /> </windowclass>
Code:function onMenuSelection(selection, subselection) if selection == 6 and subselection == 7 then getDatabaseNode().delete(); elseif selection == 4 then SpellManager.parseSpell(getDatabaseNode()); -- bmos removing this line to keep script error away -- activatedetail.setValue(1); elseif selection == 3 then if subselection == 2 then createAction("cast"); activatedetail.setValue(1); elseif subselection == 3 then createAction("damage"); activatedetail.setValue(1); elseif subselection == 4 then createAction("heal"); activatedetail.setValue(1); elseif subselection == 5 then createAction("effect"); activatedetail.setValue(1); end end end
Code:Script execution error: [string "campaign/scripts/spell.lua"]:54: attempt to call global 'getDatabaseNode' (a nil value)
Why would this global function be missing?
Thanks for your time looking at this.bmos' extensions
he/them
-
May 16th, 2021, 14:26 #2
Did you try window.getDatabaseNode?
Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
May 16th, 2021, 14:44 #3
I don't have anywhere to change that to window.getDatabaseNode().
It's an error coming from a function that I haven't changed (onDisplayChanged in 3.5E's spell.lua)
I have tried adding that function to my spell.lua and commenting out everything in it (leaving the function empty) and it still has the same error!
Specifically this is my Upgrade NPC Actions extension and I'm testing this error by opening Demon, Nalfeshnee from an official Bestiary.
I have changed parseSpell to replace the spell entry (which means that the id-XXXXXX node changes) with one from a module when re-parsing the spell.
I get why getDatabaseNode() might return bad info, but I don't understand is why the global function would be missing completely.
I was hoping I could just empty the onDisplayChanged function since I don't care about its functionality, but for some reason that doesn't even fix the issue as my merged function isn't overriding the one in the ruleset.Last edited by bmos; May 16th, 2021 at 15:01.
bmos' extensions
he/them
-
May 16th, 2021, 15:02 #4
Not sure what you mean in this answer. Sometimes things do not set that function and you have to call it off window. You saying you don’t have any place to try that confused me. If your menu function is calling it now adding window in front of it is where you would “call it”. It may not work - but it’s worth a try was all I was saying. But if it worked before as you have it in same circumstances (nothing has changed) not sure what would cause that.
Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
May 16th, 2021, 15:12 #5
The script error is coming from spell.lua's line 54 which is in the function onDisplayChanged().
I have not touched onDisplayChanged() so I have nowhere to change getDatabaseNode() to window.getDatabaseNode().
When I did try to replace onDisplayChanged() in my merged copy of spell.lua, it ignored my changes.bmos' extensions
he/them
-
May 16th, 2021, 15:37 #6
Is it possible its being triggered by a place other than normal somehow? For sure in 5E onDisplayChanged() only present in power_item.lua and power_page.lua (which work fine). But if yours in spell.lua? is somehow triggered during the OnInit cycle it may not be defined yet or something (seen that in other functions). In which case, you just check for nil and skip the call till it works. In other words, its a false error from startup maybe? As I only deal in 5E maybe something I've never seen is going on for you also. Sorry, that's the best I know on advice for this sort of thing which I've had to workaround for other functions in the past (usually involving delete node timing issues).
Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
May 16th, 2021, 15:59 #7
To my knowledge you cannot merge windowclasses like that; you need to overwrite the full script and not just the part you edit (however, one could try super maybe for more compatibility.) (and I now did not read the full conversation here; sorry, if already discussed and mentioned )
My extensions for 3.5e and Pathfinder
Bug reports please here
-
May 16th, 2021, 16:05 #8
I assumed that was just a snippet. But if not - then Kelrugem is stating you need to do all the functions even if you don't use them (not sure that is a requirement but I always do it)...
For example...
Code:function onInit() if super and super.onInit then super.onInit(); end end function onSummaryChanged() if super and super.onSummaryChanged then super.onSummaryChanged(); end end function updateControl(sControl, bReadOnly, bForceHide) if super and super.updateControl then super.updateControl(sControl, bReadOnly, bForceHide); end end function update() if super and super.update then super.update(); end end function addTrait(sName, sDesc) if super and super.addTrait then super.addTrait(sName, sDesc); end end ...
Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
May 17th, 2021, 16:03 #9
Last edited by bmos; May 17th, 2021 at 18:01.
bmos' extensions
he/them
-
May 17th, 2021, 17:58 #10
Nope, same error.
I made my spell.lua file like this:
Code:-- -- Please see the LICENSE.md file included with this distribution for -- attribution and copyright information. -- local bShow = super.bShow or true; function setFilter(bFilter) bShow = bFilter; end function getFilter() return bShow; end function onInit() -- trigger original function if super and super.onInit then super.onInit() end end function update(bEditMode) if minisheet or super.minisheet then return; end -- trigger original function if super and super.update then super.update(bEditMode) end end function onDisplayChanged() if minisheet or super.minisheet then return; end -- trigger original function if super and super.onDisplayChanged then super.onDisplayChanged() end end function onHover(bOver) -- trigger original function if super and super.onHover then super.onHover(bOver) end end function createAction(sType) -- trigger original function if super and super.createAction then super.createAction(sType) end end function onMenuSelection(selection, subselection) if selection == 6 and subselection == 7 then getDatabaseNode().delete(); elseif selection == 4 then SpellManager.parseSpell(getDatabaseNode()); -- bmos removing this line to keep script error away -- activatedetail.setValue(1); elseif selection == 3 then if subselection == 2 then createAction("cast"); activatedetail.setValue(1); elseif subselection == 3 then createAction("damage"); activatedetail.setValue(1); elseif subselection == 4 then createAction("heal"); activatedetail.setValue(1); elseif subselection == 5 then createAction("effect"); activatedetail.setValue(1); end end end function toggleDetail() -- trigger original function if super and super.toggleDetail then super.toggleDetail() end end function getDescription() -- return output of original function if super and super.getDescription then return super.getDescription() end end function activatePower() -- trigger original function if super and super.activatePower then super.activatePower() end end function usePower() -- trigger original function if super and super.usePower then super.usePower() end end
Last edited by bmos; May 17th, 2021 at 18:02.
bmos' extensions
he/them
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks