Initialization - KidneyThief/TinScript1.0 GitHub Wiki

CScriptContext

The integration of TinScript into a C++ solution is through the class CScriptContext. It is the entry point for all interaction, and requires the following steps:

  • Header files - all files requiring access to the tinscript.lib interface need to include:
    • #include "TinScript.h"
      #include "TinRegistration.h"
  • Create the context:
    • TinScript::CreateContext(<print handler>, <assert handler>, bool is_main_thread);
      • The print handler is simply a function to handle formatted printf() calls generated by TinScript, allowing you to direct the output as needed.
      • The assert handler is a bit more complicated, but serves the same purpose - how to handle asserts, such as syntax errors while parsing scripts. There is a default assert handler provided in cmdshell.h.
  • Update the context:
    • TinScript::UpdateContext(<current time msec>);
      • You'll need to update the context with the current (not delta) time in milliseconds. This allows the scheduler to process the commands it has queued up.
      • It's perfectly valid to call ::UpdateContext() with the same current time as the last update - this is the equivalent of the system being "paused".
  • Destroy the context:
    • TinScript::DestroyContext();
      • Once the application is finished, and you are shutting down the system, destroying the context will clean up all traces of Tinscript.
That's all there is to it. Once these three steps are in place, you're free to execute scripts, commands, bind classes, members and methods, and begin developing in a runtime environment. The FLTK Demo is a clear example of integrating TinScript into a simple framework application, and then scripting a very simple asteroids game.
⚠️ **GitHub.com Fallback** ⚠️