Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RF = game:GetService("ReplicatedStorage")
- local size = 5
- local function createNDarray(n, tbl)
- tbl = tbl or {}
- if n == 0 then
- return tbl
- end
- setmetatable(tbl, {
- __index = function(t, k)
- local new = createNDarray(n - 1)
- t[k] = new
- return new
- end,
- })
- return tbl
- end
- local worldmap = createNDarray(3)
- RF.ConfigEvent.OnClientEvent:Connect(function(wsize)
- size = wsize
- end)
- RF.GridCreationEvent.OnClientEvent:Connect(function(cx, cz, x, z)
- for ix = 1, 16 do
- for iz = 1, 16 do
- local instance = Instance.new("Part")
- instance.CFrame = CFrame.new(((x * cx) + ix) * size, 10, ((z * cz) + iz) * size)
- instance.Parent = workspace.worldmap
- instance.Size = Vector3.new(size, size, size)
- instance.Color = Color3.fromRGB(0, 0, 0)
- instance.Material = Enum.Material.SmoothPlastic
- instance.CastShadow = false
- instance.Anchored = true
- worldmap[(x * cx) + ix][10][(z * cz) + iz] = instance
- end
- end
- end)
- RF.RenderEvent.OnClientEvent:Connect(function(buf, parttype)
- local instance = Instance.new(parttype or "Part")
- instance.CFrame = CFrame.new(buffer.readu16(buf, 0 / 8), buffer.readf32(buf, 16 / 8), buffer.readu16(buf, 48 / 8))
- instance.Parent = workspace.worldmap
- instance.Size = Vector3.new(buffer.readu8(buf, 64 / 8), buffer.readu8(buf, 72 / 8), buffer.readu8(buf, 80 / 8))
- instance.Color = Color3.fromRGB(buffer.readu8(buf, 88 / 8), buffer.readu8(buf, 96 / 8), buffer.readu8(buf, 104 / 8))
- instance.Material = Enum.Material.SmoothPlastic
- instance.CastShadow = false
- instance.Anchored = true
- worldmap[buffer.readu16(buf, 0 / 8) / size][buffer.readf32(buf, 16 / 8)][buffer.readu16(buf, 48 / 8) / size] =
- instance
- end)
- RF.ChunkRenderEvent.OnClientEvent:Connect(function(buf)
- local offset = 0
- local cx, cy = buffer.readu8(buf, 4096 / 8), buffer.readu8(buf, 4104 / 8)
- cx, cy = math.abs(cx), math.abs(cy)
- local altermap = { cf = {}, part = {} }
- for ix = 1, 16 do
- for iz = 1, 16 do
- local instance = worldmap[(16 * cx) + ix][10][(16 * cy) + iz]
- local v2 = buffer.readu16(buf, offset / 8) / 2 ^ 4
- offset += 16
- table.insert(altermap.cf, instance.CFrame * CFrame.new(0, v2 * 75, 0))
- table.insert(altermap.part, instance)
- worldmap[(16 * cx) + ix][10][(16 * cy) + iz] = nil
- worldmap[(16 * cx) + ix][v2 * 75][(16 * cy) + iz] = instance
- instance.Color = Color3.fromRGB(v2 * 2, v2 * 2, v2 * 2)
- instance.Transparency = 0
- instance.Material = Enum.Material.Neon
- end
- end
- workspace:BulkMoveTo(altermap.part, altermap.cf, Enum.BulkMoveMode.FireCFrameChanged)
- end)
Advertisement
Add Comment
Please, Sign In to add comment