Log in

View Full Version : Error in extension call to [string "5E:scripts/manager_actor_5E.lua"]:204



SilentRuin
April 23rd, 2024, 04:46
Recently since last major release I've been having my players get this error

[ERROR] Handler error: [string "5E:scripts/manager_actor_5E.lua"]:204: attempt to index local 'sAbility' (a number value)

on a polymorphism extension call. Only after several hours of playing and if we exit game and come up it does not happen again.

Nowhere in the poly code does it call ActorManager5E.getAbilityBonus with a number.

It only calls it in 3 places:



rRoll.nTarget = 8 + ActorManager5E.getAbilityBonus(rSource, aPowerGroup.sSaveDCStat) + ActorManager5E.getAbilityBonus(rSource, "prf") + aPowerGroup.nSaveDCMod;


and



for k, v in pairs(DataCommon.skilldata) do
local sBestLabel = "";
local nBestMod = 0;
local nNPCBestMod = 0;
local nBonus = ActorManager5E.getAbilityBonus(rnodeNewCTEntryActo r, v.stat);


and



for k, v in pairs(DataCommon.ability_ltos) do
local nBonus = ActorManager5E.getAbilityBonus(rnodeNewCTEntryActo r, k);


None of these are numbers in the 2nd arg of getAbiliyBonus.

Moon Wizard
April 23rd, 2024, 07:16
If you do a global search for ActorManager5E.getAbilityBonus, you'll see that none of the built-in ruleset calls use numbers either.
Also, I haven't heard of this issue reported in standard 5E ruleset usage without extensions.

Regards,
JPG

rhagelstrom
April 23rd, 2024, 13:58
Recently since last major release I've been having my players get this error


rRoll.nTarget = 8 + ActorManager5E.getAbilityBonus(rSource, aPowerGroup.sSaveDCStat) + ActorManager5E.getAbilityBonus(rSource, "prf") + aPowerGroup.nSaveDCMod;



if aPowerGroup.sSaveDCStat is an array then it needs to be indexed

SilentRuin
April 23rd, 2024, 16:04
if aPowerGroup.sSaveDCStat is an array then it needs to be indexed

Was not aware it could be an array - thank you! I'll put something in and see if the issue goes away for me. Seems to only be for me as noone else has reported it and if I restart app it goes away.

Moon Wizard
April 23rd, 2024, 16:53
In the 5E code, it's only set in these lines of code (top two for aPowerGroup.sSaveDCState, bottom two for aPowerGroup.sStat). The default calls would not be setting to non-string type. Not sure where array reference idea came from...

aPowerGroup.sSaveDCStat = DB.getValue(nodePowerGroup, "savestat", "");
...
aPowerGroup.sSaveDCStat = aPowerGroup.sStat;
...
aPowerGroup.sStat = DB.getValue(nodePowerGroup, "stat", "");
...
aPowerGroup.sStat = sDesc:match("spellcasting ability is (%w+)") or "";
...

Regards,
JPG

SilentRuin
April 23rd, 2024, 17:03
Array comment was based on name prefix of a - and of course the crazy dual purpose of getPowerGroupRecord being able to return a aPowerGroup.data or aPowerGroup["level"] depending if nodePower argument is nil or not. Granted the latter is not going to be triggered in my calls but still - doing a dual purpose like this can cause confusion.

Right now not sure why the same code works but at some point can get "corrupted" by something - and I do use extensions. I just can't seem to duplicate the error (only seen since last major update) unless in a live game in this campaign for more than an hour and this PC tries to wild shape with polymorphism. Never seen again if we restart app for that session. Until I can duplicate it I'm just trying to guess by looking at the code. I'm not even sure its my code triggering the error.

Moon Wizard
April 23rd, 2024, 17:07
I'm not sure what you are saying.

* getPowerGroupRecord always returns a Lua table or Lua nil value. (aPowerGroup.data == aPowerGroup["data"]; and aPowerGroup.level == aPowerGroup["level"])
* Having functions return a nil value when data can't be found is very common in the code base.

Regards,
JPG

SilentRuin
April 23rd, 2024, 17:12
I'm not sure what you are saying.

* getPowerGroupRecord always returns a Lua table or Lua nil value. (aPowerGroup.data == aPowerGroup["data"]; and aPowerGroup.level == aPowerGroup["level"])
* Having functions return a nil value when data can't be found is very common in the code base.

Regards,
JPG

Sorry I should have put aPowerGroup[nLevel] = aSpells; - which is an array for a level being returned. You'd have to actually look at the PowerManager.getPowerGroupRecord code to see it. What I'm saying is true - I'm just stating it wrong (when I go by memory its unreliable)- its using that array as dual purpose. Unless I've completely lost it looking at code here.

SilentRuin
April 23rd, 2024, 17:22
My current theory is that something is calling PowerManager.getPowerGroupRecord (I do but not with nil arg) with the second arg nil then trying to use the result someplace with getAbilityBonus given the assumed non array result which turns into a number instead of string when referencing data since its an unexpected array coming back. But really I have no idea.

I'll have to wait till i can figure out how to duplicate it - which only seems to be when in a session doing lots of stuff for a while before triggering the polymorphism.

SilentRuin
April 23rd, 2024, 20:25
My solution for now is to guard all my calls mentioned on first page with

type(whatever) == "string"

Before I allow it to process. And if its not a string I'm going to do a printstack() to see what is causing this. If its my call even triggering the error call.