Need help overriding/hooking main module functions.. - Printable Version +- MMOMinion (https://www.mmominion.com) +-- Forum: FFXIVMinion (https://www.mmominion.com/forumdisplay.php?fid=87) +--- Forum: [DOWNLOADS] Addons, Lua Modules, Navigation Meshes.. (https://www.mmominion.com/forumdisplay.php?fid=90) +---- Forum: I Need Help with LUA coding! (https://www.mmominion.com/forumdisplay.php?fid=104) +---- Thread: Need help overriding/hooking main module functions.. (/showthread.php?tid=5344) Pages:
1
2
|
Need help overriding/hooking main module functions.. - Ace - 12-06-2013 So I'm trying to clean up my code to not require files to be replaced, and simply override the functions instead. I did some reading around the net and this is generally done by hooks as I understand it. I used the examples: http://www.wowwiki.com/HOWTO:_Hook_a_Function http://forums.wowace.com/showthread.php?p=140802 Seems pretty straightforward, hook the original to a local variable, override it with what you want. So I put my code into a folder, gave it a modules.def with code: Code: [Module] Inside of my assist_enhance.lua, I decided to start small by hooking the UI load and replacing it with my own, since it's the basis of the mod. So it starts with: Code: AssistEnhance = {} -- I don't know if I actually need this since I'm not really using any variables The problem I have is that my version never happens, the HandleInit still uses the built-in one in ffxiv.lua inside of the FFXIVMINION module. I've tried several version of this type of change but nothing happens. I'm still searching around but every place I've seen on the net points to this exact same methodology. Could somebody (mod maybe?) give me a push in the right direction here? RE: Need help overriding/hooking main module functions.. - Ace - 12-10-2013 Updated some stuff I tried today, my module actually loads now, realized I needed the RegisterEventHandlers. Problem is now is that mine just happens in conjunction with the original version (not instead of), so I basically have the main GUI with everything duplicated. RE: Need help overriding/hooking main module functions.. - Hairyogre - 12-11-2013 (12-10-2013, 09:11 PM)aceRage Wrote: Updated some stuff I tried today, my module actually loads now, realized I needed the RegisterEventHandlers. Problem is now is that mine just happens in conjunction with the original version (not instead of), so I basically have the main GUI with everything duplicated.Wish I had time to look for your code and actually work this. Looks like fun. Now that you have your module loading have you renamed your functions identically to the ones they're replacing? So it overrides the original code rather than running along side it? RE: Need help overriding/hooking main module functions.. - Ace - 12-11-2013 I've tried it identically, same function name but with my own module as prefix, and a couple other variations but it will only run alongside, not override. In some cases what I've been able to do is use the same function name, but only add the parts that I added, which is okay for some functions as I'm only tacking on functionality, not replacing it, but for others, it may cause some issues. I feel like there's some easy piece I'm missing for this to work. I went ahead and added what I have so far to the OP, with the parts that I haven't gotten to still commented out. RE: Need help overriding/hooking main module functions.. - Ace - 12-11-2013 I think this will be okay, as I am only adding elements/variables to the original GUI, not taking anything away. I actually had this thought last night that it might be this way. I notice in some cases though that d() doesn't work, so it's hard to determine what exactly is happening sometimes. Edit: Are there any places I can see the available GUI commands, or why one would require luck? RE: Need help overriding/hooking main module functions.. - Powder - 12-12-2013 http://mmominion.com/wiki-article-10.html they are identical to the gw2 ones. We should really add this to the FF wiki too :) RE: Need help overriding/hooking main module functions.. - Ace - 12-12-2013 What about the GUI_Delete's? I notice they are not listed as far as I can tell. I was able to get the GUI_DeleteGroup to work, but GUI_Delete seems to just delete the entire window (maybe by design). Wondering if there is one for just deleting a single control, possibly within a specified group? RE: Need help overriding/hooking main module functions.. - ferenz - 12-16-2013 There is no way to delete a single control currently. The workaround is to structure your groups accordingly, delete the entire group, and redraw your modified controls. It's not exactly efficient but we don't lose many cycles from it unless you're redrawing the controls every pulse, which is bad anyway unless you're writing a debug window or something similar. RE: Need help overriding/hooking main module functions.. - Ace - 12-17-2013 My goal was to replace a built-in combo box with one with slightly different text, one time when the module was loaded. I'm deleting the entire group now and just replacing it, which works, just slightly more code than needed and I wanted to slim it down if possible, but if it's not, I can deal. RE: Need help overriding/hooking main module functions.. - ferenz - 12-17-2013 Do you mean modifying the title of the combo box, or the string entries in the combo box? The former is a bit nasty, as you would not be able to use a hardcoded string value without potentially breaking the bot for other localizations. You could find the entry in the string table for it (something like strings[gCurrentLanguage].comboBoxTitle) and change it for just the language you want to support (strings["us"].comboBoxTitle = "newTitle"). The string table is in minionlib/languages.lua. If you make any changes to strings you definitely need to cycle through all languages to ensure that the bot doesn't crash after your changes for any language...that's one of the few areas left in the code that will crash the bot 100% if it can't find the proper string. The latter should be possible just by modifying the comboBoxVar_listitems with the new string you want. We do this all the time for markers, blacklist entries, etc. You should be able to find lots of examples where we refresh the combo box with new entries. Dunno if either of those is what you're looking for or not. |