Advertisement
eea

2dnoisev2

eea
Nov 15th, 2022 (edited)
1,048
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.07 KB | None | 0 0
  1. local seed = (math.random() - .5)*2^16
  2. local IT_X = 500
  3. local IT_Z = 500
  4. local size = Vector3.new(4, 1, 4)
  5. local snow = 7/8
  6. local rock = 5/8
  7. local grass = 3/8
  8. local sand = 2/8
  9. local terrain = true
  10. local amplitude = 500
  11. local detail = 70
  12. local offset = Vector3.new(0, 2, 0) + owner.Character.HumanoidRootPart.Position
  13.  
  14. function color(noise)
  15.     local unamnoise = noise/amplitude
  16.     if unamnoise > snow then
  17.         if terrain then
  18.             return Enum.Material.Snow
  19.         end
  20.         return Color3.new(1,1,1)
  21.     end
  22.     if unamnoise > rock and unamnoise < snow then
  23.         if terrain then
  24.             return Enum.Material.Rock
  25.         end
  26.         return Color3.new(.5, .5, .5)
  27.     end
  28.     if unamnoise > grass and unamnoise < rock then
  29.         if terrain then
  30.             return Enum.Material.Grass
  31.         end
  32.         return Color3.new(.1, .8, .1)
  33.     end
  34.     if unamnoise > sand and unamnoise < grass then
  35.         if terrain then
  36.             return Enum.Material.Sand
  37.         end
  38.         return Color3.new(.9, .9, .7)
  39.     end
  40.     if unamnoise < sand then
  41.         if terrain then return Enum.Material.Water end
  42.         return Color3.new(.2, .2, 1)
  43.     end
  44. end
  45.  
  46. function MakeTheStuff(xpos, zpos)
  47.     local noise = math.max((math.noise(xpos/detail + seed, zpos/detail + seed) + .5), sand - .01)*amplitude
  48.     local part = Instance.new("SpawnLocation", script)
  49.     part.Size = Vector3.new(size.X, noise, size.Z)
  50.     part.Position = Vector3.new(xpos, noise/2, zpos)*size + offset
  51.     part.Anchored = true
  52.     part.Enabled = false
  53.     part.Material = "SmoothPlastic"
  54.     if noise == 0 then
  55.         print(noise)
  56.     end
  57.     if terrain then
  58.         workspace.Terrain:FillBlock(part.CFrame, part.Size, color(noise))
  59.         part.Parent = nil
  60.     else
  61.         part.Color = color(noise)
  62.     end
  63. end
  64.  
  65. function run(xpos, zpos)
  66.     local s, e = pcall(function() MakeTheStuff(xpos, zpos) end)
  67.     if e then
  68.         task.wait()
  69.         run(xpos, zpos)
  70.     end
  71. end
  72.  
  73. for x = 1,IT_X do
  74.     for z = 1,IT_Z do
  75.         run(x, z)
  76.     end
  77.     task.wait(.1)
  78. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement