Added common file to store useful functions
This commit is contained in:
parent
03f68e85e5
commit
2f8c949776
26
koptilnya/common.txt
Normal file
26
koptilnya/common.txt
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
NULL_ENTITY = entity(0)
|
||||||
|
|
||||||
|
function deepcopy(orig)
|
||||||
|
local orig_type = type(orig)
|
||||||
|
local copy
|
||||||
|
if orig_type == 'table' then
|
||||||
|
copy = {}
|
||||||
|
for orig_key, orig_value in next, orig, nil do
|
||||||
|
copy[deepcopy(orig_key)] = deepcopy(orig_value)
|
||||||
|
end
|
||||||
|
setmetatable(copy, deepcopy(getmetatable(orig)))
|
||||||
|
else -- number, string, boolean, etc
|
||||||
|
copy = orig
|
||||||
|
end
|
||||||
|
return copy
|
||||||
|
end
|
||||||
|
|
||||||
|
function table:merge(table1, table2)
|
||||||
|
local newTable = deepcopy(table1)
|
||||||
|
|
||||||
|
for k, v in pairs(table2) do
|
||||||
|
newTable[k] = v
|
||||||
|
end
|
||||||
|
|
||||||
|
return newTable
|
||||||
|
end
|
||||||
@ -57,3 +57,13 @@ function render.drawFilledCircle(x, y, radius, seg)
|
|||||||
|
|
||||||
render.drawPoly(cir)
|
render.drawPoly(cir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function render.drawRotatedSimpleText(x, y, text, ang)
|
||||||
|
local m = Matrix()
|
||||||
|
m:translate(Vector(x, y, 0 ))
|
||||||
|
m:rotate(Angle(0, ang, 0))
|
||||||
|
|
||||||
|
render.pushMatrix(m)
|
||||||
|
render.drawSimpleText(0, 0, text)
|
||||||
|
render.popMatrix()
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user