Advertisement
Guest User

old script

a guest
Aug 16th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. ```lua
  2. local updatesPerSecond = 5
  3. local chunkSize = 16
  4. local blockSize = 2.5
  5.  
  6. local totalChunkSize = chunkSize * blockSize
  7.  
  8. local currentChunk = Vector2.new(0, 0)
  9.  
  10. local currentChunkModel = Instance.new("Folder", game.Workspace)
  11. local isFirstTime = true
  12. function getCurrentChunk()
  13. if game.Players.LocalPlayer.Character.HumanoidRootPart ~= nil then
  14. local plrPos = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
  15. local cX = math.ceil(plrPos.X / (totalChunkSize))
  16. local cZ = math.ceil(plrPos.Z / (totalChunkSize))
  17.  
  18. return Vector2.new(cX, cZ)
  19. else
  20. return currentChunk
  21. end
  22. end
  23.  
  24. while wait (1 / updatesPerSecond) do
  25. -- Update chunks and render new ones if needed.
  26. print(currentChunk.X .. ", ".. currentChunk.Y)
  27. if currentChunk ~= getCurrentChunk() or isFirstTime then
  28. isFirstTime = false
  29. currentChunk = getCurrentChunk()
  30. print("Spawning new chunk at (".. currentChunk.X ..", ".. currentChunk.Y ..")...")
  31. currentChunkModel:ClearAllChildren()
  32. for x = -(chunkSize), (chunkSize), blockSize do
  33. for z = -(chunkSize), (chunkSize), blockSize do
  34. local noise = 1--(math.noise(x + (currentChunk.X * chunkSize) / 20, z + (currentChunk.Y * chunkSize) / 20) + 2) * 50
  35. print(noise)
  36. for y = 0, noise, 1 do
  37. local block = Instance.new("Part", currentChunkModel)
  38. block.Anchored = true
  39. block.Size = Vector3.new(blockSize, blockSize, blockSize)
  40. block.CFrame = CFrame.new(x + (getCurrentChunk().X * 16), y, z + (getCurrentChunk().Y * 16))
  41. block.TopSurface = Enum.SurfaceType.SmoothNoOutlines
  42. block.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
  43. block.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
  44. block.RightSurface = Enum.SurfaceType.SmoothNoOutlines
  45. block.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
  46. block.BackSurface = Enum.SurfaceType.SmoothNoOutlines
  47. block.BrickColor = BrickColor.Green()
  48. end
  49. end
  50. end
  51. end
  52. end
  53. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement