Archived

This topic is now archived and is closed to further replies.

farmersckn

how would you implement a script?

Recommended Posts

Unless you wanted to implement an advanced script language of your own with a compiler, parser, etc., then yes, you will want to just read it in line by line and read its first word (being the command), use that to locate in an array a function pointer, then call that function with the remainder of that line (parameters).

- Splat

Share this post


Link to post
Share on other sites
gee wiz thanks! I'd never thought of using an array of pointers to functions...(i only started learning c++ in sept...) i was actually thinking of doing a huge switch to call the functions...probably very foolish...but i'm a qbasic native...oh well...
thank you...

Share this post


Link to post
Share on other sites
would you have a file w/ the script info that could be loaded by your game...
like this:
mov, t, 23, u, l, r, d
could mean to move a tile(23) up, left, right and down.
would you have a function to read the script and then a switch to act upon it?

Share this post


Link to post
Share on other sites