diff --git a/firmware/controllers/lua/lua_can_rx.cpp b/firmware/controllers/lua/lua_can_rx.cpp index fedf065294..979140d5ae 100644 --- a/firmware/controllers/lua/lua_can_rx.cpp +++ b/firmware/controllers/lua/lua_can_rx.cpp @@ -78,7 +78,9 @@ static void handleCanFrame(LuaHandle& ls, CANRxFrame* frame) { lua_newtable(ls); for (size_t i = 0; i < dlc; i++) { lua_pushinteger(ls, frame->data8[i]); - lua_rawseti(ls, -2, i); + + // index is i+1 because Lua "arrays" (tables) are 1-indexed + lua_rawseti(ls, -2, i + 1); } // Perform the actual function call diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index e1a4c23ce0..3f406e58d4 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -125,7 +125,7 @@ static int lua_txCan(lua_State* l) { while (true) { lua_pushnumber(l, dlc + 1); auto elementType = lua_gettable(l, 4); - auto val = lua_tointeger(l, -1); + auto val = lua_tonumber(l, -1); lua_pop(l, 1); if (elementType == LUA_TNIL) {