Thread: workin' on a scripting engine....

  1. #1
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905

    workin' on a scripting engine....

    Hey everyone, I've started working on a scripting engine for OpenGL and it's going along REALLY nicely. Here's the commands you can use in it so far:

    DrawLine
    EnableTextures
    DisableTextures
    Reset
    SetColor
    Rotate
    EnableCulling
    DrawMode
    DisableCulling
    Box

    Each command can either take parameters or just be a normal command, for example, this code will draw an untextured line to the screen:

    Code:
    /*  Script-and-Go code by Jeff Verkoeyen,
    	created 2003	*/
    
    VARIABLES;
    	@int rot1;
    	@float rot2;
    	@char testing;
    	@bool myBool;
    
    	myBool=true;
    	testing="hey";
    
    	rot1=1;
    	rot2=1;
    BEGIN;
    	rot1+1;
    	rot2+1;
    	DisableTextures;				// Disables the textures
    
    	Reset;
    	Move(0,0,-100);
    	SetColor(1.0f,1.0f,0.0f,0.5f);
    	Rotate(rot1,1.0f,0.0f,0.0f);
    	Move(10,20,0);
    	Box(-10,10,0,10,10,0,10,-10,0,-10,-10,0);
    
    	Reset;
    	Move(0,0,-100);
    	SetColor(0.0f,0.0f,1.0f,0.5f);
    	Rotate(rot2,0.0f,0.0f,1.0f);
    	Move(-10,0,0);
    	Box(-10,10,0,10,10,0,10,-10,0,-10,-10,0);
    END;
    my goal with the engine is to make it so virtually anyone can do OpenGL, even if you don't have a compiler (or you stink at programming, lol)

    the rules of the engine are these:

    1) You must begin your main code with BEGIN, and you may have a section to declare variables, ABOVE the BEGIN-END section by declaring VARIABLES;
    2) All commands must be ended with a semicolon (kinda like C/C++)
    3) Comments include Long Comments and Line Comments, EX:
    Long Comments begin with a /* and end with a */ and can go for multiple lines
    Line Comments are just // and can be placed anywhere in a line and will comment everything from that point on to the end of the line
    4) All commands that have parameters must have the parameters inside of parenthesis ( )
    5) Any command without parameters must NOT have any parenthesis....that should make logical sense, lol (for example: Reset; does not take any parameters, so Reset(3); would return an error)
    6) Any errors found in the code will generate an error inside the program, and then the program will quit (well, you have to handle the quitting and do it however you prefer)
    7) To declare variables, you must do so in the VARIABLES; section. It would also be wise to initialize your variables at the top, also. You may do normal math operations to each of the variables whether in the VARIABLES; section or the BEGIN-END; section.
    8) All programs MUST end with END

    So, yah, I'm hoping to get this finished by Monday, because I'll be using it in my games from now on probably to quickly be able to test OpenGL code without having to recompile anything

    lemme know what you think, and I'm looking for ideas of more commands I should put in the engine......

    -edit-
    updated the comment part

    -edit 2-
    updated everything that was needed to be updated (code, requirements, etc.)
    Last edited by jverkoey; 03-18-2003 at 08:30 AM.

  2. #2
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    >>2) All commands must be ended with a semicolon (kinda like visual studio)


    Correct if wrong, but i was under the impression that ending code with a ';' is all c++ not jusr VC++?

  3. #3
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    ahh, i just realized that.............well, i'll fix it, lol

  4. #4
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    I wasnt trying to nit-pick or anything, it just seemed wrong to me, and wanted to make sure that either i was wrong or you were wrong, so that the two of us were correct in our knowledge of that statement. Sorry if i came across as a jerk, i think the idea is a very good one, congratulations!

    -RoD

  5. #5
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    If a comment is begun with a single /, how will the person do division?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  6. #6
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    lol......that's true, isn't it, once i get the variables in there I won't be able to divide very easily.....hmm, and it's kinda hard to look at two characters at the same time without having to jump back....well, there is peek.....hmm..........i could use @ signs.......that would work......well, wait, if they wanted to output an @ sign......ggrgfggrfgrgfgf

    rfgfdtrfgrfgfrtgf, well, i guess i could just use C++'s way of doing it, I was trying to be as little like C++ as I could.....but I guess the comments will just have to resemble.....UNLESS

    i could use an /@ for long comments and a @/ to close 'em, and for the single line comments, i could use @*

    bwahhaa, that works

  7. #7
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Just use /*

    */

    :P

  8. #8
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    *sigh*, lol, i guess i'll just use that then, hehe, it'll give more familiarity to C++ developers anyways.....

    doop doop, gotta wait till my mom's off the puter so i can go back to work on it......

  9. #9
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    what comp are you on?

    Well this is a C/C++ oriented community, making my suggestion more than expected : )

  10. #10
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    i'm on my puter, but the thing is, my mouse is dead (i took it apart and now the chip is hanging off the side of my desk) and it's really frustrating trying to use the mouse thing where you use the number pad...cuz it keeps randomly clicking....

    I have visual studio on here, but this computer is so da#$ slow it's not even funny, OpenGL goes about 3 frames per second, unless I shrink the window down to about the size of your thumb......

    so yah, I realize i'm in a C++ dev community, I develop in C++ too, but use the OpenGL API, thing is, I just wanted to make my scripting program as simple as possible (the comments don't matter, they're always simple, lol) sooo........i think i answered everything

  11. #11
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Comments in general very simple, but if the idea is too have people who are lower knowleged in programming to use your script then i would devise a comment system that ran together as smoothly as possible.

    For example, its in my opinion that

    /*
    */

    runs together much better than

    &*
    *&

    See what i mean? I think the C++ method would tend to make a little more sense to the programmer. Just a suggestion, however.

  12. #12
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    aah, yes, that makes logical sense.....I think I've got it in my head as to how to read the two characters.......but one question: does peek look at the VERY next character in the stream, without moving forward in it? cuz i know when you use <stream name>.get(buffer); it takes one letter from the file taken from the current position, and stores it to that character, then moves the stream position over one....what I'm thinking of doing is this (forgive me if it doesn't work, i'm doing this off the top of my head...)

    Code:
    file.get(buff);
    if(buff=='/')
    {
       if(file.peek(buff)=='*')
            comment=true;     // set this so I know I'm in a comment
    }
    that way, if it ISN'T a comment, then it won't have moved forward at all and I can test later on if they wanted to divide or whatever....

    that, in my head, theoretically works, I don't know if you can use peek like that though (I'm not exactly an expert on file i/o yet....)
    Last edited by jverkoey; 03-14-2003 at 08:45 PM.

  13. #13
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    aah ha, i'm back at the good puter, I remade the comment code now so it reads like this:

    Code:
    /*  Script-and-Go code by Jeff Verkoeyen,
    	created 2003	*/
    
    BEGIN;
    	Reset;		// Equivalent to LoadIdentity
    	DisableTextures;	// Disables the textures
    	DrawLine(0,0,-80,30,0,-80);	// Draws the line
    END;
    found that the seek thing didn't work at all, so i just used tellg and seekg....that works about the same...

    Code:
    			if(buff2=='/')	//Test for comments
    			{
    				char buff3;
    				script.get(buff3);
    				if(buff3=='*')
    					comment=true;
    				else if(buff3=='/')
    					comment2=true;
    				else
    					script.seekg(filepos);
    			}
    //to find if the comment has started
    
    
    			if(buff2=='*')
    			{
    				char buff3;
    				script.get(buff3);
    				if(buff3=='/')
    					comment=false;
    				else
    					script.seekg(filepos);
    			}
    			if(buff2=='\n')
    				comment2=false;
    //to end it
    and that works fine and dandy

  14. #14
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    you guys can check out the program and tell me what you think....there's still only the basic commands..........(look above for basic instructions) this is a REALLY BASIC demo, so don't expect too much, you can draw a line, and that's about it, lol

  15. #15
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    ok, just added quite a few more commands:

    SetColor
    Move
    Box

    they're self-explanatory........

    anyways, what I was wondering was, how is it possible for users of the script to make their own variables? the only way I've been able to think of implementing variables is to have pre-defined variables that they could use........but that wouldn't add much funtionality..

    thing is, I can't figure out how............*SMACK* *idea hits his head*

    just got a revelation.....!! what do you all think about this? I'll have a huge matrix of integers, maybe about 1024 of them (int vars[1024]) then, if the user wanted to use one of 'em, he/she'd just type in:

    @<variable number>

    for example:

    @102=35;

    would store 35 to slot 102 on the array.........you guys think that would work? i think it would add a pretty nice feature to the program...........

    lookin' for feedback, I won't put it in if it's not a good idea

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-26-2006, 12:14 AM
  2. Scripting Engine - test proggie
    By Magos in forum Game Programming
    Replies: 4
    Last Post: 07-29-2005, 08:15 PM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  4. Tile Engine Scripting Idea. Suggestions?
    By napkin111 in forum Game Programming
    Replies: 8
    Last Post: 07-28-2003, 02:01 PM
  5. How do you do 'scripting' and make your own game engine?
    By Leeman_s in forum C++ Programming
    Replies: 1
    Last Post: 01-02-2002, 03:25 PM