Fix
parent
fda2357d2c
commit
1f66bf5483
128
init.lua
128
init.lua
|
@ -43,55 +43,13 @@ local tnt_tables = {["bettertnt:tnt1"] = {r=6},
|
||||||
|
|
||||||
tnt = {}
|
tnt = {}
|
||||||
tnt.force = {}
|
tnt.force = {}
|
||||||
tnt.accl = {
|
tnt.accl = {}
|
||||||
["default:steelblock"] = true,
|
|
||||||
["default:obsidian"] = true,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
local function drop_item(pos, nodename, player, count)
|
|
||||||
local drop = minetest.get_node_drops(nodename)
|
|
||||||
|
|
||||||
for _,item in ipairs(drop) do
|
|
||||||
if type(item) == "string" then
|
|
||||||
item = ItemStack(item)
|
|
||||||
end
|
|
||||||
for i=1,item:get_count() do
|
|
||||||
item:set_count(item:get_count() * count)
|
|
||||||
local obj = minetest.add_item(pos, item)
|
|
||||||
if obj == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
obj:get_luaentity().collect = true
|
|
||||||
obj:setacceleration({x=0, y=-10, z=0})
|
|
||||||
obj:setvelocity({x=math.random(0,6)-3, y=10, z=math.random(0,6)-3})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
local function destroy(pos, player, ents)
|
|
||||||
local nodename = minetest.get_node(pos).name
|
|
||||||
--local p_pos = area:index(pos.x, pos.y, pos.z)
|
|
||||||
--if nodes[p_pos] ~= tnt_c_air then
|
|
||||||
if nodename~="air" then
|
|
||||||
if tnt_tables[nodename]==nil then
|
|
||||||
ents[nodename] = (ents[nodename] or 0) + 1
|
|
||||||
end
|
|
||||||
if minetest.registered_nodes[nodename].groups.flammable ~= nil then
|
|
||||||
minetest.set_node(pos, {name = "fire:basic_flame"})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.remove_node(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function combine_texture(texture_size, frame_count, texture, ani_texture)
|
local function combine_texture(texture_size, frame_count, texture, ani_texture)
|
||||||
local l = frame_count
|
local l = frame_count
|
||||||
local px = 0
|
local px = 0
|
||||||
|
@ -185,7 +143,7 @@ end
|
||||||
function boom_id(pos, time, player, id)
|
function boom_id(pos, time, player, id)
|
||||||
minetest.after(time, function(pos)
|
minetest.after(time, function(pos)
|
||||||
|
|
||||||
local tnt_range = tnt_tables[id].r * 6
|
local tnt_range = tnt_tables[id].r * 2
|
||||||
|
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
pr = get_tnt_random(pos)
|
pr = get_tnt_random(pos)
|
||||||
|
@ -220,91 +178,43 @@ function boom_id(pos, time, player, id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ents = {}
|
|
||||||
local storedPoses = {}
|
local storedPoses = {}
|
||||||
|
|
||||||
if id~="bettertnt:tnt1" then
|
if id~="bettertnt:tnt1" then
|
||||||
for dx=-tnt_range,tnt_range do
|
for dx=-tnt_range,tnt_range do
|
||||||
for dz=-tnt_range,tnt_range do
|
for dz=-tnt_range,tnt_range do
|
||||||
for dy=-tnt_range,tnt_range do
|
for dy=-tnt_range,tnt_range do
|
||||||
--local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
local dist = (dx^2) + (dy^2) + (dz^2)
|
local dist = (dx^2) + (dy^2) + (dz^2)
|
||||||
dist = dist^(1/2.0)
|
dist = dist^(1/2.0)
|
||||||
if dist < tnt_range and dist + 1 >= tnt_range and dist~=0 then
|
if dist <= tnt_range then
|
||||||
local dir = {x=dx, y=dy, z=dz}
|
--local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
||||||
--local totalnum = math.abs(dir.x)+math.abs(dir.y)+math.abs(dir.z)
|
--vector.add(p, dir)
|
||||||
--dir = vector.normalize(dir)--vector.divide(dir, vector.new(totalnum, totalnum, totalnum))
|
----------------------------------------
|
||||||
dir.x = dir.x / dist
|
|
||||||
dir.y = dir.y / dist
|
|
||||||
dir.z = dir.z / dist
|
|
||||||
--local p = {x=pos.x, y=pos.y, z=pos.z} -- {x=0,y=0,z=0}--
|
|
||||||
local blast = tnt_range / 3
|
|
||||||
for i=1, dist do
|
|
||||||
-- i = i - 0.5
|
|
||||||
local pp = {x=dir.x*i, y=dir.y*i, z=dir.z*i}
|
|
||||||
local p = vector.add(pp, pos)
|
|
||||||
p.x = math.floor(p.x)
|
|
||||||
p.y = math.floor(p.y)
|
|
||||||
p.z = math.floor(p.z)
|
|
||||||
for i=1, #storedPoses do
|
|
||||||
if p.x==storedPoses[i].x and p.y==storedPoses[i].y and p.z==storedPoses[i].z then
|
|
||||||
--print("p: "..dump(p) .. " storedPoses: "..dump(storedPoses[i]))
|
|
||||||
p = nil
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if p==nil then break end
|
|
||||||
--local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
|
||||||
--vector.add(p, dir)
|
|
||||||
----------------------------------------
|
|
||||||
-- local p_node = area:index(p.x, p.y, p.z)
|
-- local p_node = area:index(p.x, p.y, p.z)
|
||||||
-- local d_p_node = nodes[p_node]
|
-- local d_p_node = nodes[p_node]
|
||||||
local node = minetest.get_node(p)
|
local node = minetest.get_node(p)
|
||||||
-------------------------------------------------------------
|
local nodename = node.name
|
||||||
blast = blast - 1
|
if is_tnt(nodename)==true then
|
||||||
if tnt.accl[node.name]==true then
|
minetest.remove_node(p)
|
||||||
storedPoses[#storedPoses + 1] = {x=p.x, y=p.y, z=p.z}
|
boom_id(p, 0.5, player, nodename) -- was {x=p.x, y=p.y, z=p.z}
|
||||||
local stored = minetest.get_meta(p):get_int("blast") or 0
|
elseif nodename~="air" then
|
||||||
blast = blast + stored
|
--if math.abs(dx)<tnt_range and math.abs(dy)<tnt_range and math.abs(dz)<tnt_range then
|
||||||
end
|
minetest.remove_node(p)
|
||||||
if blast <= 0 then
|
--elseif pr:next(1,5) <= 4 then
|
||||||
if tnt.accl[node.name]==true then
|
-- destroy(p, player, ents)
|
||||||
minetest.get_meta(p):set_int("blast", tnt.force[node.name] + blast)
|
--end
|
||||||
end
|
|
||||||
break
|
|
||||||
end
|
|
||||||
-------------------------------------------------------------
|
|
||||||
-- if d_p_node == tnt_c_tnt
|
|
||||||
-- or d_p_node == tnt_c_tnt_burning then
|
|
||||||
if is_tnt(node.name)==true then
|
|
||||||
--nodes[p_node] = tnt_c_tnt
|
|
||||||
minetest.remove_node(p)
|
|
||||||
boom_id(p, 0.5, player, node.name) -- was {x=p.x, y=p.y, z=p.z}
|
|
||||||
elseif not (d_p_node == tnt_c_fire) then
|
|
||||||
--if math.abs(dx)<tnt_range and math.abs(dy)<tnt_range and math.abs(dz)<tnt_range then
|
|
||||||
destroy(p, player, ents)
|
|
||||||
--elseif pr:next(1,5) <= 4 then
|
|
||||||
-- destroy(p, player, ents)
|
|
||||||
--end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
--------------------------------------------
|
|
||||||
end
|
end
|
||||||
--------------------------------------------
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, val in pairs(ents) do
|
|
||||||
drop_item(pos, name, player, val)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.add_particlespawner(
|
minetest.add_particlespawner(
|
||||||
tnt_range * 100, --amount
|
100, --amount
|
||||||
1, --time
|
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)}, --minpos
|
||||||
{x=pos.x+(tnt_range / 2), y=pos.y+(tnt_range / 2), z=pos.z+(tnt_range / 2)}, --maxpos
|
{x=pos.x+(tnt_range / 2), y=pos.y+(tnt_range / 2), z=pos.z+(tnt_range / 2)}, --maxpos
|
||||||
|
|
Loading…
Reference in New Issue