Yesterday I thought it would be fun to make a script interpreter in QuakeC and so I did.
I'm not sure if this is an interesting concept or just a stupid idea.
Anyway, I managed to make it. It currently supports the following features:
The interpreter is accessible via a command which can either run a file or a single line.
I've only tested it in server code but it should work fine in menu and client too.
Sources:
https://github.com/mbasaglia/esk-modpack...and/script
https://github.com/mbasaglia/esk-modpack.../script.qc
It has a C-like syntax, I guess somewhat similar to JavaScript. Semicolons can be replaced by commas so it's easier to execute snippets from the console.
Follows a simple script which gives a basic idea of the syntax:
I made it just for fun, does anyone know if something of this kind can be of any use?
	
	
I'm not sure if this is an interesting concept or just a stupid idea.
Anyway, I managed to make it. It currently supports the following features:
- basic imperative control structures
 
- scoped (untyped) variables
 
- functions
 
- basic numeric and string operators
 
- some misc math and string functions
 
- reading/writing cvars
 
- executing console commands
 
- handling entities
 
The interpreter is accessible via a command which can either run a file or a single line.
I've only tested it in server code but it should work fine in menu and client too.
Sources:
https://github.com/mbasaglia/esk-modpack...and/script
https://github.com/mbasaglia/esk-modpack.../script.qc
It has a C-like syntax, I guess somewhat similar to JavaScript. Semicolons can be replaced by commas so it's easier to execute snippets from the console.
Follows a simple script which gives a basic idea of the syntax:
Code:
function pluralize(string,number)
{
    if ( number == 1 )
        return string;
    else
        return string+"s";
}
function buckets_of_oats(n)
{
    return n+" "+pluralize("bucket",n)+" of oats";
}
function verse(n)
{
    print ( buckets_of_oats(n) + " on the wall, " + buckets_of_oats(n) + "!" );
    wallstring = n == 1 ? "WAAAAALLLL!!!" : "wall";
    print ( "Take one down, pass it around, you got " + buckets_of_oats(n-1) + 
        " on the "+ wallstring );
}
function sing(n = 10)
{
    while ( n > 0 )
    {
        verse(n);
        n -= 1;
    }
}
sing();I made it just for fun, does anyone know if something of this kind can be of any use?


 
 
		

 
	![[Image: 4XODR.png]](http://i.imgur.com/4XODR.png)



