ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Mon Jul 16, 2018 6:36 pm

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Fri Jun 23, 2017 8:02 am 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2263
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


Top
 Profile  
 
PostPosted: Fri Jun 23, 2017 11:46 am 
Offline
Uruivellas

Joined: Mon Sep 21, 2015 8:45 pm
Posts: 633
Location: Middle of Nowhere
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.


Top
 Profile  
 
PostPosted: Fri Jun 23, 2017 12:08 pm 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2263
Attachment:
tome-verbose.zip [17.49 KiB]
Downloaded 30 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


Top
 Profile  
 
PostPosted: Fri Jun 23, 2017 4:31 pm 
Offline
Uruivellas

Joined: Mon Sep 21, 2015 8:45 pm
Posts: 633
Location: Middle of Nowhere
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.


Top
 Profile  
 
PostPosted: Sat Jun 24, 2017 12:22 am 
Offline
Uruivellas

Joined: Mon Sep 21, 2015 8:45 pm
Posts: 633
Location: Middle of Nowhere
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:
class:bindHook("ToME:load", function(self, data)
      DamageType:loadDefinition("/data/damage_types.lua")
end)


should be this:
Code:
class:bindHook("ToME:load", function(self, data)
      DamageType:loadDefinition("/verbose-data/damage_types.lua")
end)


Top
 Profile  
 
PostPosted: Sat Jun 24, 2017 1:58 am 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2263
I tried what you said and got this error:

Code:
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


Top
 Profile  
 
PostPosted: Sat Jun 24, 2017 2:03 am 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2263
aha - this works:

Code:
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:
##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?

_________________
MADNESS rocks


Last edited by jenx on Sat Jun 24, 2017 2:11 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sat Jun 24, 2017 2:04 am 
Offline
Perspiring Physicist

Joined: Sun Sep 09, 2012 7:43 am
Posts: 5720
its */data-verbose/* not */verbose-data/*

_________________
My feedback meter decays into coding. Give me feedback and I make mods.


Top
 Profile  
 
PostPosted: Sat Jun 24, 2017 2:25 am 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2263
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 29 times
tome-verbose.zip [35.89 KiB]
Downloaded 31 times

_________________
MADNESS rocks
Top
 Profile  
 
PostPosted: Sat Jun 24, 2017 10:28 am 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2263
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 27 times

_________________
MADNESS rocks
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group