Identify the callback culprit?

Where bugs go to lie down and rest

Moderator: Moderator

Post Reply
Message
Author
visage
Archmage
Posts: 345
Joined: Fri Jan 10, 2014 4:09 pm

Identify the callback culprit?

#1 Post by visage »

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?
Last edited by visage on Wed May 03, 2017 3:45 am, edited 1 time in total.

Micbran
Sher'Tul
Posts: 1154
Joined: Sun Jun 15, 2014 12:19 am
Location: Yeehaw, pardner

Re: Identify the callback culprit?

#2 Post by Micbran »

Does it not give you a stack trace?
A little bit of a starters guide written by yours truly here.

visage
Archmage
Posts: 345
Joined: Fri Jan 10, 2014 4:09 pm

Re: Identify the callback culprit?

#3 Post by visage »

Sure it does, but the callback has already returned its value.

visage
Archmage
Posts: 345
Joined: Fri Jan 10, 2014 4:09 pm

Re: Identify the callback culprit?

#4 Post by visage »

To elaborate...

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 
The code around line 477 in damage_types is:

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
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.

visage
Archmage
Posts: 345
Joined: Fri Jan 10, 2014 4:09 pm

Re: Identify the callback culprit?

#5 Post by visage »

Unless I'm misreading this, there's a bug in Forcefield:

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,
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.

Post Reply