Anyone need a simple extension language?

Started by
2 comments, last by John Schultz 18 years, 8 months ago
I've found getting scripting languages and C++ to play nice to be unnecessarily painful, so I'm writing a simple extension language for my game engine. Would this be useful for anyone else out there? Example:

#include <iostream>
#include <string>
#include "simplescript.h"

class SomeClass
{
public:
void print_func(std::string s) 
{
 std::cout << "Simon says: " << s;
}

}; 
int main(int argc, char** argv)
{
SomeClass some_obj;

SimpleScript::Environment env; 
env.BindFunction("print", &SomeClass::print_func, some_obj)
env.RunScript("somescript.run")
return 0;
}


Somescript.run contains
Quote: (set x 10.9) (print (+ 9.7 x))
The output will be "Simon says: 20.6" I'm using s-expressions because they are easy to parse...though I might add LISP-like features later. Does this interest anyone? Does anything similar exist? -Alex
Advertisement
Perhaps see LuaPlus or Squirrel.

I found found both to be very easy to integrate and use with C++. While both are reference counted, Squirrel is easier to use with (dynamic) classes. LuaPlus also includes a remote debugger (basic debugging is also straightforward with Squirrel; at some point the author may release his remote debugger).
I was actually inspired to roll-my-own scripting language after struggling to get LuaPlus to work with gcc under OSX. It appears to have been written exclusively for windows...and while there's no real dependency on anything win32, I couldn't get LuaPlus to compile on anything but my windows XP laptop.

Squirrel, however, I've never seen before and will definitely check out.

Thanks,
-Alex
Quote:Original post by cypherx
I was actually inspired to roll-my-own scripting language after struggling to get LuaPlus to work with gcc under OSX. It appears to have been written exclusively for windows...and while there's no real dependency on anything win32, I couldn't get LuaPlus to compile on anything but my windows XP laptop.

Squirrel, however, I've never seen before and will definitely check out.

Thanks,
-Alex


Yes, LuaPlus is very powerful, and very cool, however it does rely heavily on template metaprogramming. Thus, when something fails on (library) compile or at runtime, it's harder to debug/fix (this is true of all the metaprogramming methods; boost-based methods will have similar issues. There is a partially implemented template library for Squirrel called Squadd, which uses boost (Alberto's macro based solution is easy and simple enough (and faster) than current template-based methods)). It is also interesting to note that a single metaprogramming template-based script-to-C++ call can incur around 10 (perhaps more) "helper" calls before calling C++ code (as well as the return process).

It would appear that Squirrel could compile on OSX's gcc (works on Linux gcc 3.2.3). They are also working on getting Squirrel to full 64-bit compatibility.

It would be cool to get more of LuaPlus's feature into Squirrel. For now, I'm testing with both scripting languages at the same time in the same app (easy to do).

Let us know if you get Squirrel working in OSX.

This topic is closed to new replies.

Advertisement