Jump to content
  • Advertisement
Sign in to follow this  
cypherx

Anyone need a simple extension language?

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!