flexing a snippet of my procedural generation script (high iq scripters only)

D

Deleted member 43881

Luminary
Joined
Sep 8, 2023
Posts
6,605
Reputation
11,280
i wanna flex this script somewhere but idk where so here

local function fill(a: Vector3, b: Vector3, material: Enum.Material)
local center = (a + b) / 2
local size = Vector3.new(
math.abs(a.X - b.X),
(a.Y + b.Y) / 2,
math.abs(a.Z - b.Z)
)
if size.X == 0 then size = Vector3.new(1, size.Y, size.Z) end
if size.Y == 0 then size = Vector3.new(size.X, 1, size.Z) end
if size.Z == 0 then size = Vector3.new(size.X, size.Y, 1) end
t:FillBlock(CFrame.new(center), size, material)
end

fill(Vector3.new(0, 0, 0), Vector3.new(600, 11, 400), Enum.Material.Rock)

local chunksizez = chunk_size * 5
local chunksizex = 600 / (400 / chunksizez) -- 7.5
local y = 1
local cX = 1
local cZ = 1
local tunnels = 0

local function chunk()
fill(Vector3.new((cX - 1) * chunksizex, y, (cZ - 1) * chunksizez), Vector3.new(cX * chunksizex, 40, cZ * chunksizez), Enum.Material.Ground)
cX = cX + 1
if cX * chunksizex > 600 then
cX = 1
cZ = cZ + 1
end
end
local function tunnel()
tunnels = tunnels + 1
if tunnels == 1 then

local filled = 0

local startingpointx = math.random(20, 30)
local startingpointz = math.random(20, 380)
local endpointx = math.random(500, 550)
local endpointz = math.random(350, 390)
local y = math.random(15, 20)


local totalDistance = (endpointx - startingpointx) + (endpointz - startingpointz)
local steps = totalDistance / chunk_size

local xstep = (endpointx - startingpointx) / steps
local zstep = (endpointz - startingpointz) / steps

local radius = 5

for i = 0, steps do
local currentx = startingpointx + i * xstep
local currentz = startingpointz + i * zstep
if i%10==0 then
local dist = 0
if math.random(1,2)==1 then
repeat
local mod = 1
t:FillBall(Vector3.new(currentx+mod, y, currentz), radius, Enum.Material.Air)
mod = mod + 1
dist = dist + 1
until dist == 5
currentx = currentx + 5
currentz = currentz + 5
else
repeat
local mod = 1
t:FillBall(Vector3.new(currentx, y, currentz+mod), radius, Enum.Material.Air)
mod = mod + 1
dist = dist + 1
until dist == 5
currentz = currentz + 5
currentx = currentx + 5
end
t:FillBall(Vector3.new(currentx, y, currentz), radius, Enum.Material.Air)
end
end

local function path(x,z)
local y = y
repeat
y = y + 3
x = x - 3
z = z - 3
t:FillBall(Vector3.new(x, y, z), radius, Enum.Material.Air)

until y > 40
end
nt.positionvisual(Vector3.new(endpointx,y,endpointz))
print(endpointx.." " .. endpointz)
path(endpointx,endpointz)
path(startingpointx,startingpointz)
end
end

repeat
chunk()
until cZ * chunksizez > 400
tunnel()
 

Similar threads

rata999
Replies
0
Views
10
rata999
rata999
Sovvton
Replies
13
Views
159
cobicado901
cobicado901
Nyrо
Replies
18
Views
61
moonx
moonx
ssTOL
Replies
22
Views
111
underdeveloped
underdeveloped

Users who are viewing this thread

Back
Top