Advertisement
Guest User

Untitled

a guest
Dec 5th, 2011
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. local generate_house = function( minp, maxp )
  2.     local height = 5
  3.     local width = 6
  4.     local length = 6
  5.     local amount = math.random(0, 10)
  6.     for a = 0, amount do
  7.         if (math.random() < 0.5) then
  8.             local pos = {
  9.                 x = math.random( minp.x, maxp.x ),
  10.                 y = math.random( minp.y, maxp.y ),
  11.                 z = math.random( minp.z, maxp.z ),
  12.             }
  13.             local px = { x=pos.x, y=pos.y, z=pos.z }
  14.                 local nx = minetest.env:get_node( px )
  15.             if nx.name == "default:dirt" then
  16.                 for i = 0, width do
  17.                     for j = 0, height do
  18.                         for k = 0, length do
  19.                             if (pos.y > 0) and (pos.y < 30) then
  20.                                 local p = { x=pos.x+i, y=pos.y+j, z=pos.z+k }
  21.                                     local n = minetest.env:get_node( p )
  22.                                 --if n.name == "air" then
  23.                                     if (p.x >= pos.x+1 and p.x <= pos.x+(width-1)) and (p.y >= pos.y+1 and p.y <= pos.y+(height-1)) and (p.z >= pos.z+1 and p.z <= pos.x+(length-1)) then
  24.                                         --skip
  25.                                     else
  26.                                         minetest.env:add_node( p, "default:cobble" )
  27.                                     end
  28.                                 --end
  29.                             end
  30.                         end
  31.                     end
  32.                 end
  33.             end
  34.         end
  35.     end
  36. end
  37.  
  38. minetest.register_on_generated(generate_house)
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement