From 1f66bf54835747acc3934313db2e48abdd4fb041 Mon Sep 17 00:00:00 2001 From: Ginger88895 Date: Sun, 20 Sep 2015 11:18:35 +0000 Subject: [PATCH] Fix --- init.lua | 128 +++++++++---------------------------------------------- 1 file changed, 19 insertions(+), 109 deletions(-) diff --git a/init.lua b/init.lua index 41fab14..84c4a6d 100644 --- a/init.lua +++ b/init.lua @@ -43,55 +43,13 @@ local tnt_tables = {["bettertnt:tnt1"] = {r=6}, tnt = {} tnt.force = {} -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 +tnt.accl = {} local function is_tnt(name) if tnt_tables[name]~=nil then return true end return false 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 l = frame_count local px = 0 @@ -185,7 +143,7 @@ end function boom_id(pos, time, player, id) 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() pr = get_tnt_random(pos) @@ -220,91 +178,43 @@ function boom_id(pos, time, player, id) end end - local ents = {} local storedPoses = {} if id~="bettertnt:tnt1" then for dx=-tnt_range,tnt_range do for dz=-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) dist = dist^(1/2.0) - if dist < tnt_range and dist + 1 >= tnt_range and dist~=0 then - local dir = {x=dx, y=dy, z=dz} - --local totalnum = math.abs(dir.x)+math.abs(dir.y)+math.abs(dir.z) - --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) - ---------------------------------------- + if dist <= tnt_range then + --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 d_p_node = nodes[p_node] - local node = minetest.get_node(p) - ------------------------------------------------------------- - blast = blast - 1 - if tnt.accl[node.name]==true then - storedPoses[#storedPoses + 1] = {x=p.x, y=p.y, z=p.z} - local stored = minetest.get_meta(p):get_int("blast") or 0 - blast = blast + stored - end - if blast <= 0 then - if tnt.accl[node.name]==true then - minetest.get_meta(p):set_int("blast", tnt.force[node.name] + blast) - 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)