Making a script language?
(WinXP, Console project)
I've finished my engine, worked all the glitchs I could find out of it, now I'm working on maps. Everything in my engine right now relies on fixed movement and things, so I'm going to try and add some randomness.
So, I decided, make a small scripting language! So, I mulled it over, and I came up with how it would work;
Open up a .ord file, which is plain text holding the orders.
Load the file into a string.
Parse the string, find the current level, and take the orders relating to that level. I plan to do this like:
That would be the general layout. But I'm stuck after I parse the string, I need to somehow call a function by a string. I could make a large switch statement, or I could count up every occurance of an object and evaluate the order in a loop.
@CEMD(1, 55, 12, 1);
@CEMD(1, 30, 17, 0);
But both of theyse are very slow methods. It would be better to hardcode the orders, but I'm attempting to avoid that. I need some way of running a script, but making it effective. And doing so, keep the actual scripting language to a minimum.
Then theirs compiling, I guess all I need with that is a library of functions and a switch statement, but I'm going to avoid compiling at runtime.
So, is their a better way of evaluating scripts? -Besides long switch's &/ loops for every statement (which suddenly makes the flexibility vanish).