Page 1 of 1

[svn2495] Yeek Wayist bug, but really deeper

Posted: Tue Jan 25, 2011 5:00 am
by yufra
Here is a Lua error captured from the Yeek Wayist. Looking through the psionic code a bit, I think there is a bug in the getGemLevel function. I created and tested a patch in Pastebin to fix the problem (run from game/modules/tome/data/talents/psionic). Basically it removes the redundant definitions of getGemLevel by defining it once in the main psionic.lua file, and also fixes the logical bug in getGemLevel where it fails if there is nothing in INVEN_PSIONIC_FOCUS.

Code: Select all

Lua Error: /data/talents/psionic/projection.lua:24: attempt to index local 'tk_item' (a nil value)
	At [C]:-1 
	At /data/talents/psionic/projection.lua:24 getGemLevel
	At /data/talents/psionic/projection.lua:311 do_chargedaura
	At /mod/class/Actor.lua:199 useEnergy
	At /mod/class/Actor.lua:380 
	At (tail call):-1 
	At (tail call):-1 
	At (tail call):-1 
	At (tail call):-1 
	At (tail call):-1 
	At /mod/class/NPC.lua:47 act
	At /engine/GameEnergyBased.lua:73 tick
	At /engine/GameTurnBased.lua:44 tick
	At /mod/class/Game.lua:622 
EDIT: Tested the patch, seems to work.

Re: [svn2495] Yeek Wayist bug, but really deeper

Posted: Tue Jan 25, 2011 8:27 pm
by yufra
Sus mentioned that some gems don't have material levels (artifact ones I believe). The getGemLevel function should be changed like this:

Code: Select all

Index: data/talents/psionic/psionic.lua
===================================================================
--- data/talents/psionic/psionic.lua	(revision 2506)
+++ data/talents/psionic/psionic.lua	(working copy)
@@ -121,7 +121,7 @@
 	if self:getInven("PSIONIC_FOCUS") then
 		local tk_item = self:getInven("PSIONIC_FOCUS")[1]
 		if tk_item and (tk_item.type == "gem") then
-			gem_level = tk_item.material_level
+			gem_level = tk_item.material_level or 0
 		end
 	end
 	return gem_level