SHOW:
|
|
- or go back to the newest paste.
| 1 | local ruin_deg = 10 | |
| 2 | local light_chance = 100 --The greater the number, less is the chance. | |
| 3 | ||
| 4 | function generate_hallway_segment(pos, size, height, base_material, direction) | |
| 5 | --pos - postion | |
| 6 | --direction - north/south or east/west (2, 1) | |
| 7 | local x,y,z = pos.x,pos.y,pos.z | |
| 8 | local manip = minetest.get_voxel_manip() | |
| 9 | local pos1 = {x = x + size/2, y = y + height, z = z + size/2}
| |
| 10 | local pos2 = {x = x - size/2, y = y, z = z - size/2}
| |
| 11 | local e1, e2 = manip:read_from_map(pos1, pos2) | |
| 12 | local area = VoxelArea:new{MinEdge=e1, MaxEdge=e2}
| |
| 13 | local data = manip:get_data() | |
| 14 | ||
| 15 | -- A block made out of the material -- | |
| 16 | ||
| 17 | for posX = pos2.x, pos1.x do | |
| 18 | for posY = pos2.y, pos1.y do | |
| 19 | for posZ = pos2.z, pos1.z do | |
| 20 | data[area:index(posX, posY, posZ)] = base_material | |
| 21 | end | |
| 22 | end | |
| 23 | end | |
| 24 | -- Filled directionally with air -- | |
| 25 | if direction == 1 then | |
| 26 | for internalX = pos2.x - 1, pos1.x + 1 do | |
| 27 | for internalY = pos2.y + 1, pos1.y - 1 do | |
| 28 | for internalZ = pos2.z + 1, pos1.z - 1 do | |
| 29 | light = math.random(light_chance) | |
| 30 | -- And Lights -- | |
| 31 | if light == 25 then | |
| 32 | data[area:index(internalX, internalY, internalZ)] = c_light | |
| 33 | else | |
| 34 | data[area:index(internalX, internalY, internalZ)] = c_air | |
| 35 | end | |
| 36 | end | |
| 37 | end | |
| 38 | end | |
| 39 | elseif direction == 2 then | |
| 40 | for internalX = pos2.x + 1, pos1.x - 1 do | |
| 41 | for internalY = pos2.y + 1, pos1.y - 1 do | |
| 42 | for internalZ = pos2.z - 1, pos1.z + 1 do | |
| 43 | light = math.random(50) | |
| 44 | if light == 25 then | |
| 45 | data[area:index(internalX, internalY, internalZ)] = c_light | |
| 46 | else | |
| 47 | data[area:index(internalX, internalY, internalZ)] = c_air | |
| 48 | end | |
| 49 | end | |
| 50 | end | |
| 51 | end | |
| 52 | end |