Closed Mista-Tea closed 9 years ago
Use registerCallback(event, callback) with event "postinit" https://github.com/wiremod/wire/blob/082a58dd176e7e51c8a7a2f0a079e48917ffb132/lua/entities/gmod_wire_expression2/core/init.lua#L131 Really bad global function name imo. Maybe an improvement could be switching to the gmod hook library.
@Mista-Tea you can simply use a regular Initialize
hook, which should run after all addons (as well as the gamemode) have loaded.
Besides, simply shoving a hook.Run
in autorun would not work half of the time. If you were unlucky and your addon is loaded after wiremod, wire would run its hook.Run
before your addon is even loaded. Therefore, placing the hook.Run
inside Initialize
is the solution, but then why do that when you can simply use Initialize
in the first place?
@thegrb93 that hook (and that hook system) is for E2 only. postinit is called whenever an E2 is spawned. It has nothing to do with when wiremod is loaded (or even the rest of wire at all).
@Divran, good point. Initialize
will do fine for the time being. Thanks for looking into this :)
This is a feature request unless there is currently a method to detect when Wire has been fully loaded.
It can be beneficial for external addons to know when Wire has completely finished loading. For example, the PlayerSay hook used by Expression 2 exposes all chat to clients, meaning private conversations can be snooped on. Currently there is no way to accurately know when the PlayerSay hook is added by E2. With this hook, an external addon would know exactly when it can override the hook. Developers wouldn't need to edit core files to modify functionality like this.
I believe it should be as easy as adding something like
hook.Run( "OnWireLoaded" )
at the end near https://github.com/wiremod/wire/blob/master/lua/autorun/wire_load.lua#L132. Letting it be called on the client could be helpful as well, instead of just surrounding it inif SERVER then
.Let me know your thoughts. The example I gave is very specific, but having this hook could be beneficial on a wider basis, and it's such a small and simple addition.