3
\$\begingroup\$

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?

\$\endgroup\$

closed as too broad by Alexandre Vaillancourt, Gnemlock, Josh May 16 '17 at 16:06

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    \$\begingroup\$ 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. \$\endgroup\$ – deceleratedcaviar Aug 14 '11 at 0:41
  • 5
    \$\begingroup\$ @Daniel: Lua is not an acronym; it is a proper name. \$\endgroup\$ – Nicol Bolas Aug 14 '11 at 1:03
  • 1
    \$\begingroup\$ @Nicol; Lol. (Yup, that's right, appreciate the ironic contradiction) \$\endgroup\$ – deceleratedcaviar Aug 14 '11 at 8:54
9
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Alright, I spent the past hour taking a more thorough look at lua and it seems to be simple enough! Thanks. \$\endgroup\$ – TravisG Aug 14 '11 at 14:38
0
\$\begingroup\$

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.

\$\endgroup\$

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