From 68df0fb2ea0b0e6ba5ca27216d864e4843e8bdc4 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 9 Oct 2022 14:20:35 +0200 Subject: DevTest: Move experimental items to other mods --- games/devtest/mods/callbacks/init.lua | 51 +++++++++++++++++++++ games/devtest/mods/callbacks/mod.conf | 2 + .../callbacks/textures/callbacks_callback_node.png | Bin 0 -> 139 bytes 3 files changed, 53 insertions(+) create mode 100644 games/devtest/mods/callbacks/init.lua create mode 100644 games/devtest/mods/callbacks/mod.conf create mode 100644 games/devtest/mods/callbacks/textures/callbacks_callback_node.png (limited to 'games/devtest/mods/callbacks') 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/callbacks/textures/callbacks_callback_node.png b/games/devtest/mods/callbacks/textures/callbacks_callback_node.png new file mode 100644 index 000000000..e9d87434c Binary files /dev/null and b/games/devtest/mods/callbacks/textures/callbacks_callback_node.png differ -- cgit v1.2.3