Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Can you recommend a scripting language which allows me to easily parse "one-liner" types of scripts (they're just commands, really)?

For example, a C/C++ function which simply sets the value of a 2-dimensional vector (position, for example):

void SetVector(Vector2 &vector, float x, float y)
{
    vector.x = x;
    vector.y = y;
}

And in the scripting language, the entire script should be able to just be one line long. For example, this would be a script to set the components of vector "a" to 123.0f and 456.0f (x and y) (syntax of the language doesn't really matter, just as an example):

set_vector a 123,456 

I'd use these short scripts to do simple things like change the position of objects during runtime (for debugging or other purposes), create simple config files for all kinds of entities which would go like:

bomb.script:

set_damage 1000
set_range 250
set_texture Data/Sprites/bomb.png

etc.

From a superficial glance, Lua, AngelScript etc. seem to be a little bit bloated for my simple needs (Although I must admit I haven't put tons of time into those two). Can you recommend something better?

share|improve this question
3  
LUA really is as simple as they come. Its a matter of set up, then just register your functions; your not going to really be able to avoid that anywhere. –  Daniel Aug 14 '11 at 0:41
5  
@Daniel: Lua is not an acronym; it is a proper name. –  Nicol Bolas Aug 14 '11 at 1:03
1  
@Nicol; Lol. (Yup, that's right, appreciate the ironic contradiction) –  Daniel Aug 14 '11 at 8:54

2 Answers 2

up vote 9 down vote accepted

As far as simple, "one-liner" scripts are concerned, Lua is a perfectly legitimate choice. Function binding is easy, even with the native API (though there are plenty of helpers for this). It's syntax is pretty easy to learn. Oh, and the runtime is tiny, if that sort of thing matters to you. You won't even have to include its standard libraries, so it'll be even smaller than the compiled static library.

Lua also makes a good data-description language, much like JSON or XML.

Also, don't cut yourself short in terms of room to grow. Right now, you may only want "configuration scripts." But you'd be surprised how easily you might want logic to start creeping into those configurations. Maybe you spawn certain entities based on game state. Or change the texture of something based on game state. Whatever.

Lua can handle all of these kinds of things quite readily.

It is much easier to have too much power and not use it, than it is to have less power and then suddenly need more. Lua's power will be there if you use it, and if you don't, then you won't care. It'll still be quick and simple.

share|improve this answer
    
Alright, I spent the past hour taking a more thorough look at lua and it seems to be simple enough! Thanks. –  TravisG Aug 14 '11 at 14:38

I think ChaiScript would have been an even more simpler to integrate than Lua for your case. It uses a syntax more similar to C++ so it depends.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.