1

(13 replies, posted in Scripting)

Yes, thank you anael. I'll continue my slow progress on this smile
I'm just afraid that I will clutter the API to much with my own personal stuff so it becomes unusable as a contribusion in the end.
But maybe some parts of the code can be used at least.

Also, I forgot to mention that setVisible() is broken in the test above (forgot to remove it). But it contains a Lua module loader so require() now can be used instead of doFile() if preferred.

2

(13 replies, posted in Scripting)

Thanks anael, I didn't hit any issues moving to LuaJIT, I think it is (should be) Lua 5.1 compatible with some features from 5.2 that doesn't break the compatibility with 5.1.

I'm not sure about any differences in error handling.
However, when dealing with C types in LuaJIT and error messages, then it shows type names as numbers, like: 'struct 95' which can be cryptic.
But there may be other things here that I'm not aware of yet.

I'm still experimenting a bit with maratis and LuaJIT, especially trying to make better use of the FFI. I believe the only way to do it without changing to much is to get a table of C functions (maratis script API) into LuaJIT and then use ffi.cast to convert each function in the table to the correct function type. We can avoid most of those classic lua_xxx functions then. Also, it makes it easier to pass C data from and to functions if needed, like vectors and stuff.

I have uploaded a test here, maratis+LuaJIT, but it's only for Linux 64bit.
This patch should be applied ontop of the svn 200 version. Overwriting files, then build as normal.

https://dl.dropboxusercontent.com/u/784 … tch.tar.gz

And this is the Linux 64bit binary with the patch above already applied:

https://dl.dropboxusercontent.com/u/784 … -lj.tar.gz

Hope it works if someone want to try it out.

Oh, and the API now lives in a 'maratis' table (my personal choice). That is: getObject() now becomes maratis.getObject() etc.
Same with onSceneUpdate(), now should be written as: maratis.onSceneUpdate = function() ... end

3

(13 replies, posted in Scripting)

I'm already using LuaJIT with maratis, but I couldn't figure out how to build LuaJIT from source with this scons build system, so I had to build it separately then add its library to maratis replacing Lua 5.1.

I suggest that we fully move to LuaJIT at some point. The classic lua_xxx bindings will still slow things down as it stands, but it's still a nice performance boost until we have working FFI bindings.
LuaJIT also supports some Lua 5.2 features/extensions and some other enhancements that makes it good to have in both the Editor and Player for completeness.

As for multiple scripts, I believe require() should be used to import other scripts/modules rather then doFile() for reasons BitPuffin mentioned. Otherwise I'm personally fine with one script per scene.

4

(2 replies, posted in Scripting)

Hi,
Yes, a way to pass values from Lua to specific levels would be nice smile
I realized I was in need of something similar today and hacked together two api functions so I could "preserve" Lua numbers from one level to another.

To use a game plugin is much better, but I'm not there yet.
I just drop the code here anyway in case it's useful for someone else.

file: ...Maratis/Common/MScript/MScript.cpp

#define NUMSLOTS 64
static double g_persistentSlots[NUMSLOTS];

//...

static int getPersistentSlot(lua_State * L)
{
    if(! isFunctionOk(L, "getPersistentSlot", 1))
        return 0;

    int i = luaL_checkinteger(L, -1);
    if(i<0 || i>NUMSLOTS)
    {
        printf("ERROR get persistent slot: %d, invalid index!\n", i);
        return 0;
    }

    lua_pushnumber(L, g_persistentSlots[i-1]);
    return 1;
}

static int setPersistentSlot(lua_State * L)
{
    if(! isFunctionOk(L, "setPersistentSlot", 2))
        return 0;

    int i = luaL_checkinteger(L, -2);
    if(i<1 || i>NUMSLOTS)
    {
        printf("ERROR set persistent slot: %d, invalid index!\n", i);
        return 0;
    }

    g_persistentSlots[i-1] = luaL_checknumber(L, -1);
    return 0;
}

// ...
// Then register these functions in MScript::init with the other API functions.
// ...

5

(1 replies, posted in General)

Hi SadWolf,

That looks almost like a philosophical question to me.
Is life a Scene or a Level? smile

I hope I get this at least barely right...

My interperation of scenes is that they are subparts of a larger simulated environment contained by a specific level. A scene can be a layer of text, a room full of ducks or a view of planet Mars getting terraformed. While an level is the space those scenes exist in. So when big changes is needed, maybe due to performance/memory reason - scenes is getting to big and complex, or simply because it just make sense for other reason or constraints. Then its time to switch level. For example, when going from an outdoor location to an indoor location, or from the main-screen to ingame-view, etc.

There are examples of level changes in many different games, and they all seem to follow a common pattern of "Loading..." something.
It's up to you in the end to where actual change a level contra scene. It's to general to give a good answer without knowing more details about where we really are.

* To me, life is a scene, for you maybe a level? smile

6

(1 replies, posted in Bug report)

Hi,
I have some problem with Maratis when enabling dynamic shadows using the
open source ati (radeon) video driver on Linux.

http://i48.tinypic.com/30b2o3p.png

Could this possible be fixed in shader code?
It would be nice if open source driver(s) could be fully supported by Maratis too.

$ glxinfo | grep OpenGL
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD RV635
OpenGL core profile version string: 3.1 (Core Profile) Mesa 9.1.1
OpenGL core profile shading language version string: 1.40
OpenGL core profile context flags: (none)
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 9.1.1
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions: