Simple scripting language for "one-liner"-type scripts?

TravisG
  • Simple scripting language for "one-liner"-type scripts? TravisG

    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?

  • 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.

  • 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.

Tags
c++ scripting
Related questions and answers
  • that make really hard to work with when coding some functions that use them. I was thinking of making ie. SimpleMesh and HierarchyMesh objects, which will also require that the renderer can deal... shader in every node. Other option I was thinking was making some helper functions to deal with the simpler cases, which would set some default parameters and would ask only the most basic ones... them to be attached to the node in most cases, even if I allow setting global lights to the scene. @Nicol: Yes that's what I'm trying to figure out. You can see the code doesn't rely on any hardware

  • I'm writing a generic ShaderProgram class that compiles a set of Shader objects, passes args to the shader (like vertex position, vertex normal, tex coords etc), then links the shader components...: float m_Position[3]; // x, y, z // offset 0, size = 3*sizeof(float) float m_TexCoords[2]; // u, v // offset 3*sizeof(float), size = 2*sizeof(float) float m_Normal[3... onscreen, in the shape of the terrain rectangle, but there are no regular lines etc. Here's the code I use for rendering: void ShaderProgram::Draw() { using namespace AntiMatter; if( ! m

  • My engine uses a component-based entity system internally, and I want to bind it to Lua for scripting. Now, I want to save people who write scripts for it typing work. In C++, to set the position of an entity, you'd do the following: pEntity->GetComponent< CPoint >()->SetPos( Vector( X, Y ) ); That means, if I'd bind it to Lua 1:1 you'd also have to: ent:GetComponent( CP_POINT ):SetPos( 123, 456 ) But let's be honest, would you want to type so much just to set an entities' position? I don't think so, that's why I "hid" the component system from Lua: Right now, what you do

  • I have a very simple effect file shown below. I am using this to draw 2D lines, however it is not behaving how I expected and I can't seem to get my head round why. If I draw a line that goes from 0,0 to 100, 100 for example, I would expect it to draw a line from one corner of the screen to a little way in. I would expect it to treat these numbers as screen coordinates. Instead, the line is huge! A line of about 2 long fills the whole screen. Why is this? How can I modify my shader to 'think' in screen coordinates? // a struct for the vertex shader return value struct VSOut { float4 Col

  • this on what I had done there, but modifying it to fit with Ogre. It is working but not correctly and I would like some help to understand what it is I am doing wrong. I have a state system and when...;Ogre::SceneNode *>((*it)->getUserPointer()); TObject = *it; // Set position btVector3 Point = TObject->getCenterOfMassPosition(); node->setPosition(Ogre::Vector3((float...::QuaternionToEuler(const btQuaternion &TQuat, btVector3 &TEuler) { btScalar W = TQuat.getW(); btScalar X = TQuat.getX(); btScalar Y = TQuat.getY(); btScalar Z = TQuat.getZ(); float WSquared = W

  • /////////////////////////////////////////////////////////////////////////////////////////////////////////// class Player : public Sprite { public: Player(string name,int X, int Y, float health){ set_symbol('8... of the screen, and made of 'X's. you can collide with this wall 4 times before losing. When you collide with the wall you can no longer move, and are basically are stuck in that column of the screen until you pop out into an open space, known as a ' ' (space) character. You lose one life for each INITIAL collision with the X wall, and do not lose another until you have popped out and been freed

  • (); }; #endif If I call Init() from game.cpp, the code works fine, if I call cube->init(), just as this function is entered (not when the other one is left), the device pointer suddenly has an address...Basically when placed in the same file this works fine, but if placed in separate files (and I have tested this) just after Init() is called, the pointer to ID3D10* device's value is suddenly...(zbd)); zbd.Width = SCREEN_WIDTH; // set the width of the depth buffer zbd.Height = SCREEN_HEIGHT; // set the height of the depth buffer zbd.ArraySize = 1; // we are only creating one texture

  • i was able to compile and link V8 against my game and code interpretation works fine. However I want to divide my code and the game loop should exist in one thread and the scripting engine should run in a second thread alongside my game loop. I am using SDL and therefore tried this code to spawn a new thread SDL_CreateThread(ScriptingEngine::SpawnMain, NULL); where the following code is my...;v8::Value> result = script->Run(); context.Dispose(); return EXIT_SUCCESS; } } However I get an error like Access violation reading location 0x00000000. in api.cc

  • I been working in the animation of a 2D platformer game in C++/SDL/OpenGL, and my team and I reach the point where we need to establish that every animation of the player (Walking, Running, etc..) needs a different framerate for our concept, but I use as a guideline the Game Programming All In One as a example for the smooth animation, and in the book recommend have variables that limits... that correspond in the vector delayMovementSprite. Something like this: void Sprite::movePosXWithSpeed() { playerMoveInX = false || playerMoveInX; countX++; if ( countX >

Data information