1
0
forked from redo/BlockLua

improve readme, improve std lib

This commit is contained in:
Redo
2025-10-04 01:44:25 -05:00
parent eaafb42317
commit 1a4c7bfefc
6 changed files with 129 additions and 75 deletions

View File

@@ -127,7 +127,7 @@ local vector_meta = {
for i = 1, len do
table.insert(st, tostring(v1[i]))
end
return '{ '..table.concat(st, ', ')..' }'
return 'vector{ '..table.concat(st, ', ')..' }'
end,
unpack = function(v1) return unpack(v1) end,
floor = vector_opn0n('floor', function(x1) return math.floor(x1) end),
@@ -162,10 +162,10 @@ local vector_meta = {
else error('vector rotateByAngleId: invalid rotation '..r, 2) end
return v2
end,
rotate2d = function(v, r)
rotateZ = function(v, r)
--vector_check(v, 2, 'rotate2d')
if type(r)~='number' then
error('vector rotate2d: invalid rotation '..tostring(r), 2) end
error('vector rotateZ: invalid rotation '..tostring(r), 2) end
local len = math.sqrt(v[1]^2 + v[2]^2)
local ang = math.atan2(v[2], v[1]) + r
local v2 = vector_new{ math.cos(ang)*len, math.sin(ang)*len }