Advertisement
crabb

terrain test

Jul 5th, 2020
1,246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. -- >  please keep in mind i have never used terrain before
  2. -- >> the writing of this script, so things may look vague
  3.  
  4. -- size (?)
  5. -- width,height,depth
  6. local size = 128
  7. local w,h,d = size,size,size
  8. -- list of occupancy
  9. -- list of materials
  10. local ls_occ = {};
  11. local ls_mat = {};
  12. -- region, resolution
  13. -- the size is (w,h,d)*4 (?)
  14. local region = Region3.new(Vector3.new(0, 0, 0), Vector3.new(w,h,d)*4):ExpandToGrid(4);
  15. local resolution = 4;
  16.  
  17. local mats = {
  18.     [0] = Enum.Material.CrackedLava,Enum.Material.Rock,
  19.     Enum.Material.Ground, Enum.Material.Grass,
  20.     Enum.Material.Water,  Enum.Material.Air
  21. }
  22.  
  23. -- make a 32x32x32 block of rock
  24. for z = 1,d do ls_occ[z],ls_mat[z] = {},{}
  25.     for y = 1,h do ls_occ[z][y],ls_mat[z][y] = {},{}
  26.         for x = 1,w do
  27.             local n = (math.noise(x/w*6,y/h*6,z/d*6) + 1)/2
  28.             ls_occ[z][y][x] = n
  29.             ls_mat[z][y][x] = mats[math.floor(n*6)]
  30.         end
  31.     end
  32. end
  33.  
  34. -- make a 32x1x32 slice of water, at the top
  35. for z = 1,d do
  36.     for x = 1,w do
  37.         --ls_mat[z][d][x] = Enum.Material.Water;
  38.     end
  39. end
  40.  
  41. workspace.Terrain:WriteVoxels(region,resolution,ls_mat,ls_occ);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement