OpenComputers
OpenComputers copied to clipboard
Lua 5.3 Debug Card NBT-Editing Error
Trying to set NBT when the CPU architecture is 5.3 errors out with
Error converting entry '<thing>': invalid key to 'next'
<thing> is always a list (type 9), so it affects chests with item lists.

~~~The "fix" for now is to simply strip all keys named `n` in lists, although the `setTileNBT` should, of course, ignore this key when iterating.~~~
**Edit**: apparently I was testing on Lua 5.2. This issue only happens on Lua 5.3. Removing `n` doesn't help either.
I already tried that. It didn't work. Did you even try it?
Oh, sorry. I thought I was testing that on Lua 5.3. It was Lua 5.2.
setNBT doesn't work on Lua 5.3 for me too. :confused:
this is failing for the same reason this lua code would fail in 5.3
next({true}, 1.0)
this is a bug in our JNLua, its convertLuaValue method in DefaultConverter.java is assuming a lua number is a double. It seems our JNLua code has some 5.2 behavior. In fact, if we update/fix this convert code, we would probably no longer see doubles in all the lua api results (there should be more integers)
I don't know what source @fnuecke compiles our jnlua from, but this code i see in the deobf'd source
case NUMBER:
luaValueConverter = (DefaultConverter.LuaValueConverter)LUA_VALUE_CONVERTERS.get(formalType);
if (luaValueConverter != null) {
return luaValueConverter.convert(luaState, index);
}
if (formalType == Object.class) {
return luaState.toNumber(index);
}
break;
should do a lua_isinteger check before returning the number. like this:
case NUMBER:
luaValueConverter = (DefaultConverter.LuaValueConverter)LUA_VALUE_CONVERTERS.get(formalType);
if (luaValueConverter != null) {
return luaValueConverter.convert(luaState, index);
}
if (formalType == Object.class) {
if (lua_isinteger(luaState, index))
return luaState.toInteger(index)
else
return luaState.toNumber(index);
}
break;
removing milestone 1.7.3 because I don't know when sangar will be available to build in jnlua binaries
With 5.3 being default architecture this bug became more important. Essentially all integer values reported to LUA are represented as doubles. How come JNLua is compiled from unknown sources?
This breaks e.g. AE integration NetworkControl.store and probably any other LUA function accepting tables
If the issue cannot be resolved via conventional means, may I suggest an ASM class transformer?
updating jnlua breaks our eris support. using a asm conversion may be the smart thing to do. focusing on different issues/features now
I tried to ASM patch DefaultConverter.convertLuaValue but lua_next() still throws on integer conversion. (btw. there is no lua_isinteger in this version of JNLua, so I had to use toIntegerX) Unfortunately lua_next is not very informative about what it doesn't like there. Also, what is eris?
eris is our lua-serializtion library, the thing we use to persist the lua state in-game https://github.com/fnuecke/eris
So, it looks like 5.3 should not have been made default architecture, if one of it's key features (native integers) cannot be fully supported.
i somewhat, maybe mostly, agree with you. but this issue only breaks passing some table data over our java api. user scripts in-game can use lua 5.3 just fine
As far as I see Sangar still supports https://github.com/fnuecke/eris, so, why can't he be contacted about JNLua?
Reopened on request from GT:NH.
Does this still occur after https://github.com/MightyPirates/OpenComputers/commit/ac4d93589ab9c666979bbfda818cad701b617a47 ?
ok, I finally tested and it works fine now, thanks!