Nuke was an experimental modding platform for Source-engine games. However, I haven't had time to work on it, so I am publishing the scripting layer independent of the whole Nuke project in the hopes that it will be useful.
Nuke's scripting layer uses a powerful abstraction over coroutines to create a non-blocking main thread & event system.
Scripts running in nuke are sandboxed; a barebones permissions scaffold is in the env tree but has not been completed.
Nuke is incomplete and will require polishing before you'll be able to integrate it into your own projects.
Call BaseUserdata<T>::build on a class inheriting from BaseUserdata<> to get started (the template parameter
is the child class, eg SampleClass : BaseUserdata<SampleClass>.) Class members are built by the ClassBuilder struct
in glue/ScriptBaseUserdata.h. The result from the build call should be put in the static nuke::glue::ClassMetadata Self; member.
ClassMetadata SampleClass::Self = build()
.with...<>()
.with...<>();Custom serializers can be added by following the format in glue/ScriptStack.h. Note that you may need to wrangle includes.
To run code within a nuke context, create a context with a classcollection containing all your classes (and ScriptEventHandle! don't forget ScriptEventHandle!!!), create an Isolate, and then create a Thread to run code under the isolate.
Don't run code directly in the isolate thread-- this hasn't been tested and wacky shenanigans may occur.
nuke::glue::ScriptContext ctx {
nuke::glue::ClassCollection ()
.with_class<detail::ScriptEventHandle>()
};
auto isolate = ctx.NewIsolate();
auto thread = ctx.NewThread( isolate->L )
/* todo: load code into the thread and run it! */Nuke is currently published under the LGPL license. It might be dual-licensed under MIT and LGPL in the future.