supertux
supertux copied to clipboard
Revamp the scripting API
I've had an idea for a while now. Let's revamp the scripting api by using a library called simplesquirrel. With this we could practically replace miniswig, which just adds another thing to setup. Also it's a code generator. Code generator bad.
We could replace the functionality of ExposedObject by making the expose function explicitly expose the selected functions:
static void expose(ssq::VM& vm) {
ssq::Class cls = vm.addClass("BadGuy", ssq::Class::Ctor<Foo(<arguments for badguy constructor>)>());
// You can also use lambdas (or std::function) to define constructor
// The function has to return pointer to the new instance
//
// vm.addClass("BadGuy", [](<arguments for badguy constructor>) -> BadGuy* {
// return new BadGuy(msg);
// });
cls.addFunc("kill_fall", &BadGuy::kill_fall);
cls.addFunc("set_action", &BadGuy::set_action);
cls.addVar("dir", &BadGuy::m_dir);
}
This is ripped from simplesquirrel's readme. The readme has really interesting stuff. I recommend you check it out. I also have an idea of being able to override the BadGuy class like if you were programming a badguy in C++ (but it's in squirrel).
Hopefully this will make it less tedious to add scripting features.
If no one wants to tackle this, I can do it after #2621 and #2485
#650 #732
Ye but sqrat sux
SimpleSquirrel is abandoned, might not be a good idea unless it gets forked and maintained by the SuperTux team (probably not ideal?)
I was thinking about forking, actually. At least it's more recent than sqrat