this makes a key "create" with a value of the function pointer in the table "events" which is in the global environment.
So starting off with my existing good ju ju, that is, replacing the environment table with a custom one and having it forward to the 'real' environment table for things it can't find.
I then added another feature:
Whenever a script is run (file is loaded and function in that file is called), I first create a new table and set it into the global envronment with a key of "events"; then within this script any function that wants to be valid for an event call, needs to be designated as "events.eventName"
After loading the code into the new thread state, I lookup the events table, and grab the function from it with the given function name; i think call this function like normal.
This works great because each time I run a script the events table is dumped, as such the code doesn't hang around from call to call (allowing me to know if a function is not defined); and simply replacing the table for each call is a lot less ugly than 'scrubbing' the state for functions and deleting them; in addition to feeling 'cleaner' it also means I can have global non-event related functions (which I couldnt before, as they got scrubbed each time) which makes for easier programming and fewerer pitfalls.