Hi Folks,
I'm new to the scripting idea, but I figure it will make my life easier for what I need to do.
I'm currently dabbling with an OpenGL tile/2d engine, and I hope to have some trigger based events that can be modified outside of compiled code (obviously where scripting comes in).
Well, needless to say, all my time is spent designing ideas and doing graphics/numbers type stuff so I've never really bothered with scripting.
My needs are not extreme. I just hope to have a few events and then responses to those events. I'd like you more experienced scripting folk to assess it and give me advice as to if I should just go ahead and do a custom script engine/language or attempt to use a current scripting library/language. Let me give you a primary example of what I need.
My maps will have regions, and regions will have trigger events (entity enters or leaves a region). When the event occurs, the scripting language will have a generic function call on that event, and that function will essentially just provide the dynamic data to the compiled function.
Here's some psuedo code of the scripting language (attached to or contained in the map file):
script:region001
{
on_enter
{
move_entity_instantly(100,100);
}
on_exit
{
send_entity_message("Hello there.");
}
}
In the compiled code, say, "ScriptFunctions.cpp" I might have a function to perform the action within the game code.
// The parser determined this function
// and sent the appropriate external variables
void ScriptFunctions::move_entity_instantly(Entity *ent, int x, int y)
{
ent->move(x, y);
// do some other junk
}
Remember this is all theory and psuedo code. So, do you guys think this sort of system would work, or am I terribly naive?
All comments, suggestions, advice, and experience is appreciated! if you see a fatal limitation or flaw to this simple system, please tell. If you know an easier and better method, by all means.
Thanks,
-Catch
"Creativity requires you to murder your children." - Chris Crawford