27 lines
756 B
Plaintext
27 lines
756 B
Plaintext
-- @name koptilnya/libs/utils
|
|
|
|
function checkVarClass(var, class, message)
|
|
if type(var) ~= "table" or var["class"] == nil or not var:isInstanceOf(class) then
|
|
throw(message == nil and "Wrong variable class." or message, 1, true)
|
|
end
|
|
end
|
|
|
|
function accessorFunc(tbl, varName, name, defaultValue)
|
|
tbl[varName] = defaultValue
|
|
tbl["get" .. name] = function(self)
|
|
return self[varName]
|
|
end
|
|
tbl["set" .. name] = function(self, value)
|
|
self[varName] = value
|
|
end
|
|
end
|
|
|
|
function rotateAround(entity, pivot, angles)
|
|
local pos = entity:getPos()
|
|
local localPivotPos = entity:worldToLocal(pivot)
|
|
|
|
entity:setAngles(angles)
|
|
pos = pos + (pivot - entity:localToWorld(localPivotPos))
|
|
entity:setPos(pos)
|
|
end
|