lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Jerome, thanks for reply, i really inderstand.

In java i use this code and its work :D

    public void test() {
        state.getGlobal("init");
        state.call(0, 1);
        LuaObject table = state.getLuaObject(1);
        System.out.println(table);
        try {
            LuaObject lo = state.getLuaObject(table, 3);
            System.out.println(lo);
        } catch (LuaException e) {
            e.printStackTrace();
        }
    }

I think i'd be manipulate the LuaObject table methods, but its not... I have to use methos in LuaState ('state' its your instance).

I only need to know is how to get which keys that be used in the script.

2009/6/9 Jerome Vuarand <jerome.vuarand@gmail.com>
2009/6/9 Anselmo Junior <afajunior@gmail.com>:
>> What java API/bindings are you using to access Lua?
>
> Its LuaJava: http://www.keplerproject.org/luajava/
>
>> Here you are trying to get a string key "03" from a table that only has
>> numeric keys.  I don't know what Java API you are using to access Lua, but
>> there should be a way to get numeric keys from the table.
>
> In LuaJava, the LuaState object has the same methods that is in C. If you
> know how to do is in C, i think we can do it with LuaState in java.
> I try replace in lua script the line "t[03] = "3"" for "t["03"] = "3"" and
> really work, i get the number "3" (the value of key "03"), but i'd like to
> use numeric keys.

The problems seems to be in LuaJava. The getField method of the
LuaObject class should take a LuaObject as parameter, not a String.
AFAICT you cannot use numeric keys with LuaJava.