From 95964692ebba54e51fa786cf8c92554458997e18 Mon Sep 17 00:00:00 2001 From: HeroOfTheWinds Date: Mon, 19 May 2014 14:35:32 -1000 Subject: [PATCH] Make torches go out in the vacuum Torches are extinguished next to vacuum nodes. Rightclick while holding a stick to relight, provided there is no vacuum near it. --- mods/moontest/nodes.lua | 61 ++++++++++++++++++ .../textures/moontest_unlit_torch.png | Bin 0 -> 230 bytes .../moontest_unlit_torch_on_ceiling.png | Bin 0 -> 191 bytes .../moontest_unlit_torch_on_floor.png | Bin 0 -> 289 bytes 4 files changed, 61 insertions(+) create mode 100644 mods/moontest/textures/moontest_unlit_torch.png create mode 100644 mods/moontest/textures/moontest_unlit_torch_on_ceiling.png create mode 100644 mods/moontest/textures/moontest_unlit_torch_on_floor.png diff --git a/mods/moontest/nodes.lua b/mods/moontest/nodes.lua index 764133de..e891d116 100644 --- a/mods/moontest/nodes.lua +++ b/mods/moontest/nodes.lua @@ -384,7 +384,68 @@ minetest.register_node("moontest:light_stick", { sounds = default.node_sound_defaults(), }) +--define unlit torch +minetest.register_node("moontest:unlit_torch", { + description = "Unlit Torch", + drawtype = "torchlike", + tiles = {"moontest_unlit_torch_on_floor.png", "moontest_unlit_torch_on_ceiling.png", "moontest_unlit_torch.png"}, + inventory_image = "default_torch_on_floor.png", + wield_image = "moontest_unlit_torch_on_floor.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + is_ground_content = false, + walkable = false, + light_source = 0, + selection_box = { + type = "wallmounted", + wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1}, + wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, + wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1}, + }, + groups = {choppy=2,dig_immediate=3,flammable=1,attached_node=1}, + legacy_wallmounted = true, + sounds = default.node_sound_defaults(), + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + --check if the player is holding a stick to relight it + if player:get_wielded_item():get_name() == "default:stick" then + --store whether the area is in a vacuum + local is_vacuum = false + --check in a three-node cube around the torch for vacuum + for x=-1,1 do + for y=-1,1 do + for z=-1,1 do + local vpos = {x=pos.x+x,y=pos.y+y,z=pos.z+z} + --this is a vacuum! + if minetest.get_node(vpos).name == "moontest:vacuum" then + is_vacuum = true + break + end + end + end + end + --if those loops didn't find vacuum, assume air + if is_vacuum ~= true then + local par2 = node.param2 --store the rotation of the old torch + minetest.set_node(pos, {name="default:torch", param2=par2}) + else + print("this is a vacuum!") --you idiot! + end + end + end, +}) +--ABM to extinguish torches in vacuum +minetest.register_abm({ + nodenames = {"default:torch"}, + neighbors = {"moontest:vacuum"}, + interval = 1.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local p2 = node.param2 --store rotation of old torch + minetest.set_node(pos, {name = "moontest:unlit_torch", param2=p2}) + end, +}) -- Items diff --git a/mods/moontest/textures/moontest_unlit_torch.png b/mods/moontest/textures/moontest_unlit_torch.png new file mode 100644 index 0000000000000000000000000000000000000000..d382d39e569b569814f3196d4ed79176cb5dd0c2 GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=DjSL74G){)!Z!AbW|YuPggKRuKjkZR^!bn1MpYo-U3d7N@UH+Q@s@frr_jzh8-e zap=9z7OPWcWQgwyxFw>`&bY`e;2^W6K%MO@^P`il*EMewZLoDnkzKA_#JeE!(6+zV z+a*@>PkF*R+1M)YOb~<2O>brm8Ae@pHi7DcYi@TIh*Y0vWH|rFY3<>Q58gj#5}vO8 Vw{p^p&p_)LJYD@<);T3K0RR!7P1^tf literal 0 HcmV?d00001 diff --git a/mods/moontest/textures/moontest_unlit_torch_on_ceiling.png b/mods/moontest/textures/moontest_unlit_torch_on_ceiling.png new file mode 100644 index 0000000000000000000000000000000000000000..7f4677ed6d5102df1a13b5813764a43e94780e19 GIT binary patch literal 191 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=DjSL74G){)!Z!AbW|YuPggKRuKkPl}-E|mw`e)o-U3d7N_6#ZR9y{DD1C%X<6&nje^ynGffC#e8@#&&+JCZOj_?