Hi, I'm one of the primary developers for ChaiScript, a free/oss scripting engine for C++. I noticed that one of your todo items is for config file support. I would like to offer my assistance in integrating ChaiScript into your game engine.
Config files are a somewhat "obvious" use of ChaiScript because of its simplicity, but it could be used in any other part of the game for things you want to provide runtime scripting of. The only down side is that it can be rather expensive (CPU time, RAM) at compile time. At runtime, it's pretty lightweight and would likely not be noticed at all.
Another potential downside is that it would add boost (headers only, no libs) as a requirement to your project.
Let me know if you are interested
-Jason
lefticus,
Right now the config file support I need is utterly simple, so I'll probably stick with my current system for a bit longer.
When I get into translation support, though, I might be looking at scripting languages that support unicode config files.
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
It would be nice to have scripting language, but i believe it would be better if it's a well known and widely spreaded (to lower entry-barrier for new developers and don't force them to learn additional unknown stuff)
Something like Ruby / JavaScript / Lua / Python. And similar simply and well-known formats for config YAML / JSON / ....
Or even go deeper and provide some kind of pluggable interfaces to connect any scripting language.
---
Alexey Petrushin
To be honest I think that a nice implemented scripting language also has many advantages.
However, it is difficult to implement. (I have no experience with implementing scripting languages).
A scripting language could be usefull if it implemented for many parts. I can think of:
Statements should be able to:
In my opinion we should probably include a scripting language, but only after we have discussed a lot about how to do it.
Steven
Hi !
May be I am completly wrong, but I don't understand why scripting language seems to be so important, Flare is an engine so people could do everything they want : add/remove effect, power, dialog, map etc... or create a complete new mod/game.
Moreover the way Flare is done make improvements/changes easy to do. So why add a scripting language to flare ? may be somebody could explain me ?
CyberTroll said
Flare is an engine so people could do everything they want
That is a very large statement.
At this moment, item properties, triggers and powers are implemented seperately. If we could do the large task of adding a scripting language, we could merge implementations.
If you want I can try to make some sample scripts, just to add some understanding.
Ok, make sense ! thanks for the reply
> To be honest I think that a nice implemented scripting language also has many advantages.
> However, it is difficult to implement. (I have no experience with implementing scripting languages).
I don't get it, why to reinvent bycicle? This question has been solved years ago, there are tons of scripting languages for any taste.
Alexey Petrushin
A scripting language essentially turns game code into data -- to change major functionality of the game, the modder doesn't have to recompile. This allows modders to do things that the game creator has not planned.
I definitely would use an existing scripting language (e.g. Lua). But it's not zero effort to build an engine around a scripting language -- it takes effort tying in the core engine code (usually fast C++ render routines) to high-level script functions.
I would think that an engine built for scripting should be built that way from the ground up. Thus, Flare is not a good candidate at this point -- it would require rewriting basically everything, and reimplementing most of it in script.
The method I've chosen for Flare (1.0) is having crude .ini style files to toggle built-in options. It is slightly easier to manage than most scripting languages, for modders with zero code experience. But of course it's not as flexible for advanced modders.
From the beginning of this project I've seen Flare as having a very narrow goal: the ability to do single player action rpgs. Even that scope is wildly massive, but sticking to that scope has gotten me a lot of momentum. Anything much outside the scope is (1) outside my expertise and (2) outside my available time. Anything that adds an order of magnitude of complexity to Flare 1.0 will probably be shelved, or I'll encourage others to work on a separate branch/fork.
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.
-Jason
I think I can help in implementing a python into this,
I have some expirence of using swig to imbed python into c/c++ code.
Fruch
(israel.fruchter@gmail.com)
ChaiScript is pretty generic looking(a little google told me something about ECMA language stanard), I don't think it will be a problem for the mildly experience programmer to pick up, nor enough of a hinderance to make them go elsewhere. So I don't really think there is anything to complain about there. If it was some kind of exotic syntaxed script, it would probably be ignored, but this ain't that.
Also having one of it's developers on board probably isn't a bad thing.
that's just my 2 cents as a passer-by, I don't plan on using either though. Just my thoughts as an outsider.