Application and game scripting with SchemeBlitz3D Forums/Blitz3D Userlibs/Application and game scripting with Scheme
| One more step on the long road towards a decent Blitz3D scripting library...|
Scheme is one of the two main dialects of Lisp, and a popular language for scripting and educational use due to its light weight and simple rules. The TinyScheme implementation, by Dimitrios Souflis and Jonathan Shapiro, is an embeddable interpreter conforming to most of the R5RS standard, and mainly notable as the scripting language behind the GIMP (GNU Image Manipulation Program).
Click here to download the B3D wrapper.
Unlike certain other recent submissions, TinyScheme is fully interpreted rather than compiled to machine code, so while it doesn't offer the performance of native code, it does offer a much safer scripting environment to expose to your end-users.
Three examples are included with the library in an effort to demonstrate how everything works, as well as an archive with the modified source code (original manual/readme can be found in here). Once again, TinyScheme is capable of calling Blitz3D functions that have been added to the Scheme global environment, but you'll need FastPointer, by MikhailV, in order to be able to access Blitz function pointers (not supplied with this library, but free from his site). The main interaction with Scheme is via the TSC_Eval function, which accepts and runs a command and returns the result in a string. Whole source files can be loaded into a Scheme environment with TSC_LoadFile (you need to load init.scm to get full R5RS features).
The barrier to entry for this library may be slightly higher than for others, as (as the examples will demonstrate) Blitz3D functions to be exposed to Scheme must follow a very particular pattern. Because Scheme is a dynamically-typed language, values are passed to Blitz in lists formed of Lisp cons cells, and need to be unpacked from each cell (and repacked for return). It's not logically very difficult, but probably looks terrifying in code form.
It also goes without saying that since Scheme is a Lisp, it has a wildly different syntax from almost every other language in mainstream use. This really isn't as big a deal as it looks, however, and going by the reasonable popularity of other Lisp-based scripting solutions in the world at large, shouldn't be a problem for end users. (If you don't know Lisp, but want to learn, Structure and Interpretation of Computer Programs is widely considered the finest textbook on Computer Science in the world, and uses Scheme as its language. Teach Yourself Scheme in Fixnum Days is a quicker introduction.)
One thing that I think bears mention is that with a suitable function to automatically supply the outermost parentheses, Scheme syntax would be almost perfect for an ingame command line interface, as most command line operations take the form of command followed by space-separated options.
Anyway, if anyone needs a vote of confidence, this is also the first of my scripting submissions that I'm actually considering using in my own project (TCC may be awesome but I can't really think of a good use for it!).
TinyScheme is BSD-licenced, so you can use it freely in any project, open-source or commercial.
Last edited 1+ years ago
Last edited 1+ years ago
|Blitz Social Club|