cepmoc

Untitled

Feb 28th, 2026
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.54 KB | None | 0 0
  1. local RF = game:GetService("ReplicatedStorage")
  2. local size = 5
  3. local function createNDarray(n, tbl)
  4.     tbl = tbl or {}
  5.     if n == 0 then
  6.         return tbl
  7.     end
  8.     setmetatable(tbl, {
  9.         __index = function(t, k)
  10.             local new = createNDarray(n - 1)
  11.             t[k] = new
  12.             return new
  13.         end,
  14.     })
  15.     return tbl
  16. end
  17. local worldmap = createNDarray(3)
  18. RF.ConfigEvent.OnClientEvent:Connect(function(wsize)
  19.     size = wsize
  20. end)
  21. RF.GridCreationEvent.OnClientEvent:Connect(function(cx, cz, x, z)
  22.     for ix = 1, 16 do
  23.         for iz = 1, 16 do
  24.             local instance = Instance.new("Part")
  25.             instance.CFrame = CFrame.new(((x * cx) + ix) * size, 10, ((z * cz) + iz) * size)
  26.             instance.Parent = workspace.worldmap
  27.             instance.Size = Vector3.new(size, size, size)
  28.             instance.Color = Color3.fromRGB(0, 0, 0)
  29.             instance.Material = Enum.Material.SmoothPlastic
  30.             instance.CastShadow = false
  31.             instance.Anchored = true
  32.             worldmap[(x * cx) + ix][10][(z * cz) + iz] = instance
  33.         end
  34.     end
  35. end)
  36. RF.RenderEvent.OnClientEvent:Connect(function(buf, parttype)
  37.     local instance = Instance.new(parttype or "Part")
  38.     instance.CFrame = CFrame.new(buffer.readu16(buf, 0 / 8), buffer.readf32(buf, 16 / 8), buffer.readu16(buf, 48 / 8))
  39.     instance.Parent = workspace.worldmap
  40.     instance.Size = Vector3.new(buffer.readu8(buf, 64 / 8), buffer.readu8(buf, 72 / 8), buffer.readu8(buf, 80 / 8))
  41.     instance.Color = Color3.fromRGB(buffer.readu8(buf, 88 / 8), buffer.readu8(buf, 96 / 8), buffer.readu8(buf, 104 / 8))
  42.     instance.Material = Enum.Material.SmoothPlastic
  43.     instance.CastShadow = false
  44.     instance.Anchored = true
  45.     worldmap[buffer.readu16(buf, 0 / 8) / size][buffer.readf32(buf, 16 / 8)][buffer.readu16(buf, 48 / 8) / size] =
  46.         instance
  47. end)
  48. RF.ChunkRenderEvent.OnClientEvent:Connect(function(buf)
  49.     local offset = 0
  50.     local cx, cy = buffer.readu8(buf, 4096 / 8), buffer.readu8(buf, 4104 / 8)
  51.     cx, cy = math.abs(cx), math.abs(cy)
  52.     local altermap = { cf = {}, part = {} }
  53.     for ix = 1, 16 do
  54.         for iz = 1, 16 do
  55.             local instance = worldmap[(16 * cx) + ix][10][(16 * cy) + iz]
  56.             local v2 = buffer.readu16(buf, offset / 8) / 2 ^ 4
  57.             offset += 16
  58.             table.insert(altermap.cf, instance.CFrame * CFrame.new(0, v2 * 75, 0))
  59.             table.insert(altermap.part, instance)
  60.             worldmap[(16 * cx) + ix][10][(16 * cy) + iz] = nil
  61.             worldmap[(16 * cx) + ix][v2 * 75][(16 * cy) + iz] = instance
  62.             instance.Color = Color3.fromRGB(v2 * 2, v2 * 2, v2 * 2)
  63.             instance.Transparency = 0
  64.             instance.Material = Enum.Material.Neon
  65.         end
  66.     end
  67.     workspace:BulkMoveTo(altermap.part, altermap.cf, Enum.BulkMoveMode.FireCFrameChanged)
  68. end)
Advertisement
Add Comment
Please, Sign In to add comment