100 lines
2.8 KiB
Lua
100 lines
2.8 KiB
Lua
-- get string or default
|
|
function getString(var,default)
|
|
local result = get(var)
|
|
if not result then
|
|
return default
|
|
end
|
|
return tostring(result)
|
|
end
|
|
|
|
-- get number or default
|
|
function getNumber(var,default)
|
|
local result = get(var)
|
|
if not result then
|
|
return default
|
|
end
|
|
return tonumber(result)
|
|
end
|
|
|
|
-- get true or false or default
|
|
function getBool(var,default)
|
|
local result = get(var)
|
|
if not result then
|
|
return default
|
|
end
|
|
return result == 'true'
|
|
end
|
|
|
|
function isElementVisible(e)
|
|
local res = false
|
|
if e.interior == 0 and e.dimension == 0 and e.alpha == 255 and e.scale == 1.0 then
|
|
res = true
|
|
end
|
|
|
|
return res
|
|
end
|
|
|
|
function isElementFlat(e)
|
|
local ret = false
|
|
local tol = 0.1
|
|
if not e then return ret end
|
|
local v = e.rotation
|
|
if e.model == 7657 then
|
|
if (v.x < 270+tol and v.x > 270-tol) and (v.y < tol and v.y > -tol) then
|
|
ret = true
|
|
end
|
|
else
|
|
if (v.y < tol and v.y > -tol) and (v.x < tol and v.x > -tol) then
|
|
ret = true
|
|
end
|
|
end
|
|
|
|
return ret
|
|
end
|
|
|
|
function getModelOffset(m)
|
|
local offset = Vector3(0.0, 0.0, 0.0)
|
|
local randX, randY = 0.0, 0.0
|
|
if m.model == 3458 or m.model == 8558 or m.model == 8838 then
|
|
randX = math.random(-9,9) + math.random()
|
|
randY = math.random(-1,1) + math.random()
|
|
offset.z = 1.6
|
|
elseif m.model == 8947 then
|
|
randX = math.random(-2,2) + math.random()
|
|
randY = math.random(-6,6) + math.random()
|
|
offset.z = 3.25
|
|
elseif m.model == 6959 then
|
|
randX = math.random(-7,7) + math.random()
|
|
randY = math.random(-7,7) + math.random()
|
|
elseif m.model == 18450 then
|
|
randX = math.random(-24,24) + math.random()
|
|
randY = math.random(-4,4) + math.random()
|
|
offset.z = 0.5
|
|
elseif m.model == 7657 then
|
|
randX = math.random(-4,4) + math.random()
|
|
randY = math.random()
|
|
offset.z = 0.15
|
|
elseif m.model == 9623 then
|
|
randX = math.random(-9,9) + math.random()
|
|
randY = math.random(-2,2) + math.random()
|
|
offset.z = 3.0
|
|
elseif m.model == 13649 then
|
|
offset.z = 0.7
|
|
elseif m.model == 3095 then
|
|
randX = math.random(-2,2) + math.random()
|
|
randY = math.random(-2,2) + math.random()
|
|
offset.z = 0.6
|
|
elseif m.model == 1482 then
|
|
randX = math.random()
|
|
randY = math.random(-2,2) + math.random()
|
|
offset.z = 1.5
|
|
elseif m.model == 12857 then
|
|
randX = math.random(-3,3) + math.random()
|
|
randY = math.random(-17,17) + math.random()
|
|
offset.z = 2.6
|
|
end
|
|
offset.x = math.cos(math.rad(m.rotation.z))*randX + math.sin(math.rad(m.rotation.z))*randY
|
|
offset.y = math.sin(math.rad(m.rotation.z))*randX - math.cos(math.rad(m.rotation.z))*randY
|
|
|
|
return offset
|
|
end |