Integrating a scripting language to Flare(seeing its current progress) will require reimplementing the engine. It will really be a tedious task. To be honest, I am in favor of integrating scripting to flare but then again, it's not an easy task to do. So, if someone crazy enough wants to take this tedious task, then go do it.
This is why I designed and created ChaiScript. It's suited perfectly for fitting into your C++ wherever you choose to want it. I'm going to show as complete of an example as I can in this posting, and show how simple it is to use (without knowing the internals of Flare). I'm trying to make an example of the "script a potion that affects both HP and MP" mentioned above. There's clearly some details missing, like perhaps the game designer would have to register the new types of potions he's writing. Or perhaps the game engine has a certain number of different potions slots that the game designer can fill.
//userscript.chai
fun applySpecialPotion(playerdata)
{
playerdata.HP += 10;
playerdata.MP += 15;
}
//playerdata.hpp
struct PlayerData
{ int HP; int MP; };
//main.cpp
#include "playerdata.hpp"
#include <chaiscript/ChaiScript.hpp>
int main()
{
PlayerData playerdata;
using namespace chaiscript; ChaiScript chai;
// Set up the things we care about
chai.add(fun(&PlayerData::MP), "MP");
chai.add(fun(&PlayerData::HP), "HP");
chai.add(var(&playerdata), "playerdata");
// Load the game designer's script file
chai.eval_file("userscript.chai");
// ... a bunch of stuff happens and then the player drinks our new potion
int HP = playerdata.HP;
int MP = playerdata.MP;
chai.eval("applySpecialPotion(playerdata)");
assert(playerdata.HP = HP + 10); // test that it had the affect we wanted
assert(playerdata.MP = MP + 15);
}
I may be missing a detail or two, but the above should be a complete working (compilable) example of how to use ChaiScript to script player actions in a game. We tried to make it as simple as possible to use.
The WYSIWIG editor and the <code> tags are not playing nicely with each other, so this isn't formatted as well as it could be, but I think it's readable.
This is why I designed and created ChaiScript. It's suited perfectly for fitting into your C++ wherever you choose to want it. I'm going to show as complete of an example as I can in this posting, and show how simple it is to use (without knowing the internals of Flare). I'm trying to make an example of the "script a potion that affects both HP and MP" mentioned above. There's clearly some details missing, like perhaps the game designer would have to register the new types of potions he's writing. Or perhaps the game engine has a certain number of different potions slots that the game designer can fill.
//userscript.chai
fun applySpecialPotion(playerdata)
{
playerdata.HP += 10;
playerdata.MP += 15;
}
//playerdata.hpp
struct PlayerData
{ int HP; int MP; };
//main.cpp
#include "playerdata.hpp"
#include <chaiscript/ChaiScript.hpp>
int main()
{
PlayerData playerdata;
using namespace chaiscript; ChaiScript chai;
// Set up the things we care about
chai.add(fun(&PlayerData::MP), "MP");
chai.add(fun(&PlayerData::HP), "HP");
chai.add(var(&playerdata), "playerdata");
// Load the game designer's script file
chai.eval_file("userscript.chai");
// ... a bunch of stuff happens and then the player drinks our new potion
int HP = playerdata.HP;
int MP = playerdata.MP;
chai.eval("applySpecialPotion(playerdata)");
assert(playerdata.HP = HP + 10); // test that it had the affect we wanted
assert(playerdata.MP = MP + 15);
}
I may be missing a detail or two, but the above should be a complete working (compilable) example of how to use ChaiScript to script player actions in a game. We tried to make it as simple as possible to use.
The WYSIWIG editor and the <code> tags are not playing nicely with each other, so this isn't formatted as well as it could be, but I think it's readable.
-Jason
Ah. Well we don't support Unicode directly yet. If you still want help at some point with runtime scripting of the engine, let me know.
-Jason