From 9e7a525a0a192f9df09b954d6bc784488e2a63d8 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 18:45:11 +0100 Subject: [PATCH] make snowballs activate target --- mods/ITEMS/REDSTONE/mcl_target/init.lua | 1 - mods/ITEMS/mcl_throwing/mod.conf | 2 +- mods/ITEMS/mcl_throwing/register.lua | 5 +++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mcl_target/init.lua b/mods/ITEMS/REDSTONE/mcl_target/init.lua index 3aeadbfc9..30888204e 100644 --- a/mods/ITEMS/REDSTONE/mcl_target/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_target/init.lua @@ -3,7 +3,6 @@ local S = minetest.get_translator("mcl_target") mcl_target = {} function mcl_target.hit(pos, time) - minetest.log("error", "Hello") minetest.set_node(pos, {name="mcl_target:target_on"}) mesecon.receptor_on(pos, mesecon.rules.alldirs) diff --git a/mods/ITEMS/mcl_throwing/mod.conf b/mods/ITEMS/mcl_throwing/mod.conf index 60d3e31a7..18248e76f 100644 --- a/mods/ITEMS/mcl_throwing/mod.conf +++ b/mods/ITEMS/mcl_throwing/mod.conf @@ -1,3 +1,3 @@ name = mcl_throwing depends = mcl_colors -optional_depends = mcl_core, mcl_mobitems, doc +optional_depends = mcl_core, mcl_mobitems, doc, mcl_target diff --git a/mods/ITEMS/mcl_throwing/register.lua b/mods/ITEMS/mcl_throwing/register.lua index ec11f86c7..b4a535b17 100644 --- a/mods/ITEMS/mcl_throwing/register.lua +++ b/mods/ITEMS/mcl_throwing/register.lua @@ -3,6 +3,8 @@ local S = minetest.get_translator(minetest.get_current_modname()) local math = math local vector = vector +local mod_target = minetest.get_modpath("mcl_target") + -- The snowball entity local snowball_ENTITY={ physical = false, @@ -111,6 +113,9 @@ local function snowball_on_step(self, dtime) minetest.sound_play("mcl_throwing_snowball_impact_hard", { pos = pos, max_hear_distance=16, gain=0.7 }, true) snowball_particles(self._lastpos, vel) self.object:remove() + if mod_target and node.name == "mcl_target:target_off" then + mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks + end return end end