Tidy and arrow
parent
94a02a86cf
commit
b9510f6264
|
@ -1,2 +1,3 @@
|
||||||
str_helpers
|
str_helpers
|
||||||
default
|
default
|
||||||
|
throwing?
|
||||||
|
|
|
@ -1,30 +1,25 @@
|
||||||
local tnt_tables = {["bettertnt:tnt1"] = {r=1},
|
local tnt_tables = {["bettertnt:tnt1"] = {r=1},
|
||||||
["bettertnt:tnt2"] = {r=2},
|
["bettertnt:tnt2"] = {r=2},
|
||||||
["bettertnt:tnt3"] = {r=4},
|
["bettertnt:tnt3"] = {r=3},
|
||||||
["bettertnt:tnt4"] = {r=6},
|
["bettertnt:tnt4"] = {r=4},
|
||||||
["bettertnt:tnt5"] = {r=8},
|
["bettertnt:tnt5"] = {r=5},
|
||||||
["bettertnt:tnt6"] = {r=10},
|
["bettertnt:tnt6"] = {r=7},
|
||||||
["bettertnt:tnt7"] = {r=12},
|
["bettertnt:tnt7"] = {r=9},
|
||||||
["bettertnt:tnt8"] = {r=14},
|
["bettertnt:tnt8"] = {r=11},
|
||||||
["bettertnt:tnt9"] = {r=16},
|
["bettertnt:tnt9"] = {r=13},
|
||||||
["bettertnt:tnt10"] = {r=18},
|
["bettertnt:tnt10"] = {r=15},
|
||||||
["bettertnt:tnt11"] = {r=20},
|
["bettertnt:tnt11"] = {r=20},
|
||||||
["bettertnt:tnt12"] = {r=22},
|
["bettertnt:tnt12"] = {r=25},
|
||||||
["bettertnt:tnt13"] = {r=25},
|
["bettertnt:tnt13"] = {r=30},
|
||||||
["bettertnt:tnt14"] = {r=30},
|
["bettertnt:tnt14"] = {r=35},
|
||||||
["bettertnt:tnt15"] = {r=35},
|
["bettertnt:tnt15"] = {r=40},
|
||||||
["bettertnt:tnt16"] = {r=40},
|
["bettertnt:tnt16"] = {r=50},
|
||||||
["bettertnt:tnt17"] = {r=45},
|
["bettertnt:tnt17"] = {r=60},
|
||||||
["bettertnt:tnt18"] = {r=50},
|
["bettertnt:tnt18"] = {r=70},
|
||||||
["bettertnt:tnt19"] = {r=55},
|
["bettertnt:tnt19"] = {r=85},
|
||||||
["bettertnt:tnt20"] = {r=60},
|
["bettertnt:tnt20"] = {r=100},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tnt = {}
|
|
||||||
tnt.force = {}
|
|
||||||
tnt.accl = {}
|
|
||||||
|
|
||||||
local function is_tnt(name)
|
local function is_tnt(name)
|
||||||
if tnt_tables[name]~=nil then return true end
|
if tnt_tables[name]~=nil then return true end
|
||||||
return false
|
return false
|
||||||
|
@ -44,18 +39,12 @@ end
|
||||||
|
|
||||||
local animated_tnt_texture = combine_texture(16, 4, "tnt_top.png", "bettertnt_top_burning_animated.png")
|
local animated_tnt_texture = combine_texture(16, 4, "tnt_top.png", "bettertnt_top_burning_animated.png")
|
||||||
|
|
||||||
tnt_c_tnt = {}
|
|
||||||
tnt_c_tnt_burning = {}
|
|
||||||
tnt_types_int = {}
|
|
||||||
|
|
||||||
for name,data in pairs(tnt_tables) do
|
for name,data in pairs(tnt_tables) do
|
||||||
|
|
||||||
tnt_types_int[#tnt_types_int] = name
|
|
||||||
|
|
||||||
minetest.register_node(name, {
|
minetest.register_node(name, {
|
||||||
description = "TNT ("..name..")",
|
description = "TNT ("..name..")",
|
||||||
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
||||||
groups = {dig_immediate=2, mesecon=2},
|
groups = {dig_immediate=2, mesecon=2, not_in_creative_inventory=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher)
|
||||||
|
@ -66,7 +55,7 @@ for name,data in pairs(tnt_tables) do
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.sound_play("bettertnt_ignite", {pos=pos})
|
minetest.sound_play("bettertnt_ignite", {pos=pos})
|
||||||
boom_bettertnt(pos, 4, puncher)
|
boom_bettertnt(pos, 4)
|
||||||
minetest.set_node(pos, {name=name.."_burning"})
|
minetest.set_node(pos, {name=name.."_burning"})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -100,33 +89,19 @@ for name,data in pairs(tnt_tables) do
|
||||||
{"",prev,""},
|
{"",prev,""},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
tnt_c_tnt[#tnt_c_tnt + 1] = minetest.get_content_id(name)
|
|
||||||
tnt_c_tnt_burning[#tnt_c_tnt_burning + 1] = minetest.get_content_id(name.."_burning")
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function boom_bettertnt(pos, time)
|
||||||
local function get_tnt_random(pos)
|
|
||||||
return PseudoRandom(math.abs(pos.x+pos.y*3+pos.z*5)+15)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function boom_bettertnt(pos, time, player)
|
|
||||||
local id = minetest.get_node(pos).name
|
local id = minetest.get_node(pos).name
|
||||||
boom_bettertnt_id(pos, time, player, id)
|
boom_bettertnt_id(pos, time, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function boom_bettertnt_id(pos, time, player, id)
|
function boom_bettertnt_id(pos, time, id)
|
||||||
minetest.after(time, function(pos)
|
minetest.after(time, function(pos)
|
||||||
|
|
||||||
local tnt_range = tnt_tables[id].r * 2
|
local tnt_range = tnt_tables[id].r * 2
|
||||||
|
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
pr = get_tnt_random(pos)
|
|
||||||
minetest.sound_play("bettertnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
|
minetest.sound_play("bettertnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
|
||||||
|
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
@ -178,7 +153,7 @@ function boom_bettertnt_id(pos, time, player, id)
|
||||||
|
|
||||||
if is_tnt(nodename)==true then
|
if is_tnt(nodename)==true then
|
||||||
minetest.remove_node(p)
|
minetest.remove_node(p)
|
||||||
boom_bettertnt_id(p, 0.5, player, nodename) -- was {x=p.x, y=p.y, z=p.z}
|
boom_bettertnt_id(p, 0.5, nodename) -- was {x=p.x, y=p.y, z=p.z}
|
||||||
elseif nodename~="air" then
|
elseif nodename~="air" then
|
||||||
--if math.abs(dx)<tnt_range and math.abs(dy)<tnt_range and math.abs(dz)<tnt_range then
|
--if math.abs(dx)<tnt_range and math.abs(dy)<tnt_range and math.abs(dz)<tnt_range then
|
||||||
minetest.remove_node(p)
|
minetest.remove_node(p)
|
||||||
|
@ -190,150 +165,15 @@ function boom_bettertnt_id(pos, time, player, id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.add_particlespawner(
|
|
||||||
100, --amount
|
|
||||||
1, --time
|
|
||||||
{x=pos.x-(tnt_range / 2), y=pos.y-(tnt_range / 2), z=pos.z-(tnt_range / 2)}, --minpos
|
|
||||||
{x=pos.x+(tnt_range / 2), y=pos.y+(tnt_range / 2), z=pos.z+(tnt_range / 2)}, --maxpos
|
|
||||||
{x=-0, y=-0, z=-0}, --minvel
|
|
||||||
{x=0, y=0, z=0}, --maxvel
|
|
||||||
{x=-0.5,y=5,z=-0.5}, --minacc
|
|
||||||
{x=0.5,y=5,z=0.5}, --maxacc
|
|
||||||
0.1, --minexptime
|
|
||||||
1, --maxexptime
|
|
||||||
8, --minsize
|
|
||||||
15, --maxsize
|
|
||||||
true, --collisiondetection
|
|
||||||
"bettertnt_smoke.png" --texture
|
|
||||||
)
|
|
||||||
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
|
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
|
||||||
end, pos)
|
end, pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------- GUNPOWDER -------------------
|
--------------------- GUNPOWDER -------------------
|
||||||
|
|
||||||
|
minetest.register_craftitem("bettertnt:gunpowder", {
|
||||||
function burn(pos, player)
|
|
||||||
local nodename = minetest.get_node(pos).name
|
|
||||||
if strs:starts(nodename, "bettertnt:tnt") then
|
|
||||||
minetest.sound_play("bettertnt_ignite", {pos=pos})
|
|
||||||
boom_bettertnt(pos, 1, player)
|
|
||||||
minetest.set_node(pos, {name=minetest.get_node(pos).name.."_burning"})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if nodename ~= "bettertnt:gunpowder" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.sound_play("bettertnt_gunpowder_burning", {pos=pos, gain=2})
|
|
||||||
minetest.set_node(pos, {name="bettertnt:gunpowder_burning"})
|
|
||||||
|
|
||||||
minetest.after(1, function(pos)
|
|
||||||
if minetest.get_node(pos).name ~= "bettertnt:gunpowder_burning" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.after(0.5, function(pos)
|
|
||||||
minetest.remove_node(pos)
|
|
||||||
end, {x=pos.x, y=pos.y, z=pos.z})
|
|
||||||
for dx=-1,1 do
|
|
||||||
for dz=-1,1 do
|
|
||||||
for dy=-1,1 do
|
|
||||||
pos.x = pos.x+dx
|
|
||||||
pos.y = pos.y+dy
|
|
||||||
pos.z = pos.z+dz
|
|
||||||
|
|
||||||
if not (math.abs(dx) == 1 and math.abs(dz) == 1) then
|
|
||||||
if dy == 0 then
|
|
||||||
burn({x=pos.x, y=pos.y, z=pos.z}, player)
|
|
||||||
else
|
|
||||||
if math.abs(dx) == 1 or math.abs(dz) == 1 then
|
|
||||||
burn({x=pos.x, y=pos.y, z=pos.z}, player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pos.x = pos.x-dx
|
|
||||||
pos.y = pos.y-dy
|
|
||||||
pos.z = pos.z-dz
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end, pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("bettertnt:gunpowder", {
|
|
||||||
description = "Gun Powder",
|
description = "Gun Powder",
|
||||||
drawtype = "raillike",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
tiles = {"bettertnt_gunpowder.png",},
|
|
||||||
inventory_image = "bettertnt_gunpowder_inventory.png",
|
inventory_image = "bettertnt_gunpowder_inventory.png",
|
||||||
wield_image = "bettertnt_gunpowder_inventory.png",
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
groups = {dig_immediate=2,attached_node=1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
|
||||||
if puncher:get_wielded_item():get_name() == "default:torch" then
|
|
||||||
burn(pos, puncher)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("bettertnt:gunpowder_burning", {
|
|
||||||
drawtype = "raillike",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
light_source = 5,
|
|
||||||
tiles = {{name="bettertnt_gunpowder_burning_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1}}},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
drop = "",
|
|
||||||
groups = {dig_immediate=2,attached_node=1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
local tnt_plus_gunpowder = {"bettertnt:gunpowder"}
|
|
||||||
for name,data in pairs(tnt_tables) do
|
|
||||||
tnt_plus_gunpowder[#tnt_plus_gunpowder+1] = name
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = tnt_plus_gunpowder,
|
|
||||||
neighbors = {"fire:basic_flame"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 10,
|
|
||||||
action = function(pos, node)
|
|
||||||
if tnt_tables[node.name]~=nil then
|
|
||||||
boom_bettertnt({x=pos.x, y=pos.y, z=pos.z}, 0)
|
|
||||||
else
|
|
||||||
burn(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = tnt_plus_gunpowder,
|
|
||||||
neighbors = {"tnt:gunpowder"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 10,
|
|
||||||
action = function(pos, node)
|
|
||||||
if tnt_tables[node.name]~=nil then
|
|
||||||
boom_bettertnt({x=pos.x, y=pos.y, z=pos.z}, 0)
|
|
||||||
else
|
|
||||||
burn(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -342,7 +182,55 @@ minetest.register_craft({
|
||||||
recipe = {"default:coal_lump", "default:gravel", "default:dirt"}
|
recipe = {"default:coal_lump", "default:gravel", "default:dirt"}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Arrows
|
||||||
|
if minetest.get_modpath("throwing")~=nil then
|
||||||
|
|
||||||
tnt_c_air = minetest.get_content_id("air")
|
for name,data in pairs(tnt_tables) do
|
||||||
tnt_c_fire = minetest.get_content_id("fire:basic_flame")
|
|
||||||
|
minetest.register_craftitem(name.."_arrow",{
|
||||||
|
description="TNT Arrow ("..name..")",
|
||||||
|
inventory_image="tnt_side.png^throwing_arrow.png",
|
||||||
|
groups={not_in_creative_inventory=1},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output=name.."_arrow",
|
||||||
|
recipe={
|
||||||
|
{'throwing:arrow',name},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
local THROWING_ARROW_ENTITY={
|
||||||
|
physical=false,
|
||||||
|
timer=0,
|
||||||
|
visual="wielditem",
|
||||||
|
visual_size={x=0.1,y=0.1},
|
||||||
|
textures={"throwing:arrow_box"},
|
||||||
|
lastpos={},
|
||||||
|
collisionbox={0,0,0,0,0,0},
|
||||||
|
TNTNAME=name,
|
||||||
|
}
|
||||||
|
|
||||||
|
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||||
|
self.timer=self.timer+dtime
|
||||||
|
local pos = self.object:getpos()
|
||||||
|
local node = minetest.env:get_node(pos)
|
||||||
|
|
||||||
|
if self.lastpos.x~=nil then
|
||||||
|
if node.name ~= "air" then
|
||||||
|
self.object:remove()
|
||||||
|
boom_bettertnt_id(pos,0,self.TNTNAME)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_entity(name.."_arrow_entity",THROWING_ARROW_ENTITY)
|
||||||
|
|
||||||
|
if arrows~=nil then arrows[#arrows+1]={name.."_arrow",name.."_arrow_entity"} end
|
||||||
|
if throwing_arrows~=nil then throwing_arrows[#throwing_arrows+1]={name.."_arrow",name.."_arrow_entity"} end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,25 @@
|
||||||
local tnt_tables = {["checkertnt:tnt1"] = {r=1},
|
local tnt_tables = {["checkertnt:tnt1"] = {r=1},
|
||||||
["checkertnt:tnt2"] = {r=2},
|
["checkertnt:tnt2"] = {r=2},
|
||||||
["checkertnt:tnt3"] = {r=4},
|
["checkertnt:tnt3"] = {r=3},
|
||||||
["checkertnt:tnt4"] = {r=6},
|
["checkertnt:tnt4"] = {r=4},
|
||||||
["checkertnt:tnt5"] = {r=8},
|
["checkertnt:tnt5"] = {r=5},
|
||||||
["checkertnt:tnt6"] = {r=10},
|
["checkertnt:tnt6"] = {r=7},
|
||||||
["checkertnt:tnt7"] = {r=12},
|
["checkertnt:tnt7"] = {r=9},
|
||||||
["checkertnt:tnt8"] = {r=14},
|
["checkertnt:tnt8"] = {r=11},
|
||||||
["checkertnt:tnt9"] = {r=16},
|
["checkertnt:tnt9"] = {r=13},
|
||||||
["checkertnt:tnt10"] = {r=18},
|
["checkertnt:tnt10"] = {r=15},
|
||||||
["checkertnt:tnt11"] = {r=20},
|
["checkertnt:tnt11"] = {r=20},
|
||||||
["checkertnt:tnt12"] = {r=22},
|
["checkertnt:tnt12"] = {r=25},
|
||||||
["checkertnt:tnt13"] = {r=25},
|
["checkertnt:tnt13"] = {r=30},
|
||||||
["checkertnt:tnt14"] = {r=30},
|
["checkertnt:tnt14"] = {r=35},
|
||||||
["checkertnt:tnt15"] = {r=35},
|
["checkertnt:tnt15"] = {r=40},
|
||||||
["checkertnt:tnt16"] = {r=40},
|
["checkertnt:tnt16"] = {r=50},
|
||||||
["checkertnt:tnt17"] = {r=45},
|
["checkertnt:tnt17"] = {r=60},
|
||||||
["checkertnt:tnt18"] = {r=50},
|
["checkertnt:tnt18"] = {r=70},
|
||||||
["checkertnt:tnt19"] = {r=55},
|
["checkertnt:tnt19"] = {r=85},
|
||||||
["checkertnt:tnt20"] = {r=60},
|
["checkertnt:tnt20"] = {r=100},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tnt = {}
|
|
||||||
tnt.force = {}
|
|
||||||
tnt.accl = {}
|
|
||||||
|
|
||||||
local function is_tnt(name)
|
local function is_tnt(name)
|
||||||
if tnt_tables[name]~=nil then return true end
|
if tnt_tables[name]~=nil then return true end
|
||||||
return false
|
return false
|
||||||
|
@ -44,18 +39,12 @@ end
|
||||||
|
|
||||||
local animated_tnt_texture = combine_texture(16, 4, "tnt_top.png", "checkertnt_top_burning_animated.png")
|
local animated_tnt_texture = combine_texture(16, 4, "tnt_top.png", "checkertnt_top_burning_animated.png")
|
||||||
|
|
||||||
tnt_c_tnt = {}
|
|
||||||
tnt_c_tnt_burning = {}
|
|
||||||
tnt_types_int = {}
|
|
||||||
|
|
||||||
for name,data in pairs(tnt_tables) do
|
for name,data in pairs(tnt_tables) do
|
||||||
|
|
||||||
tnt_types_int[#tnt_types_int] = name
|
|
||||||
|
|
||||||
minetest.register_node(name, {
|
minetest.register_node(name, {
|
||||||
description = "TNT ("..name..")",
|
description = "TNT ("..name..")",
|
||||||
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
||||||
groups = {dig_immediate=2, mesecon=2},
|
groups = {dig_immediate=2, mesecon=2, not_in_creative_inventory=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher)
|
||||||
|
@ -66,7 +55,7 @@ for name,data in pairs(tnt_tables) do
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.sound_play("checkertnt_ignite", {pos=pos})
|
minetest.sound_play("checkertnt_ignite", {pos=pos})
|
||||||
boom_checkertnt(pos, 4, puncher)
|
boom_checkertnt(pos, 4)
|
||||||
minetest.set_node(pos, {name=name.."_burning"})
|
minetest.set_node(pos, {name=name.."_burning"})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -101,32 +90,19 @@ for name,data in pairs(tnt_tables) do
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
tnt_c_tnt[#tnt_c_tnt + 1] = minetest.get_content_id(name)
|
|
||||||
tnt_c_tnt_burning[#tnt_c_tnt_burning + 1] = minetest.get_content_id(name.."_burning")
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function boom_checkertnt(pos, time)
|
||||||
local function get_tnt_random(pos)
|
|
||||||
return PseudoRandom(math.abs(pos.x+pos.y*3+pos.z*5)+15)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function boom_checkertnt(pos, time, player)
|
|
||||||
local id = minetest.get_node(pos).name
|
local id = minetest.get_node(pos).name
|
||||||
boom_checkertnt_id(pos, time, player, id)
|
boom_checkertnt_id(pos, time, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function boom_checkertnt_id(pos, time, player, id)
|
function boom_checkertnt_id(pos, time, id)
|
||||||
minetest.after(time, function(pos)
|
minetest.after(time, function(pos)
|
||||||
|
|
||||||
local tnt_range = tnt_tables[id].r * 2
|
local tnt_range = tnt_tables[id].r * 2
|
||||||
|
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
pr = get_tnt_random(pos)
|
|
||||||
minetest.sound_play("checkertnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
|
minetest.sound_play("checkertnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
|
||||||
|
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
@ -167,7 +143,7 @@ function boom_checkertnt_id(pos, time, player, id)
|
||||||
local nodename = minetest.get_node(p).name
|
local nodename = minetest.get_node(p).name
|
||||||
if is_tnt(nodename)==true then
|
if is_tnt(nodename)==true then
|
||||||
minetest.remove_node(p)
|
minetest.remove_node(p)
|
||||||
boom_checkertnt_id(p, 0.5, player, nodename) -- was {x=p.x, y=p.y, z=p.z}
|
boom_checkertnt_id(p, 0.5, nodename) -- was {x=p.x, y=p.y, z=p.z}
|
||||||
elseif (dx+dz+dy) % 2 == 0 then
|
elseif (dx+dz+dy) % 2 == 0 then
|
||||||
minetest.remove_node(p)
|
minetest.remove_node(p)
|
||||||
end
|
end
|
||||||
|
@ -175,150 +151,15 @@ function boom_checkertnt_id(pos, time, player, id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.add_particlespawner(
|
|
||||||
100, --amount
|
|
||||||
1, --time
|
|
||||||
{x=pos.x-(tnt_range / 2), y=pos.y-(tnt_range / 2), z=pos.z-(tnt_range / 2)}, --minpos
|
|
||||||
{x=pos.x+(tnt_range / 2), y=pos.y+(tnt_range / 2), z=pos.z+(tnt_range / 2)}, --maxpos
|
|
||||||
{x=-0, y=-0, z=-0}, --minvel
|
|
||||||
{x=0, y=0, z=0}, --maxvel
|
|
||||||
{x=-0.5,y=5,z=-0.5}, --minacc
|
|
||||||
{x=0.5,y=5,z=0.5}, --maxacc
|
|
||||||
0.1, --minexptime
|
|
||||||
1, --maxexptime
|
|
||||||
8, --minsize
|
|
||||||
15, --maxsize
|
|
||||||
true, --collisiondetection
|
|
||||||
"checkertnt_smoke.png" --texture
|
|
||||||
)
|
|
||||||
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
|
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
|
||||||
end, pos)
|
end, pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------- GUNPOWDER -------------------
|
--------------------- GUNPOWDER -------------------
|
||||||
|
|
||||||
|
minetest.register_craftitem("checkertnt:gunpowder", {
|
||||||
function burn(pos, player)
|
|
||||||
local nodename = minetest.get_node(pos).name
|
|
||||||
if strs:starts(nodename, "checkertnt:tnt") then
|
|
||||||
minetest.sound_play("checkertnt_ignite", {pos=pos})
|
|
||||||
boom_checkertnt(pos, 1, player)
|
|
||||||
minetest.set_node(pos, {name=minetest.get_node(pos).name.."_burning"})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if nodename ~= "checkertnt:gunpowder" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.sound_play("checkertnt_gunpowder_burning", {pos=pos, gain=2})
|
|
||||||
minetest.set_node(pos, {name="checkertnt:gunpowder_burning"})
|
|
||||||
|
|
||||||
minetest.after(1, function(pos)
|
|
||||||
if minetest.get_node(pos).name ~= "checkertnt:gunpowder_burning" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.after(0.5, function(pos)
|
|
||||||
minetest.remove_node(pos)
|
|
||||||
end, {x=pos.x, y=pos.y, z=pos.z})
|
|
||||||
for dx=-1,1 do
|
|
||||||
for dz=-1,1 do
|
|
||||||
for dy=-1,1 do
|
|
||||||
pos.x = pos.x+dx
|
|
||||||
pos.y = pos.y+dy
|
|
||||||
pos.z = pos.z+dz
|
|
||||||
|
|
||||||
if not (math.abs(dx) == 1 and math.abs(dz) == 1) then
|
|
||||||
if dy == 0 then
|
|
||||||
burn({x=pos.x, y=pos.y, z=pos.z}, player)
|
|
||||||
else
|
|
||||||
if math.abs(dx) == 1 or math.abs(dz) == 1 then
|
|
||||||
burn({x=pos.x, y=pos.y, z=pos.z}, player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pos.x = pos.x-dx
|
|
||||||
pos.y = pos.y-dy
|
|
||||||
pos.z = pos.z-dz
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end, pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("checkertnt:gunpowder", {
|
|
||||||
description = "Gun Powder",
|
description = "Gun Powder",
|
||||||
drawtype = "raillike",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
tiles = {"checkertnt_gunpowder.png",},
|
|
||||||
inventory_image = "checkertnt_gunpowder_inventory.png",
|
inventory_image = "checkertnt_gunpowder_inventory.png",
|
||||||
wield_image = "checkertnt_gunpowder_inventory.png",
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
groups = {dig_immediate=2,attached_node=1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
|
||||||
if puncher:get_wielded_item():get_name() == "default:torch" then
|
|
||||||
burn(pos, puncher)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("checkertnt:gunpowder_burning", {
|
|
||||||
drawtype = "raillike",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
light_source = 5,
|
|
||||||
tiles = {{name="checkertnt_gunpowder_burning_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1}}},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
drop = "",
|
|
||||||
groups = {dig_immediate=2,attached_node=1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
local tnt_plus_gunpowder = {"checkertnt:gunpowder"}
|
|
||||||
for name,data in pairs(tnt_tables) do
|
|
||||||
tnt_plus_gunpowder[#tnt_plus_gunpowder+1] = name
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = tnt_plus_gunpowder,
|
|
||||||
neighbors = {"fire:basic_flame"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 10,
|
|
||||||
action = function(pos, node)
|
|
||||||
if tnt_tables[node.name]~=nil then
|
|
||||||
boom_checkertnt({x=pos.x, y=pos.y, z=pos.z}, 0)
|
|
||||||
else
|
|
||||||
burn(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = tnt_plus_gunpowder,
|
|
||||||
neighbors = {"tnt:gunpowder"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 10,
|
|
||||||
action = function(pos, node)
|
|
||||||
if tnt_tables[node.name]~=nil then
|
|
||||||
boom_checkertnt({x=pos.x, y=pos.y, z=pos.z}, 0)
|
|
||||||
else
|
|
||||||
burn(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -327,7 +168,3 @@ minetest.register_craft({
|
||||||
recipe = {"default:coal_lump", "default:gravel", "default:cobble"}
|
recipe = {"default:coal_lump", "default:gravel", "default:cobble"}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
tnt_c_air = minetest.get_content_id("air")
|
|
||||||
tnt_c_fire = minetest.get_content_id("fire:basic_flame")
|
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,25 @@
|
||||||
local tnt_tables = {["fillertnt:tnt1"] = {r=1},
|
local tnt_tables = {["fillertnt:tnt1"] = {r=1},
|
||||||
["fillertnt:tnt2"] = {r=2},
|
["fillertnt:tnt2"] = {r=2},
|
||||||
["fillertnt:tnt3"] = {r=4},
|
["fillertnt:tnt3"] = {r=3},
|
||||||
["fillertnt:tnt4"] = {r=6},
|
["fillertnt:tnt4"] = {r=4},
|
||||||
["fillertnt:tnt5"] = {r=8},
|
["fillertnt:tnt5"] = {r=5},
|
||||||
["fillertnt:tnt6"] = {r=10},
|
["fillertnt:tnt6"] = {r=7},
|
||||||
["fillertnt:tnt7"] = {r=12},
|
["fillertnt:tnt7"] = {r=9},
|
||||||
["fillertnt:tnt8"] = {r=14},
|
["fillertnt:tnt8"] = {r=11},
|
||||||
["fillertnt:tnt9"] = {r=16},
|
["fillertnt:tnt9"] = {r=13},
|
||||||
["fillertnt:tnt10"] = {r=18},
|
["fillertnt:tnt10"] = {r=15},
|
||||||
["fillertnt:tnt11"] = {r=20},
|
["fillertnt:tnt11"] = {r=20},
|
||||||
["fillertnt:tnt12"] = {r=22},
|
["fillertnt:tnt12"] = {r=25},
|
||||||
["fillertnt:tnt13"] = {r=25},
|
["fillertnt:tnt13"] = {r=30},
|
||||||
["fillertnt:tnt14"] = {r=30},
|
["fillertnt:tnt14"] = {r=35},
|
||||||
["fillertnt:tnt15"] = {r=35},
|
["fillertnt:tnt15"] = {r=40},
|
||||||
["fillertnt:tnt16"] = {r=40},
|
["fillertnt:tnt16"] = {r=50},
|
||||||
["fillertnt:tnt17"] = {r=45},
|
["fillertnt:tnt17"] = {r=60},
|
||||||
["fillertnt:tnt18"] = {r=50},
|
["fillertnt:tnt18"] = {r=70},
|
||||||
["fillertnt:tnt19"] = {r=55},
|
["fillertnt:tnt19"] = {r=85},
|
||||||
["fillertnt:tnt20"] = {r=60},
|
["fillertnt:tnt20"] = {r=100},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tnt = {}
|
|
||||||
tnt.force = {}
|
|
||||||
tnt.accl = {}
|
|
||||||
|
|
||||||
local function is_tnt(name)
|
local function is_tnt(name)
|
||||||
if tnt_tables[name]~=nil then return true end
|
if tnt_tables[name]~=nil then return true end
|
||||||
return false
|
return false
|
||||||
|
@ -44,18 +39,12 @@ end
|
||||||
|
|
||||||
local animated_tnt_texture = combine_texture(16, 4, "tnt_top.png", "fillertnt_top_burning_animated.png")
|
local animated_tnt_texture = combine_texture(16, 4, "tnt_top.png", "fillertnt_top_burning_animated.png")
|
||||||
|
|
||||||
tnt_c_tnt = {}
|
|
||||||
tnt_c_tnt_burning = {}
|
|
||||||
tnt_types_int = {}
|
|
||||||
|
|
||||||
for name,data in pairs(tnt_tables) do
|
for name,data in pairs(tnt_tables) do
|
||||||
|
|
||||||
tnt_types_int[#tnt_types_int] = name
|
|
||||||
|
|
||||||
minetest.register_node(name, {
|
minetest.register_node(name, {
|
||||||
description = "TNT ("..name..")",
|
description = "TNT ("..name..")",
|
||||||
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
||||||
groups = {dig_immediate=2, mesecon=2},
|
groups = {dig_immediate=2, mesecon=2, not_in_creative_inventory=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
|
@ -85,7 +74,7 @@ for name,data in pairs(tnt_tables) do
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.sound_play("fillertnt_ignite", {pos=pos})
|
minetest.sound_play("fillertnt_ignite", {pos=pos})
|
||||||
boom_fillertnt(pos, 4, puncher)
|
boom_fillertnt(pos, 4)
|
||||||
minetest.set_node(pos, {name=name.."_burning"})
|
minetest.set_node(pos, {name=name.."_burning"})
|
||||||
meta=minetest.get_meta(pos)
|
meta=minetest.get_meta(pos)
|
||||||
meta:set_string("filler",filler)
|
meta:set_string("filler",filler)
|
||||||
|
@ -122,26 +111,14 @@ for name,data in pairs(tnt_tables) do
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
tnt_c_tnt[#tnt_c_tnt + 1] = minetest.get_content_id(name)
|
|
||||||
tnt_c_tnt_burning[#tnt_c_tnt_burning + 1] = minetest.get_content_id(name.."_burning")
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function boom_fillertnt(pos, time)
|
||||||
local function get_tnt_random(pos)
|
|
||||||
return PseudoRandom(math.abs(pos.x+pos.y*3+pos.z*5)+15)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function boom_fillertnt(pos, time, player)
|
|
||||||
local id = minetest.get_node(pos).name
|
local id = minetest.get_node(pos).name
|
||||||
boom_fillertnt_id(pos, time, player, id)
|
boom_fillertnt_id(pos, time, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function boom_fillertnt_id(pos, time, player, id)
|
function boom_fillertnt_id(pos, time, id)
|
||||||
minetest.after(time, function(pos)
|
minetest.after(time, function(pos)
|
||||||
|
|
||||||
local tnt_range = tnt_tables[id].r * 2
|
local tnt_range = tnt_tables[id].r * 2
|
||||||
|
@ -150,7 +127,6 @@ function boom_fillertnt_id(pos, time, player, id)
|
||||||
print(filler)
|
print(filler)
|
||||||
|
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
pr = get_tnt_random(pos)
|
|
||||||
minetest.sound_play("fillertnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
|
minetest.sound_play("fillertnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
|
||||||
|
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
@ -209,150 +185,15 @@ function boom_fillertnt_id(pos, time, player, id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.add_particlespawner(
|
|
||||||
100, --amount
|
|
||||||
1, --time
|
|
||||||
{x=pos.x-(tnt_range / 2), y=pos.y-(tnt_range / 2), z=pos.z-(tnt_range / 2)}, --minpos
|
|
||||||
{x=pos.x+(tnt_range / 2), y=pos.y+(tnt_range / 2), z=pos.z+(tnt_range / 2)}, --maxpos
|
|
||||||
{x=-0, y=-0, z=-0}, --minvel
|
|
||||||
{x=0, y=0, z=0}, --maxvel
|
|
||||||
{x=-0.5,y=5,z=-0.5}, --minacc
|
|
||||||
{x=0.5,y=5,z=0.5}, --maxacc
|
|
||||||
0.1, --minexptime
|
|
||||||
1, --maxexptime
|
|
||||||
8, --minsize
|
|
||||||
15, --maxsize
|
|
||||||
true, --collisiondetection
|
|
||||||
"fillertnt_smoke.png" --texture
|
|
||||||
)
|
|
||||||
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
|
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
|
||||||
end, pos)
|
end, pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------- GUNPOWDER -------------------
|
--------------------- GUNPOWDER -------------------
|
||||||
|
|
||||||
|
minetest.register_craftitem("fillertnt:gunpowder", {
|
||||||
function burn(pos, player)
|
|
||||||
local nodename = minetest.get_node(pos).name
|
|
||||||
if strs:starts(nodename, "fillertnt:tnt") then
|
|
||||||
minetest.sound_play("fillertnt_ignite", {pos=pos})
|
|
||||||
boom_fillertnt(pos, 1, player)
|
|
||||||
minetest.set_node(pos, {name=minetest.get_node(pos).name.."_burning"})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if nodename ~= "fillertnt:gunpowder" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.sound_play("fillertnt_gunpowder_burning", {pos=pos, gain=2})
|
|
||||||
minetest.set_node(pos, {name="fillertnt:gunpowder_burning"})
|
|
||||||
|
|
||||||
minetest.after(1, function(pos)
|
|
||||||
if minetest.get_node(pos).name ~= "fillertnt:gunpowder_burning" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.after(0.5, function(pos)
|
|
||||||
minetest.remove_node(pos)
|
|
||||||
end, {x=pos.x, y=pos.y, z=pos.z})
|
|
||||||
for dx=-1,1 do
|
|
||||||
for dz=-1,1 do
|
|
||||||
for dy=-1,1 do
|
|
||||||
pos.x = pos.x+dx
|
|
||||||
pos.y = pos.y+dy
|
|
||||||
pos.z = pos.z+dz
|
|
||||||
|
|
||||||
if not (math.abs(dx) == 1 and math.abs(dz) == 1) then
|
|
||||||
if dy == 0 then
|
|
||||||
burn({x=pos.x, y=pos.y, z=pos.z}, player)
|
|
||||||
else
|
|
||||||
if math.abs(dx) == 1 or math.abs(dz) == 1 then
|
|
||||||
burn({x=pos.x, y=pos.y, z=pos.z}, player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pos.x = pos.x-dx
|
|
||||||
pos.y = pos.y-dy
|
|
||||||
pos.z = pos.z-dz
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end, pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("fillertnt:gunpowder", {
|
|
||||||
description = "Gun Powder",
|
description = "Gun Powder",
|
||||||
drawtype = "raillike",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
tiles = {"fillertnt_gunpowder.png",},
|
|
||||||
inventory_image = "fillertnt_gunpowder_inventory.png",
|
inventory_image = "fillertnt_gunpowder_inventory.png",
|
||||||
wield_image = "fillertnt_gunpowder_inventory.png",
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
groups = {dig_immediate=2,attached_node=1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
|
||||||
if puncher:get_wielded_item():get_name() == "default:torch" then
|
|
||||||
burn(pos, puncher)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("fillertnt:gunpowder_burning", {
|
|
||||||
drawtype = "raillike",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
light_source = 5,
|
|
||||||
tiles = {{name="fillertnt_gunpowder_burning_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1}}},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
drop = "",
|
|
||||||
groups = {dig_immediate=2,attached_node=1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
local tnt_plus_gunpowder = {"fillertnt:gunpowder"}
|
|
||||||
for name,data in pairs(tnt_tables) do
|
|
||||||
tnt_plus_gunpowder[#tnt_plus_gunpowder+1] = name
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = tnt_plus_gunpowder,
|
|
||||||
neighbors = {"fire:basic_flame"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 10,
|
|
||||||
action = function(pos, node)
|
|
||||||
if tnt_tables[node.name]~=nil then
|
|
||||||
boom_fillertnt({x=pos.x, y=pos.y, z=pos.z}, 0)
|
|
||||||
else
|
|
||||||
burn(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = tnt_plus_gunpowder,
|
|
||||||
neighbors = {"tnt:gunpowder"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 10,
|
|
||||||
action = function(pos, node)
|
|
||||||
if tnt_tables[node.name]~=nil then
|
|
||||||
boom_fillertnt({x=pos.x, y=pos.y, z=pos.z}, 0)
|
|
||||||
else
|
|
||||||
burn(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -361,7 +202,3 @@ minetest.register_craft({
|
||||||
recipe = {"default:coal_lump", "default:gravel", "default:dirt"}
|
recipe = {"default:coal_lump", "default:gravel", "default:dirt"}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
tnt_c_air = minetest.get_content_id("air")
|
|
||||||
tnt_c_fire = minetest.get_content_id("fire:basic_flame")
|
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,25 @@
|
||||||
local tnt_tables = {["miningtnt:tnt1"] = {r=1},
|
local tnt_tables = {["miningtnt:tnt1"] = {r=1},
|
||||||
["miningtnt:tnt2"] = {r=2},
|
["miningtnt:tnt2"] = {r=2},
|
||||||
["miningtnt:tnt3"] = {r=4},
|
["miningtnt:tnt3"] = {r=3},
|
||||||
["miningtnt:tnt4"] = {r=6},
|
["miningtnt:tnt4"] = {r=4},
|
||||||
["miningtnt:tnt5"] = {r=8},
|
["miningtnt:tnt5"] = {r=5},
|
||||||
["miningtnt:tnt6"] = {r=10},
|
["miningtnt:tnt6"] = {r=7},
|
||||||
["miningtnt:tnt7"] = {r=12},
|
["miningtnt:tnt7"] = {r=9},
|
||||||
["miningtnt:tnt8"] = {r=14},
|
["miningtnt:tnt8"] = {r=11},
|
||||||
["miningtnt:tnt9"] = {r=16},
|
["miningtnt:tnt9"] = {r=13},
|
||||||
["miningtnt:tnt10"] = {r=18},
|
["miningtnt:tnt10"] = {r=15},
|
||||||
["miningtnt:tnt11"] = {r=20},
|
["miningtnt:tnt11"] = {r=20},
|
||||||
["miningtnt:tnt12"] = {r=22},
|
["miningtnt:tnt12"] = {r=25},
|
||||||
["miningtnt:tnt13"] = {r=25},
|
["miningtnt:tnt13"] = {r=30},
|
||||||
["miningtnt:tnt14"] = {r=30},
|
["miningtnt:tnt14"] = {r=35},
|
||||||
["miningtnt:tnt15"] = {r=35},
|
["miningtnt:tnt15"] = {r=40},
|
||||||
["miningtnt:tnt16"] = {r=40},
|
["miningtnt:tnt16"] = {r=50},
|
||||||
["miningtnt:tnt17"] = {r=45},
|
["miningtnt:tnt17"] = {r=60},
|
||||||
["miningtnt:tnt18"] = {r=50},
|
["miningtnt:tnt18"] = {r=70},
|
||||||
["miningtnt:tnt19"] = {r=55},
|
["miningtnt:tnt19"] = {r=85},
|
||||||
["miningtnt:tnt20"] = {r=60},
|
["miningtnt:tnt20"] = {r=100},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tnt = {}
|
|
||||||
tnt.force = {}
|
|
||||||
tnt.accl = {}
|
|
||||||
|
|
||||||
local function is_tnt(name)
|
local function is_tnt(name)
|
||||||
if tnt_tables[name]~=nil then return true end
|
if tnt_tables[name]~=nil then return true end
|
||||||
return false
|
return false
|
||||||
|
@ -44,10 +39,6 @@ end
|
||||||
|
|
||||||
local animated_tnt_texture = combine_texture(16, 4, "tnt_top.png", "miningtnt_top_burning_animated.png")
|
local animated_tnt_texture = combine_texture(16, 4, "tnt_top.png", "miningtnt_top_burning_animated.png")
|
||||||
|
|
||||||
tnt_c_tnt = {}
|
|
||||||
tnt_c_tnt_burning = {}
|
|
||||||
tnt_types_int = {}
|
|
||||||
|
|
||||||
function miningtnt_storage_dump(pos)
|
function miningtnt_storage_dump(pos)
|
||||||
--Add dump
|
--Add dump
|
||||||
local meta=minetest.get_meta(pos)
|
local meta=minetest.get_meta(pos)
|
||||||
|
@ -79,7 +70,7 @@ end
|
||||||
minetest.register_node("miningtnt:storage", {
|
minetest.register_node("miningtnt:storage", {
|
||||||
description = "Mining Storage",
|
description = "Mining Storage",
|
||||||
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
||||||
groups = {cracky=1, level=2},
|
groups = {cracky=1, level=2, not_in_creative_inventory=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
metadata_name = "generic",
|
metadata_name = "generic",
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
|
@ -114,12 +105,10 @@ minetest.register_node("miningtnt:storage", {
|
||||||
|
|
||||||
for name,data in pairs(tnt_tables) do
|
for name,data in pairs(tnt_tables) do
|
||||||
|
|
||||||
tnt_types_int[#tnt_types_int] = name
|
|
||||||
|
|
||||||
minetest.register_node(name, {
|
minetest.register_node(name, {
|
||||||
description = "TNT ("..name..")",
|
description = "TNT ("..name..")",
|
||||||
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
||||||
groups = {dig_immediate=2, mesecon=2},
|
groups = {dig_immediate=2, mesecon=2, not_in_creative_inventory=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher)
|
||||||
|
@ -130,7 +119,7 @@ for name,data in pairs(tnt_tables) do
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.sound_play("miningtnt_ignite", {pos=pos})
|
minetest.sound_play("miningtnt_ignite", {pos=pos})
|
||||||
boom_miningtnt(pos, 4, puncher)
|
boom_miningtnt(pos, 4)
|
||||||
minetest.set_node(pos, {name=name.."_burning"})
|
minetest.set_node(pos, {name=name.."_burning"})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -165,32 +154,19 @@ for name,data in pairs(tnt_tables) do
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
tnt_c_tnt[#tnt_c_tnt + 1] = minetest.get_content_id(name)
|
|
||||||
tnt_c_tnt_burning[#tnt_c_tnt_burning + 1] = minetest.get_content_id(name.."_burning")
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function boom_miningtnt(pos, time)
|
||||||
local function get_tnt_random(pos)
|
|
||||||
return PseudoRandom(math.abs(pos.x+pos.y*3+pos.z*5)+15)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function boom_miningtnt(pos, time, player)
|
|
||||||
local id = minetest.get_node(pos).name
|
local id = minetest.get_node(pos).name
|
||||||
boom_miningtnt_id(pos, time, player, id)
|
boom_miningtnt_id(pos, time, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function boom_miningtnt_id(pos, time, player, id)
|
function boom_miningtnt_id(pos, time, id)
|
||||||
minetest.after(time, function(pos)
|
minetest.after(time, function(pos)
|
||||||
|
|
||||||
local tnt_range = tnt_tables[id].r * 2
|
local tnt_range = tnt_tables[id].r * 2
|
||||||
|
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
pr = get_tnt_random(pos)
|
|
||||||
minetest.sound_play("miningtnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
|
minetest.sound_play("miningtnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
|
||||||
|
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
@ -266,150 +242,15 @@ function boom_miningtnt_id(pos, time, player, id)
|
||||||
i=i+1
|
i=i+1
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.add_particlespawner(
|
|
||||||
100, --amount
|
|
||||||
1, --time
|
|
||||||
{x=pos.x-(tnt_range / 2), y=pos.y-(tnt_range / 2), z=pos.z-(tnt_range / 2)}, --minpos
|
|
||||||
{x=pos.x+(tnt_range / 2), y=pos.y+(tnt_range / 2), z=pos.z+(tnt_range / 2)}, --maxpos
|
|
||||||
{x=-0, y=-0, z=-0}, --minvel
|
|
||||||
{x=0, y=0, z=0}, --maxvel
|
|
||||||
{x=-0.5,y=5,z=-0.5}, --minacc
|
|
||||||
{x=0.5,y=5,z=0.5}, --maxacc
|
|
||||||
0.1, --minexptime
|
|
||||||
1, --maxexptime
|
|
||||||
8, --minsize
|
|
||||||
15, --maxsize
|
|
||||||
true, --collisiondetection
|
|
||||||
"miningtnt_smoke.png" --texture
|
|
||||||
)
|
|
||||||
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
|
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
|
||||||
end, pos)
|
end, pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------- GUNPOWDER -------------------
|
--------------------- GUNPOWDER -------------------
|
||||||
|
|
||||||
|
minetest.register_craftitem("miningtnt:gunpowder", {
|
||||||
function burn(pos, player)
|
|
||||||
local nodename = minetest.get_node(pos).name
|
|
||||||
if strs:starts(nodename, "miningtnt:tnt") then
|
|
||||||
minetest.sound_play("miningtnt_ignite", {pos=pos})
|
|
||||||
boom_miningtnt(pos, 1, player)
|
|
||||||
minetest.set_node(pos, {name=minetest.get_node(pos).name.."_burning"})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if nodename ~= "miningtnt:gunpowder" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.sound_play("miningtnt_gunpowder_burning", {pos=pos, gain=2})
|
|
||||||
minetest.set_node(pos, {name="miningtnt:gunpowder_burning"})
|
|
||||||
|
|
||||||
minetest.after(1, function(pos)
|
|
||||||
if minetest.get_node(pos).name ~= "miningtnt:gunpowder_burning" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.after(0.5, function(pos)
|
|
||||||
minetest.remove_node(pos)
|
|
||||||
end, {x=pos.x, y=pos.y, z=pos.z})
|
|
||||||
for dx=-1,1 do
|
|
||||||
for dz=-1,1 do
|
|
||||||
for dy=-1,1 do
|
|
||||||
pos.x = pos.x+dx
|
|
||||||
pos.y = pos.y+dy
|
|
||||||
pos.z = pos.z+dz
|
|
||||||
|
|
||||||
if not (math.abs(dx) == 1 and math.abs(dz) == 1) then
|
|
||||||
if dy == 0 then
|
|
||||||
burn({x=pos.x, y=pos.y, z=pos.z}, player)
|
|
||||||
else
|
|
||||||
if math.abs(dx) == 1 or math.abs(dz) == 1 then
|
|
||||||
burn({x=pos.x, y=pos.y, z=pos.z}, player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pos.x = pos.x-dx
|
|
||||||
pos.y = pos.y-dy
|
|
||||||
pos.z = pos.z-dz
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end, pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("miningtnt:gunpowder", {
|
|
||||||
description = "Gun Powder",
|
description = "Gun Powder",
|
||||||
drawtype = "raillike",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
tiles = {"miningtnt_gunpowder.png",},
|
|
||||||
inventory_image = "miningtnt_gunpowder_inventory.png",
|
inventory_image = "miningtnt_gunpowder_inventory.png",
|
||||||
wield_image = "miningtnt_gunpowder_inventory.png",
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
groups = {dig_immediate=2,attached_node=1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
|
||||||
if puncher:get_wielded_item():get_name() == "default:torch" then
|
|
||||||
burn(pos, puncher)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("miningtnt:gunpowder_burning", {
|
|
||||||
drawtype = "raillike",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
light_source = 5,
|
|
||||||
tiles = {{name="miningtnt_gunpowder_burning_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1}}},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
drop = "",
|
|
||||||
groups = {dig_immediate=2,attached_node=1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
local tnt_plus_gunpowder = {"miningtnt:gunpowder"}
|
|
||||||
for name,data in pairs(tnt_tables) do
|
|
||||||
tnt_plus_gunpowder[#tnt_plus_gunpowder+1] = name
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = tnt_plus_gunpowder,
|
|
||||||
neighbors = {"fire:basic_flame"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 10,
|
|
||||||
action = function(pos, node)
|
|
||||||
if tnt_tables[node.name]~=nil then
|
|
||||||
boom_miningtnt({x=pos.x, y=pos.y, z=pos.z}, 0)
|
|
||||||
else
|
|
||||||
burn(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = tnt_plus_gunpowder,
|
|
||||||
neighbors = {"tnt:gunpowder"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 10,
|
|
||||||
action = function(pos, node)
|
|
||||||
if tnt_tables[node.name]~=nil then
|
|
||||||
boom_miningtnt({x=pos.x, y=pos.y, z=pos.z}, 0)
|
|
||||||
else
|
|
||||||
burn(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -418,7 +259,3 @@ minetest.register_craft({
|
||||||
recipe = {"default:coal_lump", "default:gravel", "default:pick_stone"}
|
recipe = {"default:coal_lump", "default:gravel", "default:pick_stone"}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
tnt_c_air = minetest.get_content_id("air")
|
|
||||||
tnt_c_fire = minetest.get_content_id("fire:basic_flame")
|
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,25 @@
|
||||||
local tnt_tables = {["napalmtnt:tnt1"] = {r=1},
|
local tnt_tables = {["napalmtnt:tnt1"] = {r=1},
|
||||||
["napalmtnt:tnt2"] = {r=2},
|
["napalmtnt:tnt2"] = {r=2},
|
||||||
["napalmtnt:tnt3"] = {r=4},
|
["napalmtnt:tnt3"] = {r=3},
|
||||||
["napalmtnt:tnt4"] = {r=6},
|
["napalmtnt:tnt4"] = {r=4},
|
||||||
["napalmtnt:tnt5"] = {r=8},
|
["napalmtnt:tnt5"] = {r=5},
|
||||||
["napalmtnt:tnt6"] = {r=10},
|
["napalmtnt:tnt6"] = {r=7},
|
||||||
["napalmtnt:tnt7"] = {r=12},
|
["napalmtnt:tnt7"] = {r=9},
|
||||||
["napalmtnt:tnt8"] = {r=14},
|
["napalmtnt:tnt8"] = {r=11},
|
||||||
["napalmtnt:tnt9"] = {r=16},
|
["napalmtnt:tnt9"] = {r=13},
|
||||||
["napalmtnt:tnt10"] = {r=18},
|
["napalmtnt:tnt10"] = {r=15},
|
||||||
["napalmtnt:tnt11"] = {r=20},
|
["napalmtnt:tnt11"] = {r=20},
|
||||||
["napalmtnt:tnt12"] = {r=22},
|
["napalmtnt:tnt12"] = {r=25},
|
||||||
["napalmtnt:tnt13"] = {r=25},
|
["napalmtnt:tnt13"] = {r=30},
|
||||||
["napalmtnt:tnt14"] = {r=30},
|
["napalmtnt:tnt14"] = {r=35},
|
||||||
["napalmtnt:tnt15"] = {r=35},
|
["napalmtnt:tnt15"] = {r=40},
|
||||||
["napalmtnt:tnt16"] = {r=40},
|
["napalmtnt:tnt16"] = {r=50},
|
||||||
["napalmtnt:tnt17"] = {r=45},
|
["napalmtnt:tnt17"] = {r=60},
|
||||||
["napalmtnt:tnt18"] = {r=50},
|
["napalmtnt:tnt18"] = {r=70},
|
||||||
["napalmtnt:tnt19"] = {r=55},
|
["napalmtnt:tnt19"] = {r=85},
|
||||||
["napalmtnt:tnt20"] = {r=60},
|
["napalmtnt:tnt20"] = {r=100},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tnt = {}
|
|
||||||
tnt.force = {}
|
|
||||||
tnt.accl = {}
|
|
||||||
|
|
||||||
local function is_tnt(name)
|
local function is_tnt(name)
|
||||||
if tnt_tables[name]~=nil then return true end
|
if tnt_tables[name]~=nil then return true end
|
||||||
return false
|
return false
|
||||||
|
@ -44,18 +39,12 @@ end
|
||||||
|
|
||||||
local animated_tnt_texture = combine_texture(16, 4, "tnt_top.png", "napalmtnt_top_burning_animated.png")
|
local animated_tnt_texture = combine_texture(16, 4, "tnt_top.png", "napalmtnt_top_burning_animated.png")
|
||||||
|
|
||||||
tnt_c_tnt = {}
|
|
||||||
tnt_c_tnt_burning = {}
|
|
||||||
tnt_types_int = {}
|
|
||||||
|
|
||||||
for name,data in pairs(tnt_tables) do
|
for name,data in pairs(tnt_tables) do
|
||||||
|
|
||||||
tnt_types_int[#tnt_types_int] = name
|
|
||||||
|
|
||||||
minetest.register_node(name, {
|
minetest.register_node(name, {
|
||||||
description = "TNT ("..name..")",
|
description = "TNT ("..name..")",
|
||||||
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
||||||
groups = {dig_immediate=2, mesecon=2},
|
groups = {dig_immediate=2, mesecon=2, not_in_creative_inventory=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher)
|
||||||
|
@ -66,7 +55,7 @@ for name,data in pairs(tnt_tables) do
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.sound_play("napalmtnt_ignite", {pos=pos})
|
minetest.sound_play("napalmtnt_ignite", {pos=pos})
|
||||||
boom_napalmtnt(pos, 4, puncher)
|
boom_napalmtnt(pos, 4)
|
||||||
minetest.set_node(pos, {name=name.."_burning"})
|
minetest.set_node(pos, {name=name.."_burning"})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -101,32 +90,19 @@ for name,data in pairs(tnt_tables) do
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
tnt_c_tnt[#tnt_c_tnt + 1] = minetest.get_content_id(name)
|
|
||||||
tnt_c_tnt_burning[#tnt_c_tnt_burning + 1] = minetest.get_content_id(name.."_burning")
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function boom_napalmtnt(pos, time)
|
||||||
local function get_tnt_random(pos)
|
|
||||||
return PseudoRandom(math.abs(pos.x+pos.y*3+pos.z*5)+15)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function boom_napalmtnt(pos, time, player)
|
|
||||||
local id = minetest.get_node(pos).name
|
local id = minetest.get_node(pos).name
|
||||||
boom_napalmtnt_id(pos, time, player, id)
|
boom_napalmtnt_id(pos, time, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function boom_napalmtnt_id(pos, time, player, id)
|
function boom_napalmtnt_id(pos, time, id)
|
||||||
minetest.after(time, function(pos)
|
minetest.after(time, function(pos)
|
||||||
|
|
||||||
local tnt_range = tnt_tables[id].r * 2
|
local tnt_range = tnt_tables[id].r * 2
|
||||||
|
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
pr = get_tnt_random(pos)
|
|
||||||
minetest.sound_play("napalmtnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
|
minetest.sound_play("napalmtnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
|
||||||
|
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
@ -154,157 +130,22 @@ function boom_napalmtnt_id(pos, time, player, id)
|
||||||
local nodename = minetest.get_node(p).name
|
local nodename = minetest.get_node(p).name
|
||||||
if is_tnt(nodename)==true then
|
if is_tnt(nodename)==true then
|
||||||
minetest.set_node(p,{name="fire:basic_flame"})
|
minetest.set_node(p,{name="fire:basic_flame"})
|
||||||
boom_napalmtnt_id(p, 0.5, player, nodename) -- was {x=p.x, y=p.y, z=p.z}
|
boom_napalmtnt_id(p, 0.5, nodename) -- was {x=p.x, y=p.y, z=p.z}
|
||||||
else
|
else
|
||||||
minetest.set_node(p,{name="fire:basic_flame"})
|
minetest.set_node(p,{name="fire:basic_flame"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.add_particlespawner(
|
|
||||||
100, --amount
|
|
||||||
1, --time
|
|
||||||
{x=pos.x-(tnt_range / 2), y=pos.y-(tnt_range / 2), z=pos.z-(tnt_range / 2)}, --minpos
|
|
||||||
{x=pos.x+(tnt_range / 2), y=pos.y+(tnt_range / 2), z=pos.z+(tnt_range / 2)}, --maxpos
|
|
||||||
{x=-0, y=-0, z=-0}, --minvel
|
|
||||||
{x=0, y=0, z=0}, --maxvel
|
|
||||||
{x=-0.5,y=5,z=-0.5}, --minacc
|
|
||||||
{x=0.5,y=5,z=0.5}, --maxacc
|
|
||||||
0.1, --minexptime
|
|
||||||
1, --maxexptime
|
|
||||||
8, --minsize
|
|
||||||
15, --maxsize
|
|
||||||
true, --collisiondetection
|
|
||||||
"napalmtnt_smoke.png" --texture
|
|
||||||
)
|
|
||||||
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
|
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
|
||||||
end, pos)
|
end, pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------- GUNPOWDER -------------------
|
--------------------- GUNPOWDER -------------------
|
||||||
|
|
||||||
|
minetest.register_craftitem("napalmtnt:gunpowder", {
|
||||||
function burn(pos, player)
|
|
||||||
local nodename = minetest.get_node(pos).name
|
|
||||||
if strs:starts(nodename, "napalmtnt:tnt") then
|
|
||||||
minetest.sound_play("napalmtnt_ignite", {pos=pos})
|
|
||||||
boom_napalmtnt(pos, 1, player)
|
|
||||||
minetest.set_node(pos, {name=minetest.get_node(pos).name.."_burning"})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if nodename ~= "napalmtnt:gunpowder" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.sound_play("napalmtnt_gunpowder_burning", {pos=pos, gain=2})
|
|
||||||
minetest.set_node(pos, {name="napalmtnt:gunpowder_burning"})
|
|
||||||
|
|
||||||
minetest.after(1, function(pos)
|
|
||||||
if minetest.get_node(pos).name ~= "napalmtnt:gunpowder_burning" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.after(0.5, function(pos)
|
|
||||||
minetest.remove_node(pos)
|
|
||||||
end, {x=pos.x, y=pos.y, z=pos.z})
|
|
||||||
for dx=-1,1 do
|
|
||||||
for dz=-1,1 do
|
|
||||||
for dy=-1,1 do
|
|
||||||
pos.x = pos.x+dx
|
|
||||||
pos.y = pos.y+dy
|
|
||||||
pos.z = pos.z+dz
|
|
||||||
|
|
||||||
if not (math.abs(dx) == 1 and math.abs(dz) == 1) then
|
|
||||||
if dy == 0 then
|
|
||||||
burn({x=pos.x, y=pos.y, z=pos.z}, player)
|
|
||||||
else
|
|
||||||
if math.abs(dx) == 1 or math.abs(dz) == 1 then
|
|
||||||
burn({x=pos.x, y=pos.y, z=pos.z}, player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pos.x = pos.x-dx
|
|
||||||
pos.y = pos.y-dy
|
|
||||||
pos.z = pos.z-dz
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end, pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("napalmtnt:gunpowder", {
|
|
||||||
description = "Gun Powder",
|
description = "Gun Powder",
|
||||||
drawtype = "raillike",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
tiles = {"napalmtnt_gunpowder.png",},
|
|
||||||
inventory_image = "napalmtnt_gunpowder_inventory.png",
|
inventory_image = "napalmtnt_gunpowder_inventory.png",
|
||||||
wield_image = "napalmtnt_gunpowder_inventory.png",
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
groups = {dig_immediate=2,attached_node=1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
|
||||||
if puncher:get_wielded_item():get_name() == "default:torch" then
|
|
||||||
burn(pos, puncher)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("napalmtnt:gunpowder_burning", {
|
|
||||||
drawtype = "raillike",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
light_source = 5,
|
|
||||||
tiles = {{name="napalmtnt_gunpowder_burning_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1}}},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
drop = "",
|
|
||||||
groups = {dig_immediate=2,attached_node=1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
local tnt_plus_gunpowder = {"napalmtnt:gunpowder"}
|
|
||||||
for name,data in pairs(tnt_tables) do
|
|
||||||
tnt_plus_gunpowder[#tnt_plus_gunpowder+1] = name
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = tnt_plus_gunpowder,
|
|
||||||
neighbors = {"fire:basic_flame"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 10,
|
|
||||||
action = function(pos, node)
|
|
||||||
if tnt_tables[node.name]~=nil then
|
|
||||||
boom_napalmtnt({x=pos.x, y=pos.y, z=pos.z}, 0)
|
|
||||||
else
|
|
||||||
burn(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = tnt_plus_gunpowder,
|
|
||||||
neighbors = {"tnt:gunpowder"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 10,
|
|
||||||
action = function(pos, node)
|
|
||||||
if tnt_tables[node.name]~=nil then
|
|
||||||
boom_napalmtnt({x=pos.x, y=pos.y, z=pos.z}, 0)
|
|
||||||
else
|
|
||||||
burn(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -313,7 +154,3 @@ minetest.register_craft({
|
||||||
recipe = {"default:coal_lump", "default:coal_lump", "default:dirt"}
|
recipe = {"default:coal_lump", "default:coal_lump", "default:dirt"}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
tnt_c_air = minetest.get_content_id("air")
|
|
||||||
tnt_c_fire = minetest.get_content_id("fire:basic_flame")
|
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,25 @@
|
||||||
local tnt_tables = {["neutrontnt:tnt1"] = {r=2},
|
local tnt_tables = {["neutrontnt:tnt1"] = {r=1},
|
||||||
["neutrontnt:tnt2"] = {r=4},
|
["neutrontnt:tnt2"] = {r=2},
|
||||||
["neutrontnt:tnt3"] = {r=6},
|
["neutrontnt:tnt3"] = {r=3},
|
||||||
["neutrontnt:tnt4"] = {r=8},
|
["neutrontnt:tnt4"] = {r=4},
|
||||||
["neutrontnt:tnt5"] = {r=10},
|
["neutrontnt:tnt5"] = {r=5},
|
||||||
["neutrontnt:tnt6"] = {r=12},
|
["neutrontnt:tnt6"] = {r=7},
|
||||||
["neutrontnt:tnt7"] = {r=14},
|
["neutrontnt:tnt7"] = {r=9},
|
||||||
["neutrontnt:tnt8"] = {r=16},
|
["neutrontnt:tnt8"] = {r=11},
|
||||||
["neutrontnt:tnt9"] = {r=18},
|
["neutrontnt:tnt9"] = {r=13},
|
||||||
["neutrontnt:tnt10"] = {r=20},
|
["neutrontnt:tnt10"] = {r=15},
|
||||||
["neutrontnt:tnt11"] = {r=22},
|
["neutrontnt:tnt11"] = {r=20},
|
||||||
["neutrontnt:tnt12"] = {r=25},
|
["neutrontnt:tnt12"] = {r=25},
|
||||||
["neutrontnt:tnt13"] = {r=30},
|
["neutrontnt:tnt13"] = {r=30},
|
||||||
["neutrontnt:tnt14"] = {r=35},
|
["neutrontnt:tnt14"] = {r=35},
|
||||||
["neutrontnt:tnt15"] = {r=40},
|
["neutrontnt:tnt15"] = {r=40},
|
||||||
["neutrontnt:tnt16"] = {r=45},
|
["neutrontnt:tnt16"] = {r=50},
|
||||||
["neutrontnt:tnt17"] = {r=50},
|
["neutrontnt:tnt17"] = {r=60},
|
||||||
["neutrontnt:tnt18"] = {r=55},
|
["neutrontnt:tnt18"] = {r=70},
|
||||||
["neutrontnt:tnt19"] = {r=60},
|
["neutrontnt:tnt19"] = {r=85},
|
||||||
["neutrontnt:tnt20"] = {r=65},
|
["neutrontnt:tnt20"] = {r=100},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tnt = {}
|
|
||||||
tnt.force = {}
|
|
||||||
tnt.accl = {}
|
|
||||||
|
|
||||||
local function is_tnt(name)
|
local function is_tnt(name)
|
||||||
if tnt_tables[name]~=nil then return true end
|
if tnt_tables[name]~=nil then return true end
|
||||||
return false
|
return false
|
||||||
|
@ -44,18 +39,12 @@ end
|
||||||
|
|
||||||
local animated_tnt_texture = combine_texture(16, 4, "tnt_top.png", "neutrontnt_top_burning_animated.png")
|
local animated_tnt_texture = combine_texture(16, 4, "tnt_top.png", "neutrontnt_top_burning_animated.png")
|
||||||
|
|
||||||
tnt_c_tnt = {}
|
|
||||||
tnt_c_tnt_burning = {}
|
|
||||||
tnt_types_int = {}
|
|
||||||
|
|
||||||
for name,data in pairs(tnt_tables) do
|
for name,data in pairs(tnt_tables) do
|
||||||
|
|
||||||
tnt_types_int[#tnt_types_int] = name
|
|
||||||
|
|
||||||
minetest.register_node(name, {
|
minetest.register_node(name, {
|
||||||
description = "TNT ("..name..")",
|
description = "TNT ("..name..")",
|
||||||
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
||||||
groups = {dig_immediate=2, mesecon=2},
|
groups = {dig_immediate=2, mesecon=2, not_in_creative_inventory=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher)
|
||||||
|
@ -66,7 +55,7 @@ for name,data in pairs(tnt_tables) do
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.sound_play("neutrontnt_ignite", {pos=pos})
|
minetest.sound_play("neutrontnt_ignite", {pos=pos})
|
||||||
boom_neutrontnt(pos, 4, puncher)
|
boom_neutrontnt(pos, 4)
|
||||||
minetest.set_node(pos, {name=name.."_burning"})
|
minetest.set_node(pos, {name=name.."_burning"})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -101,32 +90,19 @@ for name,data in pairs(tnt_tables) do
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
tnt_c_tnt[#tnt_c_tnt + 1] = minetest.get_content_id(name)
|
|
||||||
tnt_c_tnt_burning[#tnt_c_tnt_burning + 1] = minetest.get_content_id(name.."_burning")
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function boom_neutrontnt(pos, time)
|
||||||
local function get_tnt_random(pos)
|
|
||||||
return PseudoRandom(math.abs(pos.x+pos.y*3+pos.z*5)+15)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function boom_neutrontnt(pos, time, player)
|
|
||||||
local id = minetest.get_node(pos).name
|
local id = minetest.get_node(pos).name
|
||||||
boom_neutrontnt_id(pos, time, player, id)
|
boom_neutrontnt_id(pos, time, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function boom_neutrontnt_id(pos, time, player, id)
|
function boom_neutrontnt_id(pos, time, id)
|
||||||
minetest.after(time, function(pos)
|
minetest.after(time, function(pos)
|
||||||
|
|
||||||
local tnt_range = tnt_tables[id].r * 2
|
local tnt_range = tnt_tables[id].r * 2
|
||||||
|
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
pr = get_tnt_random(pos)
|
|
||||||
minetest.sound_play("neutrontnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
|
minetest.sound_play("neutrontnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
|
||||||
|
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
@ -160,150 +136,15 @@ function boom_neutrontnt_id(pos, time, player, id)
|
||||||
|
|
||||||
local storedPoses = {}
|
local storedPoses = {}
|
||||||
|
|
||||||
minetest.add_particlespawner(
|
|
||||||
100, --amount
|
|
||||||
1, --time
|
|
||||||
{x=pos.x-(tnt_range / 2), y=pos.y-(tnt_range / 2), z=pos.z-(tnt_range / 2)}, --minpos
|
|
||||||
{x=pos.x+(tnt_range / 2), y=pos.y+(tnt_range / 2), z=pos.z+(tnt_range / 2)}, --maxpos
|
|
||||||
{x=-0, y=-0, z=-0}, --minvel
|
|
||||||
{x=0, y=0, z=0}, --maxvel
|
|
||||||
{x=-0.5,y=5,z=-0.5}, --minacc
|
|
||||||
{x=0.5,y=5,z=0.5}, --maxacc
|
|
||||||
0.1, --minexptime
|
|
||||||
1, --maxexptime
|
|
||||||
8, --minsize
|
|
||||||
15, --maxsize
|
|
||||||
true, --collisiondetection
|
|
||||||
"neutrontnt_smoke.png" --texture
|
|
||||||
)
|
|
||||||
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
|
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
|
||||||
end, pos)
|
end, pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------- GUNPOWDER -------------------
|
--------------------- GUNPOWDER -------------------
|
||||||
|
|
||||||
|
minetest.register_craftitem("neutrontnt:gunpowder", {
|
||||||
function burn(pos, player)
|
|
||||||
local nodename = minetest.get_node(pos).name
|
|
||||||
if strs:starts(nodename, "neutrontnt:tnt") then
|
|
||||||
minetest.sound_play("neutrontnt_ignite", {pos=pos})
|
|
||||||
boom_neutrontnt(pos, 1, player)
|
|
||||||
minetest.set_node(pos, {name=minetest.get_node(pos).name.."_burning"})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if nodename ~= "neutrontnt:gunpowder" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.sound_play("neutrontnt_gunpowder_burning", {pos=pos, gain=2})
|
|
||||||
minetest.set_node(pos, {name="neutrontnt:gunpowder_burning"})
|
|
||||||
|
|
||||||
minetest.after(1, function(pos)
|
|
||||||
if minetest.get_node(pos).name ~= "neutrontnt:gunpowder_burning" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.after(0.5, function(pos)
|
|
||||||
minetest.remove_node(pos)
|
|
||||||
end, {x=pos.x, y=pos.y, z=pos.z})
|
|
||||||
for dx=-1,1 do
|
|
||||||
for dz=-1,1 do
|
|
||||||
for dy=-1,1 do
|
|
||||||
pos.x = pos.x+dx
|
|
||||||
pos.y = pos.y+dy
|
|
||||||
pos.z = pos.z+dz
|
|
||||||
|
|
||||||
if not (math.abs(dx) == 1 and math.abs(dz) == 1) then
|
|
||||||
if dy == 0 then
|
|
||||||
burn({x=pos.x, y=pos.y, z=pos.z}, player)
|
|
||||||
else
|
|
||||||
if math.abs(dx) == 1 or math.abs(dz) == 1 then
|
|
||||||
burn({x=pos.x, y=pos.y, z=pos.z}, player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pos.x = pos.x-dx
|
|
||||||
pos.y = pos.y-dy
|
|
||||||
pos.z = pos.z-dz
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end, pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("neutrontnt:gunpowder", {
|
|
||||||
description = "Gun Powder",
|
description = "Gun Powder",
|
||||||
drawtype = "raillike",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
tiles = {"neutrontnt_gunpowder.png",},
|
|
||||||
inventory_image = "neutrontnt_gunpowder_inventory.png",
|
inventory_image = "neutrontnt_gunpowder_inventory.png",
|
||||||
wield_image = "neutrontnt_gunpowder_inventory.png",
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
groups = {dig_immediate=2,attached_node=1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
|
||||||
if puncher:get_wielded_item():get_name() == "default:torch" then
|
|
||||||
burn(pos, puncher)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("neutrontnt:gunpowder_burning", {
|
|
||||||
drawtype = "raillike",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
light_source = 5,
|
|
||||||
tiles = {{name="neutrontnt_gunpowder_burning_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1}}},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
|
||||||
},
|
|
||||||
drop = "",
|
|
||||||
groups = {dig_immediate=2,attached_node=1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
local tnt_plus_gunpowder = {"neutrontnt:gunpowder"}
|
|
||||||
for name,data in pairs(tnt_tables) do
|
|
||||||
tnt_plus_gunpowder[#tnt_plus_gunpowder+1] = name
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = tnt_plus_gunpowder,
|
|
||||||
neighbors = {"fire:basic_flame"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 10,
|
|
||||||
action = function(pos, node)
|
|
||||||
if tnt_tables[node.name]~=nil then
|
|
||||||
boom_neutrontnt({x=pos.x, y=pos.y, z=pos.z}, 0)
|
|
||||||
else
|
|
||||||
burn(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = tnt_plus_gunpowder,
|
|
||||||
neighbors = {"tnt:gunpowder"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 10,
|
|
||||||
action = function(pos, node)
|
|
||||||
if tnt_tables[node.name]~=nil then
|
|
||||||
boom_neutrontnt({x=pos.x, y=pos.y, z=pos.z}, 0)
|
|
||||||
else
|
|
||||||
burn(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -312,7 +153,3 @@ minetest.register_craft({
|
||||||
recipe = {"default:coal_lump", "default:gravel", "default:glass"}
|
recipe = {"default:coal_lump", "default:gravel", "default:glass"}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
tnt_c_air = minetest.get_content_id("air")
|
|
||||||
tnt_c_fire = minetest.get_content_id("fire:basic_flame")
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue