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

D

Deleted member 43881

Luminary
Joined
Sep 8, 2023
Posts
6,633
Reputation
11,307
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

Lxisos
Replies
14
Views
143
Greypiller
Greypiller
nestivv
Replies
15
Views
784
nestivv
nestivv
oadboueq1293
Replies
32
Views
604
2023whitecel
2023whitecel

Users who are viewing this thread

Back
Top