impl compat.move for 5.1 vanilla lua

This commit is contained in:
BlackMATov
2024-12-07 22:38:09 +07:00
parent c79b7757c1
commit 6470b0a72b
2 changed files with 18 additions and 2 deletions

View File

@@ -18,7 +18,7 @@
- [ ] add batch vector operations
- [ ] add inplace vector operations
- [x] cache chunk lists in batch operations
- [ ] impl compat.move for 5.1 vanilla lua
- [x] impl compat.move for 5.1 vanilla lua
- [x] add registry.batch_set
- [x] rename include/exclude/execute to query_include/exclude/execute
- [x] rename entities/components to chunk_entities/components

View File

@@ -10,7 +10,23 @@ compat.unpack = table.unpack or function(list, i, j)
end
compat.move = table.move or function(a1, f, e, t, a2)
error('compat.move is not implemented yet', 2)
if a2 == nil then
a2 = a1
end
if e < f then
return a2
end
local d = t - f
if t > e or t <= f or a2 ~= a1 then
for i = f, e do a2[i + d] = a1[i] end
else
for i = e, f, -1 do a2[i + d] = a1[i] end
end
return a2
end
return compat