Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ruin_deg = 10
- local light_chance = 100 --The greater the number, less is the chance.
- function generate_hallway_segment(pos, size, height, base_material, direction)
- --pos - postion
- --direction - north/south or east/west (2, 1)
- local x,y,z = pos.x,pos.y,pos.z
- local manip = minetest.get_voxel_manip()
- local pos1 = {x = x + size/2, y = y + height, z = z + size/2}
- local pos2 = {x = x - size/2, y = y, z = z - size/2}
- local e1, e2 = manip:read_from_map(pos1, pos2)
- local area = VoxelArea:new{MinEdge=e1, MaxEdge=e2}
- local data = manip:get_data()
- -- A block made out of the material --
- for posX = pos2.x, pos1.x do
- for posY = pos2.y, pos1.y do
- for posZ = pos2.z, pos1.z do
- data[area:index(posX, posY, posZ)] = base_material
- end
- end
- end
- -- Filled directionally with air --
- if direction == 1 then
- for internalX = pos2.x - 1, pos1.x + 1 do
- for internalY = pos2.y + 1, pos1.y - 1 do
- for internalZ = pos2.z + 1, pos1.z - 1 do
- light = math.random(light_chance)
- -- And Lights --
- if light == 25 then
- data[area:index(internalX, internalY, internalZ)] = c_light
- else
- data[area:index(internalX, internalY, internalZ)] = c_air
- end
- end
- end
- end
- elseif direction == 2 then
- for internalX = pos2.x + 1, pos1.x - 1 do
- for internalY = pos2.y + 1, pos1.y - 1 do
- for internalZ = pos2.z - 1, pos1.z + 1 do
- light = math.random(50)
- if light == 25 then
- data[area:index(internalX, internalY, internalZ)] = c_light
- else
- data[area:index(internalX, internalY, internalZ)] = c_air
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment