Skip to main content
GameDev.net gamedev.net
🔒 Locked

Scripting engine...

Started by ArtemisX Apr 6, 2001 at 5:17 PM 1 replies 600+ views
Original Post
ArtemisX
ArtemisX
Ok, I have NO idea on how to implement a scripting engine. The biggest problem is the idea of conditions. I''m completely clueless when it comes to this. If anybody could give me some general ideas, I''d be appreciative. Thanks ArtemisX
wingman20
wingman20
what i would suggest it to have the formatting of the script very rigid, have all the functions a set length (ie 4 characters long) and each command on a single line, hat way you don't have to bother with formatting the script.

here's what i would do:

-read line up to first space
-store data from read in cmd
-check if the command associated with cmd has paramters, if it does loop the number of pareters:
-read up to first space or carage return (ascii 10), or = or < etc.
-store data from read in p[ i ]
-end loop
-switch(cmd)
-case(...)
-do something
-case("if")
-if(p[1]=="="){
-if(p[0]==p[2]){
...}
....}
....
-end swithch
-go back to the beggingin until there are no more lines

i would also reccomend (although i'm no exprert) that you not allow conditinal statements to take up more than one line (like you can in c if you use {}), just to remove some comlexety from the scripting engine

hope this helps

Edited by - wingman20 on April 7, 2001 6:39:12 PM
Zephyre
Zephyre
I had the program go through recursively and grab a word (surrounded by parentheses or spaces), then I identified it (command, variable, built in function), and passed it on to the next word to be read. When I got to a semicolon I had a linked list going all the way to the right with everything identified, then I just went back through it (reverse), and did my stuff. I dunno if that helps, I''m pretty sure it doesn''t. If you''re looking for something fast, Flipcode has a good example of pre-compiled scripts.

============================
Trevor "Zephyre" Barnett
============================ Trevor "Zephyre" Barnett Zephyre@home.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.