So I just recently learned about SkookumScript, and it seems really cool. I was wondering, what are the steps involved in embedding Sk into another codebase? I’ve been building my own game/engine and I would like to use Sk as the scripting language within it, but I’m not sure which classes need to be instantiated, initialized, or derived to get the Sk system running.
I’d prefer to develop/compile scripts with the IDE, then call/run them within the engine. But I’m fine with just reading and compiling during runtime if that’s easier to get started.
Really I’d just like a rundown of what code needs to be in place to get things off the ground.
Hey @SethSR - welcome to the SkookumScript community!
There are a few past posts in the forum that also talk about hooking up SkookumScript to other engines:
Looking at how SkookumScript is connected to UE4 is a good start and it helps to see a working system. That being said, the SkookumScript UE4 plugin is more complex than you will need since it also has to interact with the UE4 visual scripting system Blueprints and UE4 itself is massive.
The main steps will be:
subclass SkRuntimeBase and supply your own custom overrides.
subclass SkRemoteRuntimeBase to have a live connection with the SkookumIDE and use its REPL, live editing and debugging
there are a number of initialization methods to start SkookumScript up - look in the SkookumScript UE4 plugin and see SkookumScriptRuntime.cpp, SkUERuntime.cpp and related files for examples.
call SkRuntimeBase::update() in an appropriate place in your game loop
there are a number of deinitialization methods to clean up SkookumScript after a level/mission if needed or once a project shuts down - also look in the SkookumScript UE4 plugin and see SkookumScriptRuntime.cpp, SkUERuntime.cpp and related files for examples.
The subclassed files are used to specify how to load files and communicate using TCP/IP. SkookumScript intentionally tries to focus just on gameplay - it doesn’t know about files, networks or even many aspects of memory. Most engines have very custom mechanisms to handle all of that so SkookumScript is designed to just hook into those existing mechanisms rather than supply its own competing ways of doing things.
This will get SkookumScript up and running - you should be able load up the core scripts, run the SkookumIDE and call native SkookumScript commands.
Next you will need to bind commands from your engine into SkookumScript. You can see some good examples in the Sk UE4 plugin such as SkVector3.cpp. You don’t need tons of commands connected before you can do some pretty interesting things.
Some recommendations to start:
simple math objects for positions, rotations, etc.
creating objects such as NPCs
This entire process isn’t especially well documented so feel free to ask more questions here and please post any discoveries or clarifications you file.