From 94cf84f7322c3b623281e384a4e0dc68c3b8bcd6 Mon Sep 17 00:00:00 2001 From: kaadmy Date: Thu, 24 Sep 2015 13:33:53 -0700 Subject: [PATCH] removed legacy stuff and made tnt have no damage when near water --- mods/default/crafting.lua | 19 +++++-- mods/default/furnace.lua | 2 - mods/default/nodes.lua | 108 ++++++++++++++++++-------------------- mods/tnt/init.lua | 25 +++++---- 4 files changed, 80 insertions(+), 74 deletions(-) diff --git a/mods/default/crafting.lua b/mods/default/crafting.lua index 22d0d48..c6ed14b 100644 --- a/mods/default/crafting.lua +++ b/mods/default/crafting.lua @@ -830,15 +830,24 @@ minetest.register_tool( if pointed_thing.type ~= "node" then return end local pos = pointed_thing.under + local node = minetest.get_node(pointed_thing.under) + local nodename = node.name - if minetest.get_node(pointed_thing.under).name == "default:torch_weak" then - local n = minetest.get_node(pointed_thing.under) + if nodename == "default:torch_weak" then + local n = minetest.get_node(pos) minetest.set_node(pos, {name = "default:torch", param = n.param, param2 = n.param2}) itemstack:add_wear(800) - elseif minetest.get_node(pointed_thing.under).name == "default:torch_dead" then - local n = minetest.get_node(pointed_thing.under) + elseif nodename == "default:torch_dead" then + local n = minetest.get_node(pos) minetest.set_node(pos, {name = "default:torch_weak", param = n.param, param2 = n.param2}) - itemstack:add_wear(1300) + itemstack:add_wear(800) + elseif nodename == "tnt:tnt" then + local y = minetest.registered_nodes["tnt:tnt"] + if y ~= nil then + y.on_punch(pos, node, user) + + itemstack:add_wear(800) + end end return itemstack diff --git a/mods/default/furnace.lua b/mods/default/furnace.lua index d136f3c..9e985af 100644 --- a/mods/default/furnace.lua +++ b/mods/default/furnace.lua @@ -58,7 +58,6 @@ minetest.register_node( "default_furnace_sides.png", "default_furnace_sides.png", "default_furnace_front.png"}, paramtype2 = "facedir", groups = {cracky = 2}, - legacy_facedir_simple = true, is_ground_content = false, sounds = default.node_sound_stone_defaults(), on_construct = function(pos) @@ -95,7 +94,6 @@ minetest.register_node( light_source = 8, drop = "default:furnace", groups = {cracky = 2}, - legacy_facedir_simple = true, is_ground_content = false, sounds = default.node_sound_stone_defaults(), on_construct = function(pos) diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index 6552351..9f032d4 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -704,7 +704,58 @@ minetest.register_node( wall_side = {-0.5, -8/16, -0.1, -0.5+4/16, 0, 0.1}, }, groups = {choppy=2, dig_immediate=3, attached_node=1}, - legacy_wallmounted = true, + sounds = default.node_sound_defaults(), + }) + +minetest.register_node( + "default:torch_weak", + { + description = "Weak Torch", + drawtype = "nodebox", + tiles ={ + { + name = "default_torch_3d_ends.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 1.0, + }, + }, + { + name = "default_torch_3d_ends.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 1.0, + }, + }, + { + name = "default_torch_3d.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 1.0, + }, + }, + }, + inventory_image = "default_torch.png", + wield_image = "default_torch.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + is_ground_content = false, + walkable = false, + light_source = default.LIGHT_MAX-4, + node_box = { + type = "wallmounted", + wall_top = {-2/16, 0, -2/16, 2/16, 0.5, 2/16}, + wall_bottom = {-2/16, -0.5, -2/16, 2/16, 0, 2/16}, + wall_side = {-0.5, -8/16, -0.1, -0.5+4/16, 0, 0.1}, + }, + groups = {choppy=2, dig_immediate=3, attached_node=1}, sounds = default.node_sound_defaults(), }) @@ -757,59 +808,6 @@ minetest.register_node( wall_side = {-0.5, -8/16, -0.1, -0.5+4/16, 0, 0.1}, }, groups = {choppy=2, dig_immediate=3, attached_node=1}, - legacy_wallmounted = true, - sounds = default.node_sound_defaults(), - }) -minetest.register_node( - "default:torch_weak", - { - description = "Weak Torch", - drawtype = "nodebox", - tiles ={ - { - name = "default_torch_3d_ends.png", - animation = { - type = "vertical_frames", - aspect_w = 16, - aspect_h = 16, - length = 1.0, - }, - }, - { - name = "default_torch_3d_ends.png", - animation = { - type = "vertical_frames", - aspect_w = 16, - aspect_h = 16, - length = 1.0, - }, - }, - { - name = "default_torch_3d.png", - animation = { - type = "vertical_frames", - aspect_w = 16, - aspect_h = 16, - length = 1.0, - }, - }, - }, - inventory_image = "default_torch.png", - wield_image = "default_torch.png", - paramtype = "light", - paramtype2 = "wallmounted", - sunlight_propagates = true, - is_ground_content = false, - walkable = false, - light_source = default.LIGHT_MAX-4, - node_box = { - type = "wallmounted", - wall_top = {-2/16, 0, -2/16, 2/16, 0.5, 2/16}, - wall_bottom = {-2/16, -0.5, -2/16, 2/16, 0, 2/16}, - wall_side = {-0.5, -8/16, -0.1, -0.5+4/16, 0, 0.1}, - }, - groups = {choppy=2, dig_immediate=3, attached_node=1}, - legacy_wallmounted = true, sounds = default.node_sound_defaults(), }) @@ -833,7 +831,6 @@ minetest.register_node( wall_side = {-0.5, -0.5+(4/16), -0.5+(1/16), -0.5+(1/16), 0.5-(4/16), 0.5-(1/16)}, }, groups = {choppy=2,dig_immediate=2,attached_node=1}, - legacy_wallmounted = true, sounds = default.node_sound_defaults(), on_construct = function(pos) --local n = minetest.get_node(pos) @@ -939,7 +936,6 @@ minetest.register_node( "default_chest_sides.png", "default_chest_sides.png", "default_chest_front.png"}, paramtype2 = "facedir", groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, - legacy_facedir_simple = true, is_ground_content = false, sounds = default.node_sound_wood_defaults(), on_construct = function(pos) diff --git a/mods/tnt/init.lua b/mods/tnt/init.lua index 6217627..59870f2 100644 --- a/mods/tnt/init.lua +++ b/mods/tnt/init.lua @@ -111,6 +111,9 @@ end local function entity_physics(pos, radius) -- Make the damage radius larger than the destruction radius radius = radius * 2 + + local no_water = (minetest.find_node_near(pos, 2, {"default:water_source"}) == nil) + local objs = minetest.get_objects_inside_radius(pos, radius) for _, obj in pairs(objs) do local obj_pos = obj:getpos() @@ -122,8 +125,10 @@ local function entity_physics(pos, radius) obj_vel, radius * 10)) end - local damage = (4 / dist) * radius - obj:set_hp(obj:get_hp() - damage) + if no_water then + local damage = (4 / dist) * radius + obj:set_hp(obj:get_hp() - damage) + end end end @@ -151,7 +156,7 @@ local function burn(pos) if name == "tnt:tnt" then minetest.sound_play("tnt_ignite", {pos=pos}) minetest.set_node(pos, {name="tnt:tnt_burning"}) - minetest.get_node_timer(pos):start(1) + minetest.get_node_timer(pos):start(2) end end @@ -195,8 +200,7 @@ end local function boom(pos) minetest.sound_play("tnt_explode", {pos=pos, gain=1.5, max_hear_distance=2*64}) - minetest.set_node(pos, {name="air"}) - minetest.get_node_timer(pos):start(0.5) + minetest.remove_node(pos) local drops = explode(pos, radius) entity_physics(pos, radius) @@ -215,16 +219,15 @@ minetest.register_node( on_punch = function(pos, node, puncher) local itemname = puncher:get_wielded_item():get_name() - if itemname == "default:torch" or itemname == "default:torch_weak" or itemname == "default:flint_and_steel" then - minetest.sound_play("tnt_ignite", {pos=pos}) - minetest.set_node(pos, {name="tnt:tnt_burning"}) - minetest.get_node_timer(pos):start(4) + if itemname == "default:torch" + or itemname == "default:torch_weak" + or itemname == "default:flint_and_steel" then + burn(pos) end end, on_blast = function(pos, intensity) burn(pos) end, - mesecons = {effector = {action_on = boom}}, }) minetest.register_node( @@ -254,7 +257,7 @@ minetest.register_craft( output = "tnt:tnt", recipe = { {"", "group:planks", ""}, - {"group:planks", "default:torch", "group:planks"}, + {"group:planks", "default:flint_and_steel", "group:planks"}, {"", "group:planks", ""} } })