From 4bd91750bc04250fd10f41c26a1b6ccd36fab7ba Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 17:38:04 +0100 Subject: [PATCH] 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