Remove disintigration bombs.
This commit is contained in:
parent
e9765fabfc
commit
52d4311071
2 changed files with 4 additions and 113 deletions
109
spec_bomb.lua
109
spec_bomb.lua
|
@ -1,62 +1,3 @@
|
|||
local function disintigrate(pos, radius, node_name, user_name, dropped)
|
||||
if not (pos and radius and node_name and user_name and type(radius) == 'number' and type(user_name) == 'string') then
|
||||
return
|
||||
end
|
||||
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local air = minetest.get_content_id('air')
|
||||
local minp = vector.subtract(pos, radius)
|
||||
local maxp = vector.add(pos, radius)
|
||||
local vm = minetest.get_voxel_manip()
|
||||
if not vm then
|
||||
return
|
||||
end
|
||||
|
||||
local emin, emax = vm:read_from_map(minp, maxp)
|
||||
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
|
||||
local data = vm:get_data()
|
||||
local count = 0
|
||||
local drops = {}
|
||||
local p = {}
|
||||
for z = minp.z, maxp.z do
|
||||
p.z = z
|
||||
for y = minp.y, maxp.y do
|
||||
p.y = y
|
||||
local ivm = area:index(minp.x, y, z)
|
||||
for x = minp.x, maxp.x do
|
||||
p.x = x
|
||||
if data[ivm] == node_id and not minetest.is_protected(p, user_name) then
|
||||
data[ivm] = air
|
||||
count = count + 1
|
||||
if count % 50 == 0 then
|
||||
drops[#drops+1] = table.copy(p)
|
||||
end
|
||||
end
|
||||
ivm = ivm + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
vm:update_map()
|
||||
|
||||
count = math.floor(count / 3)
|
||||
|
||||
for _, p in pairs(drops) do
|
||||
if count < 1 then
|
||||
return
|
||||
end
|
||||
local dropitem = ItemStack(dropped or node_name)
|
||||
local take = math.min(count, dropitem:get_stack_max())
|
||||
dropitem:set_count(take)
|
||||
local obj = minetest.add_item(p, dropitem)
|
||||
if obj then
|
||||
count = count - take
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function floor(pos, blocks, node_name, user_name)
|
||||
if not (pos and blocks and node_name and user_name and type(blocks) == 'number' and type(node_name) == 'string' and type(user_name) == 'string') then
|
||||
return
|
||||
|
@ -84,56 +25,6 @@ local function floor(pos, blocks, node_name, user_name)
|
|||
end
|
||||
|
||||
|
||||
-- Bombs
|
||||
local nodes = {{'fun_caves:pyramid_1', 'default:sandstone'}, {'fun_caves:tree', 'fun_caves:tree'}, {'default:stone', 'default:cobble'},}
|
||||
for _, node in pairs(nodes) do
|
||||
local node_name = node[1]
|
||||
local comp = node[2] or node_name
|
||||
local node_texture = minetest.registered_items[node_name].tiles
|
||||
if type(node_texture) == 'table' then
|
||||
node_texture = node_texture[1]
|
||||
end
|
||||
local newnode = fun_caves.clone_node(node_name)
|
||||
local _, d_name = node_name:match('(.*:)(.*)')
|
||||
local bomb_name = "fun_caves:"..d_name..'_bomb'
|
||||
local d_name_u = d_name:gsub("(%l)(%w*)", function(a,b) return string.upper(a)..b end)
|
||||
newnode.description = d_name_u.." Bomb"
|
||||
newnode.tiles = {'tnt_top.png', 'tnt_bottom.png', newnode.tiles[1]}
|
||||
newnode.inventory_image = '[inventorycube{tnt_top.png{'..node_texture..'{tnt_side.png'
|
||||
newnode.drop = bomb_name
|
||||
newnode.on_punch = function(pos, node, puncher, pointed_thing)
|
||||
if not (pos and puncher) then
|
||||
return
|
||||
end
|
||||
|
||||
local wield = puncher:get_wielded_item()
|
||||
if not wield or wield:get_name() ~= "default:torch" then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.after(5, function()
|
||||
local pos_node = minetest.get_node_or_nil(pos)
|
||||
if not (pos_node and pos_node.name == bomb_name) then
|
||||
return
|
||||
end
|
||||
|
||||
disintigrate(pos, 5, node_name, puncher:get_player_name(), comp)
|
||||
minetest.remove_node(pos)
|
||||
end)
|
||||
end
|
||||
minetest.register_node(bomb_name, newnode)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "fun_caves:"..d_name..'_bomb',
|
||||
recipe = {
|
||||
{"", comp, ""},
|
||||
{comp, "tnt:gunpowder", comp},
|
||||
{"", comp, ""}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
-- Floor bombs
|
||||
local nodes = {{'default:sandstone', 'default:sandstone_block'}, {'default:wood', 'fun_caves:wood_block'}, {'default:stone', 'default:stone_block'},}
|
||||
for _, node in pairs(nodes) do
|
||||
|
|
|
@ -336,17 +336,17 @@ fun_caves.treegen = function(minp, maxp, data, p2data, area, node)
|
|||
if distance < r then
|
||||
if distance % 8 == 7 and wood_1[index3d] < 0.3 then
|
||||
data[ivm] = node['fun_caves:petrified_wood']
|
||||
elseif wood_1[index3d] < -1.1 then
|
||||
data[ivm] = node['fun_caves:weightless_water']
|
||||
elseif wood_1[index3d] < -0.9 then
|
||||
data[ivm] = node['fun_caves:weightless_water']
|
||||
elseif wood_1[index3d] < -0.8 then
|
||||
data[ivm] = node['air']
|
||||
elseif wood_1[index3d] < -0.1 then
|
||||
data[ivm] = node['fun_caves:tree']
|
||||
elseif wood_1[index3d] < 0.1 then
|
||||
data[ivm] = node['air']
|
||||
elseif wood_1[index3d] < 0.9 then
|
||||
elseif wood_1[index3d] < 0.7 then
|
||||
data[ivm] = node['fun_caves:tree']
|
||||
elseif wood_1[index3d] < 1.3 then
|
||||
elseif wood_1[index3d] < 1.2 then
|
||||
data[ivm] = node['fun_caves:ironwood']
|
||||
else
|
||||
data[ivm] = node['fun_caves:diamondwood']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue