Whi is my damage_types.lua not overloading?

A place to post your add ons and ideas for them

Moderator: Moderator

Post Reply
Message
Author
jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Whi is my damage_types.lua not overloading?

#1 Post 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?
MADNESS rocks

nsrr
Uruivellas
Posts: 971
Joined: Mon Sep 21, 2015 8:45 pm
Location: Middle of Nowhere

Re: Whi is my damage_types.lua not overloading?

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

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: Whi is my damage_types.lua not overloading?

#3 Post by jenx »

tome-verbose.zip
(17.49 KiB) Downloaded 94 times
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
MADNESS rocks

nsrr
Uruivellas
Posts: 971
Joined: Mon Sep 21, 2015 8:45 pm
Location: Middle of Nowhere

Re: Whi is my damage_types.lua not overloading?

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

nsrr
Uruivellas
Posts: 971
Joined: Mon Sep 21, 2015 8:45 pm
Location: Middle of Nowhere

Re: Whi is my damage_types.lua not overloading?

#5 Post 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)

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: Whi is my damage_types.lua not overloading?

#6 Post 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 

MADNESS rocks

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: Whi is my damage_types.lua not overloading?

#7 Post 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?
Last edited by jenx on Sat Jun 24, 2017 2:11 am, edited 1 time in total.
MADNESS rocks

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

Re: Whi is my damage_types.lua not overloading?

#8 Post by HousePet »

its */data-verbose/* not */verbose-data/*
My feedback meter decays into coding. Give me feedback and I make mods.

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: Whi is my damage_types.lua not overloading?

#9 Post 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 :-)
Attachments
tome-verbose.zip
(17.78 KiB) Downloaded 87 times
tome-verbose.zip
(35.89 KiB) Downloaded 87 times
MADNESS rocks

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: Whi is my damage_types.lua not overloading?

#10 Post 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?)
Attachments
tome-verbose.zip
(18.08 KiB) Downloaded 91 times
MADNESS rocks

Post Reply