Page 1 of 1

Very Strange Add-on Conflict

Posted: Thu Apr 02, 2020 8:48 pm
by nsrr
While helping Mr. Frog debug a particular compatibility issue with Hiveminder, I discovered that any add-on with the line:

Code: Select all

local NPC = require "mod.class.NPC"
outside of a talent or other function will cause temporary effects from add-ons with a higher to weight to produce an error along the lines of:

Code: Select all

Lua Error: /engine/interface/GameTargeting.lua:137: /engine/interface/ActorTalents.lua:164: /engine/interface/ActorTemporaryEffects.lua:123: attempt to index local 'ed' (a nil value)
stack traceback:
/engine/interface/ActorTemporaryEffects.lua:123: in function 'setEffect'
/data-dreadnecromancer/damage_types.lua:68: in function 'projector'
/engine/interface/ActorProject.lua:259: in function 'project'
/data-dreadnecromancer/talents/spells/grave-raz.lua:42: in function </data-dreadnecromancer/talents/spells/grave-raz.lua:37>
[C]: in function 'xpcall'
/engine/interface/ActorTalents.lua:162: in function </engine/interface/ActorTalents.lua:151>
At [C]:-1
At [C]:-1 error
At /engine/interface/GameTargeting.lua:137 fct
At /engine/interface/GameTargeting.lua:143 targetMode
At /engine/interface/GameTargeting.lua:212
At /engine/KeyBind.lua:231
which essentially is saying that the effect can't be found, even though the higher weight add-on has definitely defined it.

If the add-on which adds the new effect has a lower weight than the add-on with the NPC require line, there is no issue. Additionally, if this line is moved inside of a function or other table, the issue is resolved. It doesn't seem that any other require will cause an issue like this, as many add-ons will define them at the beginning of a talent file, outside of any function or table.

It likely is not an issue outside of add-on conflicts, but it struck me as being bizarre enough to warrant documenting.

Re: Very Strange Add-on Conflict

Posted: Fri Apr 03, 2020 12:50 am
by HousePet
I think I've encountered this one before. You might be able to find some earlier posts about it somewhere.

Re: Very Strange Add-on Conflict

Posted: Fri Apr 03, 2020 2:09 am
by starsapphire
Can't find the real cause, but I have encountered similiar problem when writing another addon.
I will suggest this distrubs the load order of ToME4.

If you put

Code: Select all

require "mod.class.NPC"
inside some file, especially if you superload some core classes
since mod.class.Actor will load a lot of modules, it may disturb the designed load order of ToME4 (as it is demonstrated in tome/load.lua), and this may cause some problem.

We may need more exact information about where you put

Code: Select all

require "mod.class.NPC"
to get a more detailed troubleshoot.

Re: Very Strange Add-on Conflict

Posted: Fri Apr 03, 2020 4:52 pm
by nsrr
Specifically, the line was in a talent file, but outside of any talent or function. The file was placed in the add-on on the path addon/data/talents/gifts/filename and was loaded via a hook. I think this would define the local 'NPC' inside of the talent environment (though I honestly don't fully understand the implications of that myself).