Length of the array part of the table at `idx` (counts 1..n until the first nil). Avoids depending on lua_objlen's exact spelling across Luau versions.
| 126 | // Length of the array part of the table at `idx` (counts 1..n until the first |
| 127 | // nil). Avoids depending on lua_objlen's exact spelling across Luau versions. |
| 128 | int arrayLen(lua_State* L, int idx) { |
| 129 | int n = 0; |
| 130 | while (true) { |
| 131 | lua_rawgeti(L, idx, n + 1); |
| 132 | const bool is_nil = lua_isnil(L, -1); |
| 133 | lua_pop(L, 1); |
| 134 | if (is_nil) { |
| 135 | return n; |
| 136 | } |
| 137 | ++n; |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | std::string stringField(lua_State* L, int table_idx, const char* key, const std::string& fallback = "") { |
| 142 | lua_rawgetfield(L, table_idx, key); |
no outgoing calls
no test coverage detected