I'm working on an addon with a lot of small changes to a large number of talents. Two questions:
1. Is there any way to see a revision history of individual functions/class definitions, etc. so that I can see if, say, the specific Fireflash talent definition (not just the fire.lua file) has been updated?
2. Is there a superload equivalent way to update only part of a talent definition, but leave the rest alone? In the case of Fireflash, I'd like to change only the "radius = function(...." part of the definition, but leave the rest alone, so that I don't need to rewrite that part of the addon if something else in the talent changes between game versions.
Questions about addon development
Moderator: Moderator
-
- Uruivellas
- Posts: 744
- Joined: Thu Nov 18, 2010 6:42 pm
Re: Questions about addon development
I die somethong like that in the constitution stamina addon, where i changed the stamina recover talent. So yes you can for the second part. Not sure about the first bot.
Re: Questions about addon development
It's a little cumbersome but (assuming you're trying to track svn HEAD):
You have to check the line numbers that start the diff chunks against your local version to see what function they're in. A two step deal, but that's what I do. You'll probably want to pipe the output through more or another pager. If you use a graphical svn client, I have no help to offer.
Code: Select all
svn log -r BASE:HEAD --diff [path]
-
- Uruivellas
- Posts: 744
- Joined: Thu Nov 18, 2010 6:42 pm
Re: Questions about addon development
Thanks for the replies. After some more digging, I've partially rewritten _M:newTalent in ActorTalents.lua to allow talents to be redefined multiple times. Superloading the old function, this merges (overwrites) new talent definitions on top of the old, greatly simplifying talent updates. Only changed fields (besides talent name and type) need to be included in the addon's overload or data definitions.
For example:
I think this functionality should be added to the engine, since it makes addon talent changes much easier, faster to develop (and run) and more robust with respect to changing game versions. I've only updated the definition for talents, but similar functionality for actors, objects, etc, could also be done. I will post the new function definition after I've tested it a bit more.
For example:
Code: Select all
Original talent def Update def Effective (running) def
newTalent{ newTalent{ newTalent{
name = "Fireflash", name = "Fireflash", name = "Fireflash",
type = {"spell/fire",3}, type = {"spell/fire",3}, type = {"spell/fire",3},
.... <original fields carried over>
range =7. ... range =7.
... <original fields carried over>
radius = <original radius>, radius = <new radius>, radius = <new radius>,
... ... <original fields carried over>
info = <original info>, info = <new info>, info = <new info>,
} } }
Re: Questions about addon development
Talent updates are already fairly easy if you use hooks in your addon. Put a load.lua file in the hooks subdirectory of your mod and add a "ToME:load" hook:Hachem_Muche wrote:Thanks for the replies. After some more digging, I've partially rewritten _M:newTalent in ActorTalents.lua to allow talents to be redefined multiple times. Superloading the old function, this merges (overwrites) new talent definitions on top of the old, greatly simplifying talent updates.
Code: Select all
require "engine.class"
require "engine.interface.ActorTalents"
class:bindHook("ToME:load", function (self, data)
ActorTalents:loadDefinition("/data-my-mod/path/to/talent-changer.lua")
end)
Code: Select all
local talent_to_change = Talents:getTalentFromId(Talents.T_TALENT_ID)
talent_to_change.value_to_change = 7
talent_to_change.function_to_change = function (actor, talent)
print "This message will show up in the log."
end
Changing items is even easier using the (undocumented, even on the wiki) "Entity:loadList" hook. You don't even need extra files for this one. Just put the changes directly in load.lua. The name of the file that's being loaded is in data.file and all the items created in that file are stored in the data.res table. Say you wanted to add a couple gold to the price of Prox's foot:
Code: Select all
require "engine.class"
class:bindHook("Entity:loadList", function (self, data)
if data.file == "/data/general/objects/boss-artifacts.lua" then
for _, item in ipairs(data.res) do
if item.name == "Prox's Lucky Halfling Foot" then item.cost = item.cost + 2 end
end
end
end)