From 68df0fb2ea0b0e6ba5ca27216d864e4843e8bdc4 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 9 Oct 2022 14:20:35 +0200 Subject: [PATCH] DevTest: Move experimental items to other mods --- games/devtest/mods/callbacks/init.lua | 51 +++++++++ games/devtest/mods/callbacks/mod.conf | 2 + .../textures/callbacks_callback_node.png} | Bin games/devtest/mods/experimental/init.lua | 1 - games/devtest/mods/testtools/README.md | 15 +++ games/devtest/mods/testtools/init.lua | 2 + games/devtest/mods/testtools/items.lua | 106 ------------------ games/devtest/mods/testtools/particles.lua | 36 ++++++ games/devtest/mods/testtools/privatizer.lua | 24 ++++ .../textures/testtools_particle_sheet.png} | Bin .../textures/testtools_particle_spawner.png | Bin 0 -> 138 bytes .../textures/testtools_particle_vertical.png} | Bin .../textures/testtools_privatizer.png | Bin 138 -> 569 bytes 13 files changed, 130 insertions(+), 107 deletions(-) create mode 100644 games/devtest/mods/callbacks/init.lua create mode 100644 games/devtest/mods/callbacks/mod.conf rename games/devtest/mods/{experimental/textures/experimental_callback_node.png => callbacks/textures/callbacks_callback_node.png} (100%) delete mode 100644 games/devtest/mods/testtools/items.lua create mode 100644 games/devtest/mods/testtools/particles.lua create mode 100644 games/devtest/mods/testtools/privatizer.lua rename games/devtest/mods/{experimental/textures/experimental_particle_sheet.png => testtools/textures/testtools_particle_sheet.png} (100%) create mode 100644 games/devtest/mods/testtools/textures/testtools_particle_spawner.png rename games/devtest/mods/{experimental/textures/experimental_particle_vertical.png => testtools/textures/testtools_particle_vertical.png} (100%) diff --git a/games/devtest/mods/callbacks/init.lua b/games/devtest/mods/callbacks/init.lua new file mode 100644 index 000000000..baaf9fbc7 --- /dev/null +++ b/games/devtest/mods/callbacks/init.lua @@ -0,0 +1,51 @@ +local function print_to_everything(msg) + minetest.log("action", msg) + minetest.chat_send_all(msg) +end + +minetest.register_node("callbacks:callback_node", { + description = "Callback Test Node (construct/destruct/timer)".."\n".. + "Tests callbacks: on_construct, after_place_node, on_destruct, after_destruct, after_dig_node, on_timer", + tiles = {"callbacks_callback_node.png"}, + groups = {dig_immediate=3}, + -- This was known to cause a bug in minetest.item_place_node() when used + -- via minetest.place_node(), causing a placer with no position + paramtype2 = "facedir", + drop = "", + + on_construct = function(pos) + print_to_everything("callbacks:callback_node:on_construct("..minetest.pos_to_string(pos)..")") + local meta = minetest.get_meta(pos) + meta:set_string("mine", "test") + local timer = minetest.get_node_timer(pos) + timer:start(4, 3) + end, + + after_place_node = function(pos, placer) + print_to_everything("callbacks:callback_node:after_place_node("..minetest.pos_to_string(pos)..")") + local meta = minetest.get_meta(pos) + if meta:get_string("mine") == "test" then + print_to_everything("correct metadata found") + else + print_to_everything("incorrect metadata found") + end + end, + + on_destruct = function(pos) + print_to_everything("callbacks:callback_node:on_destruct("..minetest.pos_to_string(pos)..")") + end, + + after_destruct = function(pos) + print_to_everything("callbacks:callback_node:after_destruct("..minetest.pos_to_string(pos)..")") + end, + + after_dig_node = function(pos, oldnode, oldmetadata, digger) + print_to_everything("callbacks:callback_node:after_dig_node("..minetest.pos_to_string(pos)..")") + end, + + on_timer = function(pos, elapsed) + print_to_everything("callbacks:callback_node:on_timer(): elapsed="..dump(elapsed)) + return true + end, +}) + diff --git a/games/devtest/mods/callbacks/mod.conf b/games/devtest/mods/callbacks/mod.conf new file mode 100644 index 000000000..7f7b6b86a --- /dev/null +++ b/games/devtest/mods/callbacks/mod.conf @@ -0,0 +1,2 @@ +name = callbacks +description = Adds various callback-related stuff diff --git a/games/devtest/mods/experimental/textures/experimental_callback_node.png b/games/devtest/mods/callbacks/textures/callbacks_callback_node.png similarity index 100% rename from games/devtest/mods/experimental/textures/experimental_callback_node.png rename to games/devtest/mods/callbacks/textures/callbacks_callback_node.png diff --git a/games/devtest/mods/experimental/init.lua b/games/devtest/mods/experimental/init.lua index 20350b093..e37d85dbf 100644 --- a/games/devtest/mods/experimental/init.lua +++ b/games/devtest/mods/experimental/init.lua @@ -5,7 +5,6 @@ experimental = {} dofile(minetest.get_modpath("experimental").."/detached.lua") -dofile(minetest.get_modpath("experimental").."/items.lua") dofile(minetest.get_modpath("experimental").."/commands.lua") function experimental.print_to_everything(msg) diff --git a/games/devtest/mods/testtools/README.md b/games/devtest/mods/testtools/README.md index 72f0a2db0..3de2969a7 100644 --- a/games/devtest/mods/testtools/README.md +++ b/games/devtest/mods/testtools/README.md @@ -120,9 +120,24 @@ Usage: * Punch entity to increase visual size * Sneak+punch entity to decrease visual size +## Note Meta Privatizer +Sets the 'formspec' and 'infotext' metadata fields of a node +to private. This means that clients can no longer access these +fields. +This only works for chests [`chest:chest`] at the moment. + +Usage: +* Punch: Set metadata of pointed node to private + ## Light Tool Show light level of node. Usage: * Punch: Show light info of node in front of the punched node's side * Place: Show light info of the node that you touched + +## Particle Spawner +Spawn a random animated particle. + +Usage: +* Punch: Spawn particle diff --git a/games/devtest/mods/testtools/init.lua b/games/devtest/mods/testtools/init.lua index abc1ed79b..6db5a7cd1 100644 --- a/games/devtest/mods/testtools/init.lua +++ b/games/devtest/mods/testtools/init.lua @@ -2,6 +2,8 @@ local S = minetest.get_translator("testtools") local F = minetest.formspec_escape dofile(minetest.get_modpath("testtools") .. "/light.lua") +dofile(minetest.get_modpath("testtools") .. "/privatizer.lua") +dofile(minetest.get_modpath("testtools") .. "/particles.lua") minetest.register_tool("testtools:param2tool", { description = S("Param2 Tool") .."\n".. diff --git a/games/devtest/mods/testtools/items.lua b/games/devtest/mods/testtools/items.lua deleted file mode 100644 index 3a7c178f7..000000000 --- a/games/devtest/mods/testtools/items.lua +++ /dev/null @@ -1,106 +0,0 @@ -minetest.register_node("experimental:callback_node", { - description = "Callback Test Node".."\n".. - "Tests callbacks: on_construct, after_place_node, on_destruct, after_destruct, after_dig_node, on_timer", - tiles = {"experimental_callback_node.png"}, - groups = {dig_immediate=3}, - -- This was known to cause a bug in minetest.item_place_node() when used - -- via minetest.place_node(), causing a placer with no position - paramtype2 = "facedir", - drop = "", - - on_construct = function(pos) - experimental.print_to_everything("experimental:callback_node:on_construct("..minetest.pos_to_string(pos)..")") - local meta = minetest.get_meta(pos) - meta:set_string("mine", "test") - local timer = minetest.get_node_timer(pos) - timer:start(4, 3) - end, - - after_place_node = function(pos, placer) - experimental.print_to_everything("experimental:callback_node:after_place_node("..minetest.pos_to_string(pos)..")") - local meta = minetest.get_meta(pos) - if meta:get_string("mine") == "test" then - experimental.print_to_everything("correct metadata found") - else - experimental.print_to_everything("incorrect metadata found") - end - end, - - on_destruct = function(pos) - experimental.print_to_everything("experimental:callback_node:on_destruct("..minetest.pos_to_string(pos)..")") - end, - - after_destruct = function(pos) - experimental.print_to_everything("experimental:callback_node:after_destruct("..minetest.pos_to_string(pos)..")") - end, - - after_dig_node = function(pos, oldnode, oldmetadata, digger) - experimental.print_to_everything("experimental:callback_node:after_dig_node("..minetest.pos_to_string(pos)..")") - end, - - on_timer = function(pos, elapsed) - experimental.print_to_everything("on_timer(): elapsed="..dump(elapsed)) - return true - end, -}) - -minetest.register_tool("experimental:privatizer", { - description = "Node Meta Privatizer".."\n".. - "Punch: Marks 'infotext' and 'formspec' meta fields of chest as private", - inventory_image = "experimental_tester_tool_1.png", - groups = { testtool = 1, disable_repair = 1 }, - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type == "node" then - local node = minetest.get_node(pointed_thing.under) - if node.name == "chest:chest" then - local p = pointed_thing.under - minetest.log("action", "Privatizer used at "..minetest.pos_to_string(p)) - minetest.get_meta(p):mark_as_private({"infotext", "formspec"}) - if user and user:is_player() then - minetest.chat_send_player(user:get_player_name(), "Chest metadata (infotext, formspec) set private!") - end - return - end - end - if user and user:is_player() then - minetest.chat_send_player(user:get_player_name(), "Privatizer can only be used on chest!") - end - end, -}) - -minetest.register_tool("experimental:particle_spawner", { - description = "Particle Spawner".."\n".. - "Punch: Spawn random test particle", - inventory_image = "experimental_tester_tool_1.png^[invert:g", - groups = { testtool = 1, disable_repair = 1 }, - on_use = function(itemstack, user, pointed_thing) - local pos = minetest.get_pointed_thing_position(pointed_thing, true) - if pos == nil then - if user then - pos = user:get_pos() - end - end - pos = vector.add(pos, {x=0, y=0.5, z=0}) - local tex, anim - if math.random(0, 1) == 0 then - tex = "experimental_particle_sheet.png" - anim = {type="sheet_2d", frames_w=3, frames_h=2, frame_length=0.5} - else - tex = "experimental_particle_vertical.png" - anim = {type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3} - end - - minetest.add_particle({ - pos = pos, - velocity = {x=0, y=0, z=0}, - acceleration = {x=0, y=0.04, z=0}, - expirationtime = 6, - collisiondetection = true, - texture = tex, - animation = anim, - size = 4, - glow = math.random(0, 5), - }) - end, -}) - diff --git a/games/devtest/mods/testtools/particles.lua b/games/devtest/mods/testtools/particles.lua new file mode 100644 index 000000000..18efe2572 --- /dev/null +++ b/games/devtest/mods/testtools/particles.lua @@ -0,0 +1,36 @@ +minetest.register_tool("testtools:particle_spawner", { + description = "Particle Spawner".."\n".. + "Punch: Spawn random test particle", + inventory_image = "testtools_particle_spawner.png", + groups = { testtool = 1, disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + local pos = minetest.get_pointed_thing_position(pointed_thing, true) + if pos == nil then + if user then + pos = user:get_pos() + end + end + pos = vector.add(pos, {x=0, y=0.5, z=0}) + local tex, anim + if math.random(0, 1) == 0 then + tex = "testtools_particle_sheet.png" + anim = {type="sheet_2d", frames_w=3, frames_h=2, frame_length=0.5} + else + tex = "testtools_particle_vertical.png" + anim = {type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3} + end + + minetest.add_particle({ + pos = pos, + velocity = {x=0, y=0, z=0}, + acceleration = {x=0, y=0.04, z=0}, + expirationtime = 6, + collisiondetection = true, + texture = tex, + animation = anim, + size = 4, + glow = math.random(0, 5), + }) + end, +}) + diff --git a/games/devtest/mods/testtools/privatizer.lua b/games/devtest/mods/testtools/privatizer.lua new file mode 100644 index 000000000..bd6e2377a --- /dev/null +++ b/games/devtest/mods/testtools/privatizer.lua @@ -0,0 +1,24 @@ +minetest.register_tool("testtools:privatizer", { + description = "Node Meta Privatizer".."\n".. + "Punch: Marks 'infotext' and 'formspec' meta fields of chest as private", + inventory_image = "testtools_privatizer.png", + groups = { testtool = 1, disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type == "node" then + local node = minetest.get_node(pointed_thing.under) + if node.name == "chest:chest" then + local p = pointed_thing.under + minetest.log("action", "[testtools] Privatizer used at "..minetest.pos_to_string(p)) + minetest.get_meta(p):mark_as_private({"infotext", "formspec"}) + if user and user:is_player() then + minetest.chat_send_player(user:get_player_name(), "Chest metadata (infotext, formspec) set private!") + end + return + end + end + if user and user:is_player() then + minetest.chat_send_player(user:get_player_name(), "Privatizer can only be used on chest!") + end + end, +}) + diff --git a/games/devtest/mods/experimental/textures/experimental_particle_sheet.png b/games/devtest/mods/testtools/textures/testtools_particle_sheet.png similarity index 100% rename from games/devtest/mods/experimental/textures/experimental_particle_sheet.png rename to games/devtest/mods/testtools/textures/testtools_particle_sheet.png diff --git a/games/devtest/mods/testtools/textures/testtools_particle_spawner.png b/games/devtest/mods/testtools/textures/testtools_particle_spawner.png new file mode 100644 index 0000000000000000000000000000000000000000..5df416a582e75a7c476f834038cfef02d2bd9ad2 GIT binary patch literal 138 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`fu1goAr*|t3T!N_tbdQIn!n(2 z$T-mExsg|!?WAD(f%+B8*aW&um>)<9uuaTh;PctTxH;|YuYR{?gPD2`5)RwA6J{(j lP`J)ILvLZF*AjaM23@x0qN{zs{skJ&;OXk;vd$@?2>`a$DQ5rx literal 0 HcmV?d00001 diff --git a/games/devtest/mods/experimental/textures/experimental_particle_vertical.png b/games/devtest/mods/testtools/textures/testtools_particle_vertical.png similarity index 100% rename from games/devtest/mods/experimental/textures/experimental_particle_vertical.png rename to games/devtest/mods/testtools/textures/testtools_particle_vertical.png diff --git a/games/devtest/mods/testtools/textures/testtools_privatizer.png b/games/devtest/mods/testtools/textures/testtools_privatizer.png index 5df416a582e75a7c476f834038cfef02d2bd9ad2..b9896287a4d87cd82656a00baa6e1df4cc21838a 100644 GIT binary patch delta 545 zcmV++0^a?K0l5T_BYy#eX+uL$Nkc;*aB^>EX>4Tx04R}tkv&MmKpe$iTg6f;9qb^* zAwzYt;1}YkRVYG*P%E_RU~=gfG-*guTpR`0f`cE6RRs^9pd7t}p^eY9E0X~6vmg$B?yg@v@Y3ZEziKDD6Da7Z*qXu1&_>t?f%Ws@Z4*Pj# z)W~M$iKE0qsf*<;g30fkz6vlDq!STKn*G+#}EDozq>VylM`-II0^K=*!IUT z(669An*)aX&ry93Cw(w-souYBOtO3TwHfFc@MbU0S2FR$&ef=K+|6= z0`F(^O?hD876`4my|wpo`T%69tMmLO zg(#Z;LtTJ^k;G8|3z6RYk4q5~rGbdg1^>x509zoE>;h=06EqNK7{D|Uat+0Sh}QsO j!h(^+&>ClC7<2#tx=|XSDys$~00000NkvXXu0mjf6gl&5 delta 110 zcmV-!0FnQ>1d0KWBWD0nNkl