Replacing getParadoxModifier
Moderator: Moderator
Replacing getParadoxModifier
Lua uses single pass compiling, right? So am I right in assuming that the only way to replace a helper function in the talent codebase (like 'getParadoxModifier') would be to superload the file it occurs in and then reload everything that would use it? Either way, is there anybody that can help talk me through the process?
Re: Replacing getParadoxModifier
Just superload the file it is in and replace it.
Everything else will use the new one.
Everything else will use the new one.
My feedback meter decays into coding. Give me feedback and I make mods.
Re: Replacing getParadoxModifier
Hmmm, nope, doesn't seem to be working.
A superload on \superload\data\talents\chronomancy\chronomancer.lua with a simple test edit doesn't spam the log with Tunes:
What am I missing?
A superload on \superload\data\talents\chronomancy\chronomancer.lua with a simple test edit doesn't spam the log with Tunes:
Code: Select all
local _M = loadPrevious(...)
tuneParadox = function(self, t, value)
print("[DUSKER] Tune")
local dox = self:getParadox() - (self.preferred_paradox or 300)
local fix = math.min( math.abs(dox), value )
if dox > 0 then
self:incParadox( -fix )
elseif dox < 0 then
self:incParadox( fix )
end
end
Re: Replacing getParadoxModifier
Well that is a completely different function/file to what you initially asked to do.
I'll have to get home before I can explain how to change that function.
I'll have to get home before I can explain how to change that function.
My feedback meter decays into coding. Give me feedback and I make mods.
Re: Replacing getParadoxModifier
Same file, and another case of a variable mapped to an anonymous function (just one that's easier to test calls).
I know what I'm doing when superloading an actual defined function; I can't see how to successfully replace an anonymous function, referenced by variable, without forcing a recompile pass of everything that could use the anonymous function.
I know what I'm doing when superloading an actual defined function; I can't see how to successfully replace an anonymous function, referenced by variable, without forcing a recompile pass of everything that could use the anonymous function.
Re: Replacing getParadoxModifier
Oh, I was thinking it was in actor.lua for some reason. Sleep deprivation most likely...
Also, Drat! The example I was thinking of pulling from one of my addons isn't there anymore.
There used to be a function in spells.lua which disabled other alchemy infusions, which we had to modify to add more infusion talents to it.
It was something like using getfenv(...) to load the function and then edit it.
Try:
"getfenv(_M).tuneParadox ="
Instead of "tuneParadox ="
You might need to grap DarkGod for this. I haven't done lua code for about a year now.
Also, Drat! The example I was thinking of pulling from one of my addons isn't there anymore.
There used to be a function in spells.lua which disabled other alchemy infusions, which we had to modify to add more infusion talents to it.
It was something like using getfenv(...) to load the function and then edit it.
Try:
"getfenv(_M).tuneParadox ="
Instead of "tuneParadox ="
You might need to grap DarkGod for this. I haven't done lua code for about a year now.
My feedback meter decays into coding. Give me feedback and I make mods.
Re: Replacing getParadoxModifier
I could be wrong (quite probably), but I think you can just redefine it in a new data file. As in, don't use a superload or an overload, just load in a new file (such as \data\talents\talents.lua) and have that file contain the new definition. Look in Razakai's Marksman addon and open up data\talents\talents.lua and you will see where doWardenWeaponSwap has been redefined. This is a function that is initially defined in chronomancer.lua, I believe, and is used by several TW talents. The principle should be the same, I think.
Re: Replacing getParadoxModifier
You can redefine it, but that will only apply to any new talents you create after that definition.
My feedback meter decays into coding. Give me feedback and I make mods.
Re: Replacing getParadoxModifier
Indeed you just need to redefine it in a new talent file that you load.
Notice how getParadoxModifier is *not* a local function, it's a global (well global to the talents environment) so any file making a new getParadoxModifier function will override the old one correctly.
To access the main talents env form your addon you can just use Talents.main_env. So your new talent file would look like:
Notice how getParadoxModifier is *not* a local function, it's a global (well global to the talents environment) so any file making a new getParadoxModifier function will override the old one correctly.
To access the main talents env form your addon you can just use Talents.main_env. So your new talent file would look like:
Code: Select all
Talents.main_env.getParadoxModifier = function(self) ...... end
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning

Re: Replacing getParadoxModifier
Thank you, blessed Darkgod! I'd already noted that the variable wasn't locally scoped, and had tried:darkgod wrote:just use Talents.main_env.
Code: Select all
Talents.getParadoxModifier = myAddonVersion
--as well as
_G.getParadoxModifier = myAddonVersion