Skip to content

Instantly share code, notes, and snippets.

@Neztore
Created February 10, 2019 18:34
Show Gist options
  • Select an option

  • Save Neztore/ae967739bd8b1a83ae7c5c896a4042ed to your computer and use it in GitHub Desktop.

Select an option

Save Neztore/ae967739bd8b1a83ae7c5c896a4042ed to your computer and use it in GitHub Desktop.
A strange shape generator that I made for Teverse.
function drawPoint (x, y, z)
local b = engine.block("New block " ..math.floor(x))
b.parent = engine.workspace
b.colour = colour(0, 0.5, 0.5)
b.position = vector3(x, y, z)
end
function drawCircle (z, r, detail)
local x, y = 0, 0
for i = 1, 360, detail do
local angle = i * math.pi / 180
local ptx, pty = x + r * math.cos( angle ), y + r * math.sin( angle )
drawPoint( ptx, pty, z)
end
end
function generateCone (radius, offset, detailReducer, distance)
-- Actual code: distance is just the total offset since start
if not distance then distance = 0 end
if not detailReducer then detailReducer = 1 end
if not offset then offset = 5 end
while radius > 0 do
drawCircle(distance, radius, detailReducer)
-- Now we increment/decrement
distance = distance + offset
radius = radius - 5
wait(.5)
end
end
-- we pass in offset (a fixed incrementing value)
-- And the Radius of the new circle
-- We want to repeat until the radius is 0.
-- Lower detailReducer value = more detail. No parts is divided by this value (approx.). Making it whole is recomended.
-- One side
generateCone(100, nil, 4 )
generateCone(75, nil, 3)
generateCone(50, nil, 2)
-- Other side
generateCone(100, -5, 4, -5)
generateCone(75, -5, 3, -5)
generateCone(50, -5, 2, -5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment