From 25f9baff2c91f842d04664b3b5b2881c3d98810e 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 3aeadbfc9d..30888204e8 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 60d3e31a79..18248e76f7 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 ec11f86c72..b4a535b175 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