]> git.lizzy.rs Git - minetest.git/commitdiff
DevTest: Move more logging to log mod
authorWuzzy <Wuzzy@disroot.org>
Sat, 8 Oct 2022 15:46:03 +0000 (17:46 +0200)
committersfan5 <sfan5@live.de>
Sun, 23 Oct 2022 19:58:56 +0000 (21:58 +0200)
games/devtest/mods/experimental/init.lua
games/devtest/mods/experimental/items.lua [deleted file]
games/devtest/mods/experimental/textures/experimental_tester_tool_1.png [deleted file]
games/devtest/mods/log/init.lua
games/devtest/mods/testtools/items.lua [new file with mode: 0644]
games/devtest/mods/testtools/textures/testtools_privatizer.png [new file with mode: 0644]

index b292f792e3a0696f80535980e822265f777220cb..20350b0932d8af423b2bdad73a1ba0ba7a753924 100644 (file)
@@ -13,11 +13,4 @@ function experimental.print_to_everything(msg)
        minetest.chat_send_all(msg)
 end
 
-minetest.log("info", "[experimental] modname="..dump(minetest.get_current_modname()))
-minetest.log("info", "[experimental] modpath="..dump(minetest.get_modpath("experimental")))
-minetest.log("info", "[experimental] worldpath="..dump(minetest.get_worldpath()))
 
-
-minetest.register_on_mods_loaded(function()
-       minetest.log("action", "[experimental] on_mods_loaded()")
-end)
diff --git a/games/devtest/mods/experimental/items.lua b/games/devtest/mods/experimental/items.lua
deleted file mode 100644 (file)
index 3a7c178..0000000
+++ /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/experimental/textures/experimental_tester_tool_1.png b/games/devtest/mods/experimental/textures/experimental_tester_tool_1.png
deleted file mode 100644 (file)
index 5df416a..0000000
Binary files a/games/devtest/mods/experimental/textures/experimental_tester_tool_1.png and /dev/null differ
index 4102bca363fe4ed659872ab96ae61a8bdb47bf12..c1c052ddc7dd53039216706141d008e22109a85d 100644 (file)
@@ -1,3 +1,16 @@
+local modname = minetest.get_current_modname()
+local prefix = "["..modname.."] "
+
+-- Startup info
+minetest.log("action", prefix.."modname="..dump(modname))
+minetest.log("action", prefix.."modpath="..dump(minetest.get_modpath(modname)))
+minetest.log("action", prefix.."worldpath="..dump(minetest.get_worldpath()))
+
+-- Callback info
+minetest.register_on_mods_loaded(function()
+       minetest.log("action", prefix.."Callback: on_mods_loaded()")
+end)
+
 minetest.register_on_chatcommand(function(name, command, params)
-       minetest.log("action", "[devtest] Caught command '"..command.."', issued by '"..name.."'. Parameters: '"..params.."'")
+       minetest.log("action", prefix.."Caught command '"..command.."', issued by '"..name.."'. Parameters: '"..params.."'")
 end)
diff --git a/games/devtest/mods/testtools/items.lua b/games/devtest/mods/testtools/items.lua
new file mode 100644 (file)
index 0000000..3a7c178
--- /dev/null
@@ -0,0 +1,106 @@
+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/textures/testtools_privatizer.png b/games/devtest/mods/testtools/textures/testtools_privatizer.png
new file mode 100644 (file)
index 0000000..5df416a
Binary files /dev/null and b/games/devtest/mods/testtools/textures/testtools_privatizer.png differ