Question about hooks
Hi,
lets assume I have this setup: AddOn1\file1.lua Lua Code:
AddOn2\file2.lua Lua Code:
So is it possible to access the created "frame" in file2.lua? |
Well, I'm not sure "hooks" are actually what you're asking about, and you certainly shouldn't create a function in one file in your addon and hook it in another. Hooks are for when you want to modify something in Blizzard code or another addon. If you're writing your own code, just write it the way you want it in the first place.
That said, to share something between files in your addon, just add it to your addon's private table; you've named it "ns" in your code: AddOn1\file1.lua Lua Code:
AddOn2\file2.lua Lua Code:
|
Quote:
AddOn1/file1.lua is all what this addon provides. |
Well, then this is where posting fake code examples gets you in trouble... if the actual code is set up like your example (local "frame" with no name, parent, or distinguishing features created inside a local function) then no, there's no way to access it from another file in another addon. However, it seems unlikely that a real addon would actually do that, so there's probably a way... but without seeing the actual code, there's no way to tell.
|
Quote:
Lua Code:
|
Because the function that creates the frame is local, only code within that .lua file can call CreateRollFrame().
Becasue the frame is not given a name, there is no way for code outside that .lua file to access the frame once it has been created unless the fames is parented to another frame that at some stage has been given a name. |
If that frame has some distinctive features you might be able to use EnumerateFrames() to get a pointer to it. For example this code catches all existent action buttons (from standard UI, Bartender4, ButtonForge, Dominos etc) and new ones will be added as well. Doesn't matter if they have a name or parent. (code extracted and adapted from SetMacroIcon lib)
Lua Code:
|
there is no clean way to access a local anonymous frame.
Code:
local hooked = {}; |
Scanning EnumerateFrames() can be very taxing on the system considering the default UI alone creates hundreds of frames. Trying to "hack" your way to get access to a local frame is customized to that specific frame. One way I can think of that would be much easier on the system is to use GetFramesRegisteredForEvent("CANCEL_LOOT_ROLL") and cross-check the taint record of any existing index.
Lua Code:
Hacking these frames isn't always going to be easy and it takes a lot of understanding with the environment they exist in. Not only the function creating a frame, but every function that takes the frame in as an argument is a possible point of entry to capture it. Scanning methods like the ones posted here are a last resort if you can't find a viable point of entry to get direct access. |
Quote:
|
Quote:
|
All times are GMT -6. The time now is 11:25 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI