Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- fills the marked area, ignored objects are not affected
- function io_area_fill (pos, ends, node, force, voxelmanip)
- local pos_start = {x = math.min(pos.x, ends.x) + 1, y = math.min(pos.y, ends.y) + 1, z = math.min(pos.z, ends.z) + 1}
- local pos_end = {x = math.max(pos.x, ends.x) - 1, y = math.max(pos.y, ends.y) - 1, z = math.max(pos.z, ends.z) - 1}
- -- create a vm if none is given
- local voxelmanip_this = {}
- if voxelmanip then
- voxelmanip_this = {vm = voxelmanip.vm, emin = voxelmanip.emin, emax = voxelmanip.emax, update = false}
- else
- voxelmanip_this = {vm = VoxelManip(), emin = pos_start, emax = pos_end, update = true}
- end
- local data = voxelmanip_this.vm:get_data()
- local area = VoxelArea:new{MinEdge = voxelmanip_this.emin, MaxEdge = voxelmanip_this.emax}
- local node_content = minetest.get_content_id(node)
- local node_air_content = minetest.get_content_id("air")
- -- set each node in the marked area
- for i in area:iterp(pos_start, pos_end) do
- if data[i] == node_air_content or force == true then
- data[i] = node_content
- end
- end
- -- write new vm data, preform updates here if we used a local vm
- voxelmanip_this.vm:set_data(data)
- voxelmanip_this.vm:write_to_map()
- if voxelmanip_this.update == true then
- io_vm_update(voxelmanip_this)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement