From 4bd91750bc04250fd10f41c26a1b6ccd36fab7ba Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 17:38:04 +0100 Subject: [PATCH 01/11] add target with API --- mods/ITEMS/REDSTONE/mcl_target/init.lua | 58 ++++++++++++++++++ mods/ITEMS/REDSTONE/mcl_target/mod.conf | 3 + .../textures/mcl_target_target_side.png | Bin 0 -> 752 bytes .../textures/mcl_target_target_top.png | Bin 0 -> 752 bytes 4 files changed, 61 insertions(+) create mode 100644 mods/ITEMS/REDSTONE/mcl_target/init.lua create mode 100644 mods/ITEMS/REDSTONE/mcl_target/mod.conf create mode 100755 mods/ITEMS/REDSTONE/mcl_target/textures/mcl_target_target_side.png create mode 100755 mods/ITEMS/REDSTONE/mcl_target/textures/mcl_target_target_top.png diff --git a/mods/ITEMS/REDSTONE/mcl_target/init.lua b/mods/ITEMS/REDSTONE/mcl_target/init.lua new file mode 100644 index 000000000..3aeadbfc9 --- /dev/null +++ b/mods/ITEMS/REDSTONE/mcl_target/init.lua @@ -0,0 +1,58 @@ +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) + + local timer = minetest.get_node_timer(pos) + timer:start(time) +end + +minetest.register_node("mcl_target:target_off", { + description = S("Target"), + --_tt_help = S(""), + --_doc_items_longdesc = longdesc, + --_doc_items_usagehelp = buttonuse, + tiles = {"mcl_target_target_top.png", "mcl_target_target_top.png", "mcl_target_target_side.png"}, + groups = {hoey = 1}, + sounds = mcl_sounds.node_sound_dirt_defaults({ + footstep = {name="default_grass_footstep", gain=0.1}, + }), + mesecons = { + receptor = { + state = mesecon.state.off, + rules = mesecon.rules.alldirs, + }, + }, + _mcl_blast_resistance = 0.5, + _mcl_hardness = 0.5, +}) + +minetest.register_node("mcl_target:target_on", { + description = S("Target"), + _doc_items_create_entry = false, + tiles = {"mcl_target_target_top.png", "mcl_target_target_top.png", "mcl_target_target_side.png"}, + groups = {hoey = 1, not_in_creative_inventory = 1}, + drop = "mcl_target:target_off", + sounds = mcl_sounds.node_sound_dirt_defaults({ + footstep = {name="default_grass_footstep", gain=0.1}, + }), + on_timer = function(pos, elapsed) + local node = minetest.get_node(pos) + if node.name == "mcl_target:target_on" then --has not been dug + minetest.set_node(pos, {name="mcl_target:target_off"}) + mesecon.receptor_off(pos, mesecon.rules.alldirs) + end + end, + mesecons = { + receptor = { + state = mesecon.state.on, + rules = mesecon.rules.alldirs, + }, + }, + _mcl_blast_resistance = 0.5, + _mcl_hardness = 0.5, +}) diff --git a/mods/ITEMS/REDSTONE/mcl_target/mod.conf b/mods/ITEMS/REDSTONE/mcl_target/mod.conf new file mode 100644 index 000000000..16f70ed12 --- /dev/null +++ b/mods/ITEMS/REDSTONE/mcl_target/mod.conf @@ -0,0 +1,3 @@ +name = mcl_target +author = AFCMS +depends = mesecons, mcl_sounds \ No newline at end of file diff --git a/mods/ITEMS/REDSTONE/mcl_target/textures/mcl_target_target_side.png b/mods/ITEMS/REDSTONE/mcl_target/textures/mcl_target_target_side.png new file mode 100755 index 0000000000000000000000000000000000000000..286f7767edfb3060af8b57a0521c6930b36bbf36 GIT binary patch literal 752 zcmVPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01F8K01F8L68c9z00007bV*G`2jmA2 z4>=XXM-d(X00MAHL_t(I%YBp2OVe=}$6vFr!@i&SZLWXM4&*}N_ zJnzr*KF3(wO3+wmMF^!3 zSES64H$xuKH2G3@7fS-1!i{mUB z*4Y@G0RJsQ+bLQaZ72XzW>8*y#2xTsce*&`aA2`jm4H*Rc+Ls<364yIua!hHjp>2! zdiLPuJ6ZrS4%o zv!kS9aiU?pP*ho5+vSv$Y=(3;Lpn}}M&-jU=C1Y}q48^Qxj^G;Hp|;rKQK+*^JRrl zSRQ{)@8r;bg|rum5Dn`DN2ba6TB$#4$?c%Vb&}@(PUZ&2>75(`U@sCmR?5MVY3lkr zkTR1~aB)KWP#1FpPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01F8K01F8L68c9z00007bV*G`2jmA2 z4>|)JzW0m(00MAHL_t(I%YBp2OVe=}$6vFr!@i&SZLWXM4&*}N_ zJnzr*KF3(wO3+wmMF^!3 zSES64H$xuKH2G3@7fS-1!i{mUB z*4Y@G0RJsQ+bLQaZ72XzW>8*y#2xTsce*&`aA2`jm4H*Rc+Ls<364yIua!hHjp>2! zdiLPuJ6ZrS4%o zv!kS9aiU?pP*ho5+vSv$Y=(3;Lpn}}M&-jU=C1Y}q48^Qxj^G;Hp|;rKQK+*^JRrl zSRQ{)@8r;bg|rum5Dn`DN2ba6TB$#4$?c%Vb&}@(PUZ&2>75(`U@sCmR?5MVY3lkr zkTR1~aB)KWP#1Fp Date: Sat, 26 Feb 2022 18:45:11 +0100 Subject: [PATCH 02/11] 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 From 7449725a5671a55e8489caedd781a57ae12776c6 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 19:03:27 +0100 Subject: [PATCH 03/11] add target crafting receipe --- mods/ITEMS/REDSTONE/mcl_target/init.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mods/ITEMS/REDSTONE/mcl_target/init.lua b/mods/ITEMS/REDSTONE/mcl_target/init.lua index 30888204e..1c0582f06 100644 --- a/mods/ITEMS/REDSTONE/mcl_target/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_target/init.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator("mcl_target") +local mod_farming = minetest.get_modpath("mcl_farming") + mcl_target = {} function mcl_target.hit(pos, time) @@ -55,3 +57,15 @@ minetest.register_node("mcl_target:target_on", { _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, }) + + +if mod_farming then + minetest.register_craft({ + output = "mcl_target:target_off", + recipe = { + {"", "mesecons:redstone", ""}, + {"mesecons:redstone", "mcl_farming:hay_block", "mesecons:redstone"}, + {"", "mesecons:redstone", ""}, + }, + }) +end \ No newline at end of file From 540b72f1d6f74bdfbdbc4dccfff3f0bdbc80dc95 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 19:10:54 +0100 Subject: [PATCH 04/11] add target help text --- mods/ITEMS/REDSTONE/mcl_target/init.lua | 5 ++--- mods/ITEMS/REDSTONE/mcl_target/locale/mcl_target.fr.tr | 4 ++++ mods/ITEMS/REDSTONE/mcl_target/locale/template.txt | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 mods/ITEMS/REDSTONE/mcl_target/locale/mcl_target.fr.tr create mode 100644 mods/ITEMS/REDSTONE/mcl_target/locale/template.txt diff --git a/mods/ITEMS/REDSTONE/mcl_target/init.lua b/mods/ITEMS/REDSTONE/mcl_target/init.lua index 1c0582f06..268c6ebe3 100644 --- a/mods/ITEMS/REDSTONE/mcl_target/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_target/init.lua @@ -14,9 +14,8 @@ end minetest.register_node("mcl_target:target_off", { description = S("Target"), - --_tt_help = S(""), - --_doc_items_longdesc = longdesc, - --_doc_items_usagehelp = buttonuse, + _doc_items_longdesc = S("A target is a block that provides a temporary redstone charge when hit by a projectile."), + _doc_items_usagehelp = S("Throw a projectile on the target to activate it."), tiles = {"mcl_target_target_top.png", "mcl_target_target_top.png", "mcl_target_target_side.png"}, groups = {hoey = 1}, sounds = mcl_sounds.node_sound_dirt_defaults({ diff --git a/mods/ITEMS/REDSTONE/mcl_target/locale/mcl_target.fr.tr b/mods/ITEMS/REDSTONE/mcl_target/locale/mcl_target.fr.tr new file mode 100644 index 000000000..6c558683d --- /dev/null +++ b/mods/ITEMS/REDSTONE/mcl_target/locale/mcl_target.fr.tr @@ -0,0 +1,4 @@ +# textdomain: mcl_target +Target=Cible +A target is a block that provides a temporary redstone charge when hit by a projectile.=La cible est un bloc qui se comporte comme une source d'énergie temporaire quand elle est frappée par un projectile. +Throw a projectile on the target to activate it.=Lancer un projectile sur la cible pour l'activer. \ No newline at end of file diff --git a/mods/ITEMS/REDSTONE/mcl_target/locale/template.txt b/mods/ITEMS/REDSTONE/mcl_target/locale/template.txt new file mode 100644 index 000000000..18bc7708c --- /dev/null +++ b/mods/ITEMS/REDSTONE/mcl_target/locale/template.txt @@ -0,0 +1,4 @@ +# textdomain: mcl_target +Target= +A target is a block that provides a temporary redstone charge when hit by a projectile.= +Throw a projectile on the target to activate it.= \ No newline at end of file From c6f72c473f42faaa8a73e0ad750ca86d86bd8c64 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 22:12:26 +0100 Subject: [PATCH 05/11] make eggs activate target --- mods/ITEMS/mcl_throwing/register.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mods/ITEMS/mcl_throwing/register.lua b/mods/ITEMS/mcl_throwing/register.lua index b4a535b17..0bfcffc7b 100644 --- a/mods/ITEMS/mcl_throwing/register.lua +++ b/mods/ITEMS/mcl_throwing/register.lua @@ -177,6 +177,9 @@ local function egg_on_step(self, dtime) end minetest.sound_play("mcl_throwing_egg_impact", { pos = self.object:get_pos(), max_hear_distance=10, gain=0.5 }, true) 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 From d89687984b8938239a9838016ebb917d53fada68 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 22:16:10 +0100 Subject: [PATCH 06/11] make ender pearls activate target --- mods/ITEMS/mcl_throwing/register.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mods/ITEMS/mcl_throwing/register.lua b/mods/ITEMS/mcl_throwing/register.lua index 0bfcffc7b..8683eea0a 100644 --- a/mods/ITEMS/mcl_throwing/register.lua +++ b/mods/ITEMS/mcl_throwing/register.lua @@ -284,6 +284,9 @@ local function pearl_on_step(self, dtime) end 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 From 096d46152ee63ab3498229af0fa2f3ca8d6b9d7a Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 22:20:05 +0100 Subject: [PATCH 07/11] make bottle o enchanting activate target --- mods/HUD/mcl_experience/bottle.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mods/HUD/mcl_experience/bottle.lua b/mods/HUD/mcl_experience/bottle.lua index 10e42a57d..17a70054d 100644 --- a/mods/HUD/mcl_experience/bottle.lua +++ b/mods/HUD/mcl_experience/bottle.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) +local mod_target = minetest.get_modpath("mcl_target") + minetest.register_entity("mcl_experience:bottle",{ textures = {"mcl_experience_bottle.png"}, hp_max = 1, @@ -30,6 +32,9 @@ minetest.register_entity("mcl_experience:bottle",{ vertical = false, texture = "mcl_particles_effect.png^[colorize:blue:127", }) + if mod_target and n == "mcl_target:target_off" then + mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks + end self.object:remove() end end, From b51e3223042d9910595cbd1f85856d72b57961dc Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 22:38:34 +0100 Subject: [PATCH 08/11] make fire charges activate target (+ fix possible crash) --- mods/ENTITIES/mobs_mc/blaze.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index 5c6972872..79f0887cb 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -5,6 +5,8 @@ local S = minetest.get_translator("mobs_mc") +local mod_target = minetest.get_modpath("mcl_target") + --################### --################### BLAZE --################### @@ -178,17 +180,19 @@ mobs:register_arrow("mobs_mc:blaze_fireball", { -- Node hit, make fire hit_node = function(self, pos, node) - if node.name == "air" then - minetest.set_node(pos_above, {name=mobs_mc.items.fire}) + if node == "air" then + minetest.set_node(pos, {name = mobs_mc.items.fire}) else - local v = self.object:get_velocity() - v = vector.normalize(v) + if self._shot_from_dispenser and mod_target and node == "mcl_target:target_off" then + mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks + end + local v = vector.normalize(self.object:get_velocity()) local crashpos = vector.subtract(pos, v) local crashnode = minetest.get_node(crashpos) -- Set fire if node is air, or a replacable flammable node (e.g. a plant) if crashnode.name == "air" or (minetest.registered_nodes[crashnode.name].buildable_to and minetest.get_item_group(crashnode.name, "flammable") >= 1) then - minetest.set_node(crashpos, {name=mobs_mc.items.fire}) + minetest.set_node(crashpos, {name = mobs_mc.items.fire}) end end end From eae8effd57fb3f9eb9146f04b32507b2204adb7b Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 22:42:27 +0100 Subject: [PATCH 09/11] make splash potions activate target --- mods/ITEMS/mcl_potions/splash.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index 112b58754..4a820e467 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -1,6 +1,8 @@ local S = minetest.get_translator(minetest.get_current_modname()) local GRAVITY = tonumber(minetest.settings:get("movement_gravity")) +local mod_target = minetest.get_modpath("mcl_target") + local function splash_image(colorstring, opacity) if not opacity then opacity = 127 @@ -66,6 +68,9 @@ function mcl_potions.register_splash(name, descr, color, def) local g = minetest.get_item_group(n, "liquid") local d = 0.1 local redux_map = {7/8,0.5,0.25} + if mod_target and n == "mcl_target:target_off" then + mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks + end if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and g == 0 or mcl_potions.is_obj_hit(self, pos) then minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) local texture, acc From 210a0d8ee176954d528e9e835b3b3cc5db243acf Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 22:44:50 +0100 Subject: [PATCH 10/11] make lingering potions activate target (+ indentation fix) --- mods/ITEMS/mcl_potions/lingering.lua | 127 ++++++++++++++------------- 1 file changed, 66 insertions(+), 61 deletions(-) diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index d22dd4181..64f846cb6 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) +local mod_target = minetest.get_modpath("mcl_target") + local function lingering_image(colorstring, opacity) if not opacity then opacity = 127 @@ -95,71 +97,74 @@ function mcl_potions.register_lingering(name, descr, color, def) end end minetest.register_craftitem(id, { - description = descr, - _tt_help = def.tt, - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = S("Use the “Punch” key to throw it."), - inventory_image = lingering_image(color), - groups = {brewitem=1, not_in_creative_inventory=0}, - on_use = function(item, placer, pointed_thing) - local velocity = 10 - local dir = placer:get_look_dir(); - local pos = placer:getpos(); - minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true) - local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") - obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) - obj:setacceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3}) - obj:get_luaentity()._thrower = placer:get_player_name() - if not minetest.is_creative_enabled(placer:get_player_name()) then - item:take_item() + description = descr, + _tt_help = def.tt, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = S("Use the “Punch” key to throw it."), + inventory_image = lingering_image(color), + groups = {brewitem=1, not_in_creative_inventory=0}, + on_use = function(item, placer, pointed_thing) + local velocity = 10 + local dir = placer:get_look_dir(); + local pos = placer:getpos(); + minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true) + local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") + obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) + obj:setacceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3}) + obj:get_luaentity()._thrower = placer:get_player_name() + if not minetest.is_creative_enabled(placer:get_player_name()) then + item:take_item() + end + return item + end, + stack_max = 1, + _on_dispense = function(stack, dispenserpos, droppos, dropnode, dropdir) + local s_pos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51)) + local pos = {x=s_pos.x+dropdir.x,y=s_pos.y+dropdir.y,z=s_pos.z+dropdir.z} + minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true) + local obj = minetest.add_entity(pos, id.."_flying") + local velocity = 22 + obj:set_velocity({x=dropdir.x*velocity,y=dropdir.y*velocity,z=dropdir.z*velocity}) + obj:set_acceleration({x=dropdir.x*-3, y=-9.8, z=dropdir.z*-3}) end - return item - end, - stack_max = 1, - _on_dispense = function(stack, dispenserpos, droppos, dropnode, dropdir) - local s_pos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51)) - local pos = {x=s_pos.x+dropdir.x,y=s_pos.y+dropdir.y,z=s_pos.z+dropdir.z} - minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true) - local obj = minetest.add_entity(pos, id.."_flying") - local velocity = 22 - obj:set_velocity({x=dropdir.x*velocity,y=dropdir.y*velocity,z=dropdir.z*velocity}) - obj:set_acceleration({x=dropdir.x*-3, y=-9.8, z=dropdir.z*-3}) - end -}) + }) -local w = 0.7 + local w = 0.7 -minetest.register_entity(id.."_flying",{ - textures = {lingering_image(color)}, - hp_max = 1, - visual_size = {x=w/2,y=w/2}, - collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1}, - pointable = false, - on_step = function(self, dtime) - local pos = self.object:get_pos() - local node = minetest.get_node(pos) - local n = node.name - local g = minetest.get_item_group(n, "liquid") - local d = 4 - if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and g == 0 or mcl_potions.is_obj_hit(self, pos) then - minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) - add_lingering_effect(pos, color, def, name == "water") - local texture - if name == "water" then - texture = "mcl_particles_droplet_bottle.png" - else - if def.instant then - texture = "mcl_particles_instant_effect.png" + minetest.register_entity(id.."_flying",{ + textures = {lingering_image(color)}, + hp_max = 1, + visual_size = {x=w/2,y=w/2}, + collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1}, + pointable = false, + on_step = function(self, dtime) + local pos = self.object:get_pos() + local node = minetest.get_node(pos) + local n = node.name + local g = minetest.get_item_group(n, "liquid") + local d = 4 + if mod_target and n == "mcl_target:target_off" then + mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks + end + if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and g == 0 or mcl_potions.is_obj_hit(self, pos) then + minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) + add_lingering_effect(pos, color, def, name == "water") + local texture + if name == "water" then + texture = "mcl_particles_droplet_bottle.png" else - texture = "mcl_particles_effect.png" + if def.instant then + texture = "mcl_particles_instant_effect.png" + else + texture = "mcl_particles_effect.png" + end end + linger_particles(pos, d, texture, color) + if name == "water" then + mcl_potions._extinguish_nearby_fire(pos, d) + end + self.object:remove() end - linger_particles(pos, d, texture, color) - if name == "water" then - mcl_potions._extinguish_nearby_fire(pos, d) - end - self.object:remove() - end - end, -}) + end, + }) end From 5a7b1cc382f2a5ca5769a4544dd8ed7308f7b86e Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 23:52:03 +0100 Subject: [PATCH 11/11] make all arrow types activate target (+ depends and code fixes) --- mods/ITEMS/mcl_bows/arrow.lua | 10 ++++++-- mods/ITEMS/mcl_bows/mod.conf | 2 +- mods/ITEMS/mcl_bows/rocket.lua | 32 ++++++++++--------------- mods/ITEMS/mcl_potions/tipped_arrow.lua | 7 ++++++ 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 7529da167..b82d65ff2 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) +local mod_target = minetest.get_modpath("mcl_target") + local math = math local vector = vector @@ -117,8 +119,7 @@ function ARROW_ENTITY.on_step(self, dtime) self._time_in_air = self._time_in_air + .001 local pos = self.object:get_pos() - local dpos = table.copy(pos) -- digital pos - dpos = vector.round(dpos) + local dpos = vector.round(vector.new(pos)) -- digital pos local node = minetest.get_node(dpos) if self._stuck then @@ -383,6 +384,11 @@ function ARROW_ENTITY.on_step(self, dtime) tnt.ignite(self._stuckin) end + -- Activate target + if mod_target and snode.name == "mcl_target:target_off" then + mcl_target.hit(self._stuckin, 1) --10 redstone ticks + end + -- Push the button! Push, push, push the button! if mod_button and minetest.get_item_group(node.name, "button") > 0 and minetest.get_item_group(node.name, "button_push_by_arrow") == 1 then local bdir = minetest.wallmounted_to_dir(node.param2) diff --git a/mods/ITEMS/mcl_bows/mod.conf b/mods/ITEMS/mcl_bows/mod.conf index 79ae42436..e9f025a94 100644 --- a/mods/ITEMS/mcl_bows/mod.conf +++ b/mods/ITEMS/mcl_bows/mod.conf @@ -1,6 +1,6 @@ name = mcl_bows author = Arcelmi description = This mod adds bows and arrows for MineClone 2. -depends = controls, mcl_particles, mcl_enchanting, mcl_init +depends = controls, mcl_particles, mcl_enchanting, mcl_init, mcl_util optional_depends = awards, mcl_achievements, mcl_core, mcl_mobitems, playerphysics, doc, doc_identifier, mesecons_button diff --git a/mods/ITEMS/mcl_bows/rocket.lua b/mods/ITEMS/mcl_bows/rocket.lua index 678aba4d4..2c1d30dcd 100644 --- a/mods/ITEMS/mcl_bows/rocket.lua +++ b/mods/ITEMS/mcl_bows/rocket.lua @@ -18,20 +18,6 @@ local function dir_to_pitch(dir) return -math.atan2(-dir.y, xz) end -local function random_arrow_positions(positions, placement) - if positions == "x" then - return math.random(-4, 4) - elseif positions == "y" then - return math.random(0, 10) - end - if placement == "front" and positions == "z" then - return 3 - elseif placement == "back" and positions == "z" then - return -3 - end - return 0 -end - local function damage_explosion(self, damagemulitplier) mcl_explosions.explode(self.object:get_pos(), 3, {}) local objects = minetest.get_objects_inside_radius(self.object:get_pos(), 8) @@ -49,10 +35,10 @@ end local function particle_explosion(self) local particle_pattern = math.random(1, 3) - local fpitch = 0 - local true_type = "" - local type = math.random(1,2) - local size = math.random(1,3) + local fpitch + --local true_type + local type = math.random(1, 2) + local size = math.random(1, 3) local colors = {"red", "yellow", "blue", "green", "white"} local this_colors = {colors[math.random(#colors)], colors[math.random(#colors)], colors[math.random(#colors)]} @@ -64,11 +50,11 @@ local function particle_explosion(self) fpitch = math.random(60, 70) end - if type == 1 then + --[[if type == 1 then true_type = "Popper" else true_type = "Floof" - end + end]] if type == 1 then minetest.sound_play("mcl_bows_firework", { @@ -243,6 +229,7 @@ end local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements") local mod_button = minetest.get_modpath("mesecons_button") +local mod_target = minetest.get_modpath("mcl_target") minetest.register_craftitem("mcl_bows:rocket", { description = S("Arrow"), @@ -578,6 +565,11 @@ function ARROW_ENTITY.on_step(self, dtime) tnt.ignite(self._stuckin) end + -- Activate target + if mod_target and snode.name == "mcl_target:target_off" then + mcl_target.hit(self._stuckin, 1) --10 redstone ticks + end + -- Push the button! Push, push, push the button! if mod_button and minetest.get_item_group(node.name, "button") > 0 and minetest.get_item_group(node.name, "button_push_by_arrow") == 1 then local bdir = minetest.wallmounted_to_dir(node.param2) diff --git a/mods/ITEMS/mcl_potions/tipped_arrow.lua b/mods/ITEMS/mcl_potions/tipped_arrow.lua index 1717533a8..880dff956 100644 --- a/mods/ITEMS/mcl_potions/tipped_arrow.lua +++ b/mods/ITEMS/mcl_potions/tipped_arrow.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) +local mod_target = minetest.get_modpath("mcl_target") + local math = math -- Time in seconds after which a stuck arrow is deleted @@ -342,6 +344,11 @@ function mcl_potions.register_arrow(name, desc, color, def) self.object:set_velocity({x=0, y=0, z=0}) self.object:set_acceleration({x=0, y=0, z=0}) + -- Activate target + if mod_target and snode.name == "mcl_target:target_off" then + mcl_target.hit(self._stuckin, 1) --10 redstone ticks + end + -- Push the button! Push, push, push the button! if mod_button and minetest.get_item_group(node.name, "button") > 0 and minetest.get_item_group(node.name, "button_push_by_arrow") == 1 then local bdir = minetest.wallmounted_to_dir(node.param2)