Lua iterator fixes

This commit is contained in:
Zef Hemel
2025-01-08 11:12:26 +01:00
parent ec6db8c766
commit 076c296dfd
2 changed files with 121 additions and 3 deletions
+7 -3
View File
@@ -20,10 +20,14 @@ export const tableApi = new LuaTable({
insert: new LuaBuiltinFunction(
(_sf, tbl: LuaTable, posOrValue: number | any, value?: any) => {
if (value === undefined) {
value = posOrValue;
posOrValue = tbl.length + 1;
let pos = 1;
while (tbl.get(pos) !== null) {
pos++;
}
tbl.set(pos, posOrValue);
} else {
tbl.insert(posOrValue, value);
}
tbl.insert(posOrValue, value);
},
),
remove: new LuaBuiltinFunction((_sf, tbl: LuaTable, pos?: number) => {