Page 1 of 1

[1.5.5] lua errors with ActorLife.lua - help please....!

Posted: Sun Jul 16, 2017 4:51 am
by jenx
I have overwirtten ActorLife.lua in an addon I'm developing, with only minor changes, namely, adding some print functions. that's all.

But it now triggers on the world map endless lua errors:

Code: Select all

Lua Error: /mod/class/WorldNPC.lua:190: attempt to index field 'ActorLife' (a nil value)
	At [C]:-1 __index
	At /mod/class/WorldNPC.lua:190 die
	At /mod/class/WorldNPC.lua:141 attack
	At /mod/class/interface/ActorLife.lua:42 check
	At [string "return function(self, x, y, what, ...) local ..."]:1 checkAllEntities
	At /engine/interface/ActorAI.lua:64 aiCanPass
	At /engine/interface/ActorAI.lua:86 runAI
	At /mod/ai//worldnpcs.lua:85 doAI
	At /mod/class/WorldNPC.lua:155 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 

any idea why this is happening?

Re: [1.5.5] lua errors with ActorLife.lua - help please....!

Posted: Sun Jul 16, 2017 9:26 am
by St_ranger_er
Any chance that you use original function in your superloaded? if so, check that original function called correctly i.e. first argument in brackets should be "self".

example from wiki https://te4.org/wiki/Addons

Code: Select all

local _M = loadPrevious(...)
local base_levelup = _M.levelup

function _M:levelup() --<- no arguments
  -- Do stuff "before" loading the original file

  -- execute the original function
  local retval = base_levelup(self) --<- but self here as first argument

  -- Do stuff "after" loading the original file

  -- return whatever the original function would have returned
  return retval
end

return _M

Re: [1.5.5] lua errors with ActorLife.lua - help please....!

Posted: Sun Jul 16, 2017 10:56 am
by jenx
Thanks!