Page 1 of 1
Whi is my damage_types.lua not overloading?
Posted: Fri Jun 23, 2017 8:02 am
by jenx
I've written an addon that modifies damage_types.lua, and placed it in:
overload / data /
yet it is clearly not being loaded.
I've set overload = true in my init file.
Could the problem be embers? It has a damage_types.lua file (neither overload nor superload, it just sits in the folder - how does that work?)
embers is weight 10, my addon is weight 15.
edit: i've also tried superload and just dropping it in data. all to no avail...
Any suggestions?
Re: Whi is my damage_types.lua not overloading?
Posted: Fri Jun 23, 2017 11:46 am
by nsrr
Guess I should have adressed this more directly in the post about editing a talent, but anyway, the short answer is that you don't overload or superload data files. You just have to have your add on load a data file with the same name. If there is anything in your new file that was also in the original, then the original will be overwritten by your version when the file loads (assuming the weight is higher).
In this case you want a file named damage_types.lua, inside of which you will paste a copy of the function you want to change and then edit it to make the changes you want.
Edit:
Just looked at your other post again and I see you want to edit the default projector, which, if I understand correctly, is not modified by the damage_types file in Embers? In that case you will want to copy the default projector function from base ToME into your new file to make changes to it. Basically, anything new in the file, such as the damage types in Embers, will be 'appended' to the file, while anything that was already in the file will be overwritten.
Re: Whi is my damage_types.lua not overloading?
Posted: Fri Jun 23, 2017 12:08 pm
by jenx
nsrr wrote:Guess I should have adressed this more directly in the post about editing a talent, but anyway, the short answer is that you don't overload or superload data files. You just have to have your add on load a data file with the same name. If there is anything in your new file that was also in the original, then the original will be overwritten by your version when the file loads (assuming the weight is higher).
In this case you want a file named damage_types.lua, inside of which you will paste a copy of the function you want to change and then edit it to make the changes you want.
Edit:
Just looked at your other post again and I see you want to edit the default projector, which, if I understand correctly, is not modified by the damage_types file in Embers? In that case you will want to copy the default projector function from base ToME into your new file to make changes to it. Basically, anything new in the file, such as the damage types in Embers, will be 'appended' to the file, while anything that was already in the file will be overwritten.
So, following your lead, I created a new file damage_types.lua, placed it in /data/ and placed in it my copy of setDefaultProjector(function(src, x, y, type, dam, state).
Then I set the weighting of my init.lua to higher than embers. I set data = true as well.
here is the file, in case this helps you troubleshoot it.
I really appreacite your help btw - I would like to get this to work.
Unfortunately, it didn't work

it is still using the regular damage_types.lua
Re: Whi is my damage_types.lua not overloading?
Posted: Fri Jun 23, 2017 4:31 pm
by nsrr
I can't look at the file until later, but I suspect I know what the problem is. I forgot to mention that, unlike super loads and overloads, data files are not loaded automatically. You will need to use a hook to load it. Set hooks to true in your I init file, add a folder named hooks, and create a file in it called load. Look in another add on to see how to format the hook.... I don't k ow exactly how it goes off the top of my head.
Re: Whi is my damage_types.lua not overloading?
Posted: Sat Jun 24, 2017 12:22 am
by nsrr
Just took a look at the file you attached. I see a couple things that might be the issue.
First, 'hooks' is set to 'false' in your init file; should be set to 'true'.
Second, I believe that this:
Code: Select all
class:bindHook("ToME:load", function(self, data)
DamageType:loadDefinition("/data/damage_types.lua")
end)
should be this:
Code: Select all
class:bindHook("ToME:load", function(self, data)
DamageType:loadDefinition("/verbose-data/damage_types.lua")
end)
Re: Whi is my damage_types.lua not overloading?
Posted: Sat Jun 24, 2017 1:58 am
by jenx
I tried what you said and got this error:
Code: Select all
Lua Error: /engine/DamageType.lua:44: cannot open /verbose-data/damage_types.lua: Bad file descriptor
At [C]:-1
At [C]:-1 error
At /engine/DamageType.lua:44 loadDefinition
At /hooks/verbose/load.lua:5
At [string "return function(l, self, data) local ok=false..."]:1 triggerHook
At /mod/load.lua:265
At [C]:-1 require
At /engine/Module.lua:160 load
At /engine/Module.lua:1029 instanciate
At /engine/utils.lua:2243 showMainMenu
At /engine/init.lua:172
At [C]:-1 dofile
At /loader/init.lua:217
Re: Whi is my damage_types.lua not overloading?
Posted: Sat Jun 24, 2017 2:03 am
by jenx
aha - this works:
Code: Select all
class:bindHook("ToME:load", function(self, data)
DamageType:loadDefinition("/data-verbose/damage_types.lua")
end)
my version is finally being used, after days of trying !
however, it gives an error straight away
Code: Select all
##Use Talent Lua Error## T_ATTACK Actor: 21296 Coiougon
Lua Error: /engine/interface/ActorTalents.lua:322: /engine/interface/ActorTalents.lua:295: /engine/interface/ActorTalents.lua:162: /data-verbose/damage_types.lua:8: attempt to call global 'initState' (a nil value)
stack traceback:
/data-verbose/damage_types.lua:8: in function 'defaultProjector'
/data/damage_types.lua:703: in function 'projector'
/data/damage_types.lua:1831: in function 'projector'
/mod/class/interface/Combat.lua:600: in function 'attackTargetWith'
/mod/class/interface/Combat.lua:184: in function 'attackTarget'
/data/talents/misc/misc.lua:75: in function </data/talents/misc/misc.lua:54>
[C]: in function 'xpcall'
/engine/interface/ActorTalents.lua:160: in function </engine/interface/ActorTalents.lua:149>
At [C]:-1
At [C]:-1 error
At /engine/interface/ActorTalents.lua:322 useTalent
At /mod/class/interface/Combat.lua:37 attack
At /engine/interface/ActorLife.lua:42 check
At [string "return function(self, x, y, what, ...) local ..."]:1 checkAllEntities
At /engine/Actor.lua:209 move
At /mod/class/Actor.lua:1317 move
At /mod/class/Player.lua:310 moveDir
At /mod/class/Game.lua:1894
At /engine/KeyBind.lua:230
initState is set in the regular damage_types.lua. I thought my loading would replace just the one function in damage_types, so why does this error happen?
Re: Whi is my damage_types.lua not overloading?
Posted: Sat Jun 24, 2017 2:04 am
by HousePet
its */data-verbose/* not */verbose-data/*
Re: Whi is my damage_types.lua not overloading?
Posted: Sat Jun 24, 2017 2:25 am
by jenx
HousePet wrote:its */data-verbose/* not */verbose-data/*
yep, got that. but see the error above...
UPDATE: Fixed. new version attached.
this is incompatible with LOTS of addons, so use at your own peril.
and all it does is modify the log

Re: Whi is my damage_types.lua not overloading?
Posted: Sat Jun 24, 2017 10:28 am
by jenx
Hmmm, now it is not working, but I don't think I changed it much at all.
Hachem_muche - can you see what's wrong with this please? (or any?)