Derpius / VisTrace

Garry's Mod binary module for tracing meshes at high speed on the CPU (and much more)
https://derpius.github.io/VisTrace
MIT License
27 stars 1 forks source link

[feature] Better Extension Loading #64

Closed Derpius closed 2 years ago

Derpius commented 2 years ago

Is your feature request related to a problem? Please describe. At the moment extensions need to be loaded in a specific order with vistrace to get initialised via the hook.

A more robust method is to add a vistrace.RegisterExtension function that adds init funcs to a list, then on init calls them. If already initialised it would call immediately.

This would also let you see what extensions are loaded

yogwoggf commented 2 years ago

How much detail should be in the extension register list? Name, author, init function or just name and init function? Should VisTrace provide a macro in the include/vistrace.h file? I was thinking something like this:

#include "vistrace.h"
#include "gmod module base"

LUA_FUNCTION(Init) {
    // do init stuff
}

GMOD_MODULE_OPEN() {
    VISTRACE_REGISTER_EXTENSION("My Extension", Init)
}
Derpius commented 2 years ago

Can simply be a macro that replaces GMOD_MODULE_OPEN

VISTRACE_EXTENSION_OPEN(My Extension) {} VISTRACE_EXTENSION_CLOSE() {}

I’m gonna be working on this now though so