Very Strange Add-on Conflict

Where bugs go to lie down and rest

Moderator: Moderator

Post Reply
Message
Author
nsrr
Sher'Tul
Posts: 1126
Joined: Mon Sep 21, 2015 8:45 pm
Location: Middle of Nowhere

Very Strange Add-on Conflict

#1 Post 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.

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Very Strange Add-on Conflict

#2 Post by HousePet »

I think I've encountered this one before. You might be able to find some earlier posts about it somewhere.
My feedback meter decays into coding. Give me feedback and I make mods.

starsapphire
Thalore
Posts: 132
Joined: Sat Sep 27, 2014 11:33 am
Location: Irkkk

Re: Very Strange Add-on Conflict

#3 Post 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.

nsrr
Sher'Tul
Posts: 1126
Joined: Mon Sep 21, 2015 8:45 pm
Location: Middle of Nowhere

Re: Very Strange Add-on Conflict

#4 Post 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).

Post Reply