I keep on running into an issue where some "on damage taken" callback is returning a number rather than a hash and thus causing all sorts of things to break horribly. I assume this is the fault of one or another of the mods I have installed.
Is there a reasonable way for me to track down which callback it is or am I stuck with: code-diving; and getting a savefile into that state and then using the debug tools to start disabling effects until I've isolated what's going on?
Identify the callback culprit?
Moderator: Moderator
Identify the callback culprit?
Last edited by visage on Wed May 03, 2017 3:45 am, edited 1 time in total.
Re: Identify the callback culprit?
Does it not give you a stack trace?
A little bit of a starters guide written by yours truly here.
Re: Identify the callback culprit?
Sure it does, but the callback has already returned its value.
Re: Identify the callback culprit?
To elaborate...
The traceback:
The code around line 477 in damage_types is:
So, one solution to my problem of identifying the culprit would be for there to be a line I could insert inside the for loop that would log an identifier for the callback.
The traceback:
Code: Select all
[LOG] #UID:16013:0#Shadow hits #fbd578#Raze Corona Gunner#LAST# for #aaaaaa#(17 to psi shield)#LAST# damage.
Lua Error: /data/damage_types.lua:477: attempt to index local 'ret' (a number value)
At [C]:-1 __index
At /data/damage_types.lua:477 defaultProjector
At /data/damage_types.lua:742 projector
At /data/damage_types.lua:1127 projector
At /engine/interface/ActorProject.lua:420 projectDoAct
At /engine/interface/ActorProject.lua:508 projectDoStop
At /engine/Projectile.lua:230 act
At /engine/GameEnergyBased.lua:129 tickLevel
At /engine/GameEnergyBased.lua:64 tick
At /engine/GameTurnBased.lua:51 tick
At /mod/class/Game.lua:1386
Code: Select all
if target.iterCallbacks then
for cb in target:iterCallbacks("callbackOnTakeDamage") do
local ret = cb(src, x, y, type, dam, state)
if ret then
if ret.dam then dam = ret.dam end
if ret.stopped then return ret.stopped end
end
end
end
Re: Identify the callback culprit?
Unless I'm misreading this, there's a bug in Forcefield:
If the callback is called while the talent isn't active, it returns the damage rather than a hash containing the damage. This causes line 477 in damage_types to blow up.
...and changing that line does in fact seem to resolve my issue.
Code: Select all
callbackOnTakeDamage = function(self, t, src, x, y, damtype, dam, tmp)
local ff = self:isTalentActive(t.id)
if not ff then return dam end
local total_dam = dam
local absorbable_dam = t.getResist(self,t) / 100 * total_dam
local guaranteed_dam = total_dam - absorbable_dam
return {dam=guaranteed_dam}
end,
...and changing that line does in fact seem to resolve my issue.