There are very few discussion threads in this forum, so I hope that I'm posting this in the right place.
What is the proper way to use superload when making an addon? So far I've prefaced the file that I've wanted to modify with 'local _M = loadPrevious(...)', put in the function that I want to change, and end the file with 'return _M'. That worked well enough for me in beta 37, but in beta 38 that only seems to work some of the time. And the time that I need it most is the time it doesn't work -- superloading the 'data' directory.
I've seen 'data' overloaded just fine, and even the separate 'data' folder definition work in various modules. But the former is absolute and should be avoided for compatibility purposes, and the latter I've only seen used when the module maker wanted to add new files.
So my big point of confusion is, how can I modify existing data folder files when I don't want to append to them, overwrite them, or add new files to the directory?
Superloading
Moderator: Moderator
Re: Superloading
I don't think there is a way. Encapsulating a function and redefining/editing a data entry are very different operations, at least in my understanding. Perhaps there is something more to it. Overwriting the file seems like the simplest solution, and while compatibility is a concern, any addons that modified the same data entry would probably be incompatible (or not fully-functional) anyway.
Sorry about all the parentheses (sometimes I like to clarify things).
Re: Superloading
Yeah superload is mostly for class files.
But for data files there is usualy a way. You can detect & alter the loading of an entities file list by hooking on "Entity:loadList" (works for both general & zone specific stuff). It allows you to add/alter/remove any entities craeted in the loaded file.
For birth things many addons are doing it already check it out, same with talents and other things.
If you are more preciwse I can give more precise examples
But for data files there is usualy a way. You can detect & alter the loading of an entities file list by hooking on "Entity:loadList" (works for both general & zone specific stuff). It allows you to add/alter/remove any entities craeted in the loaded file.
For birth things many addons are doing it already check it out, same with talents and other things.
If you are more preciwse I can give more precise examples

[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

-
- Thalore
- Posts: 148
- Joined: Fri Aug 19, 2011 5:06 pm
Re: Superloading
Thanks. The stuff that I want to do is pretty minor, so it was just a little frustrating to be unable to do anything about it.
For example, I don't want to automatically pick up alchemist gems (I've never played an alchemist, and as I understand it those gems are only useful for that class). Doing that requires two things: essentially adding 'auto_pickup = false' to the relevant part in gem.lua, and altering Player.lua so that the Transmogrification Chest doesn't pick them up either. I've successfully superloaded Player.lua (I might have done it improperly, but it does work), but I couldn't get the game to recognize my changes to gem.lua when I tried to superload it.
So for this example, how would I go about modifying gem.lua in a fashion that the game would recognize without resorting to overloading?
For example, I don't want to automatically pick up alchemist gems (I've never played an alchemist, and as I understand it those gems are only useful for that class). Doing that requires two things: essentially adding 'auto_pickup = false' to the relevant part in gem.lua, and altering Player.lua so that the Transmogrification Chest doesn't pick them up either. I've successfully superloaded Player.lua (I might have done it improperly, but it does work), but I couldn't get the game to recognize my changes to gem.lua when I tried to superload it.
So for this example, how would I go about modifying gem.lua in a fashion that the game would recognize without resorting to overloading?
Re: Superloading
Code: Select all
class:bindHook("Entity:loadList", function(self, data)
if data.file ~= "/data/general/objects/gem.lua" then return end
for i = 1, #res do
if res[i].rarity then
res[i].auto_pickup = false
end
end
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

-
- Thalore
- Posts: 148
- Joined: Fri Aug 19, 2011 5:06 pm
Re: Superloading
Thanks Darkgod! I did have to fool around with it a bit; I got it working with #data.res instead of #res, and as written it makes normal gems not auto pickup instead of alchemist gems. I might have done something wrong programatically, but it is working for me now.