//
// This code was written by stom (not davema, who reposted it).
// For more TTS scripts and mods, see my workshop page: https://steamcommunity.com/id/st0m/myworkshopfiles/
//
function onLoad()
circle = {
color = {0, 0.8, 0.4}, --RGB color of the circle
radius = 5, --radius of the circle around the object
show = false, --should the circle be shown by default?
steps = 32, --number of segments that make up the circle
thickness = 0.25, --thickness of the circle line
vertical_position = 1, --vertical height of the circle relative to the object
}
end
function onDrop()
if circle then toggleCircle() end
end
function toggleCircle()
circle.show = not circle.show
if circle.show then
self.setVectorLines({
{
points = getCircleVectorPoints(circle.radius, circle.steps, circle.vertical_position),
color = circle.color,
thickness = circle.thickness,
rotation = {0,0,0},
}
})
else
self.setVectorLines({})
end
end
function getCircleVectorPoints(radius, steps, y)
local t = {}
local d,s,c,r = 360/steps, math.sin, math.cos, math.rad
for i = 0,steps do
table.insert(t, {
c(r(d*i))*radius,
y,
s(r(d*i))*radius
})
end
return t
end
Comments