]> git.lizzy.rs Git - minetest.git/commitdiff
DevTest: Cleanup callback logging
authorWuzzy <Wuzzy@disroot.org>
Sun, 9 Oct 2022 14:41:55 +0000 (16:41 +0200)
committersfan5 <sfan5@live.de>
Sun, 23 Oct 2022 19:58:56 +0000 (21:58 +0200)
games/devtest/mods/callbacks/entities.lua
games/devtest/mods/callbacks/items.lua
games/devtest/mods/callbacks/nodes.lua

index 6a7f13d7556adbf6e4a060137e9bbf469978ad10..e8379cb6f4155bafa4e2b64e2add322c2a5630e5 100644 (file)
@@ -1,7 +1,7 @@
 -- Entities that test their callbacks
 
 local message = function(msg)
-       minetest.log("action", msg)
+       minetest.log("action", "[callbacks] "..msg)
        minetest.chat_send_all(msg)
 end
 
index fb9f6b675740a312fa1a87bf8057d336d0d95be2..cd73529bd8c08cdea56eee8759705e25defb73f5 100644 (file)
@@ -2,6 +2,11 @@
 -- Item callbacks
 --
 
+local function print_to_everything(msg)
+       minetest.log("action", "[callbacks] " .. msg)
+       minetest.chat_send_all(msg)
+end
+
 minetest.register_craftitem("callbacks:callback_item_1", {
        description = "Callback Test Item 1".."\n"..
                "Tests callbacks: on_secondary_use, on_drop, on_pickup, on_use, after_use".."\n"..
@@ -12,7 +17,7 @@ minetest.register_craftitem("callbacks:callback_item_1", {
        groups = { callback_test = 1 },
 
        on_secondary_use = function(itemstack, user, pointed_thing)
-               minetest.log("[callbacks:callback_item_1 on_secondary_use] " .. itemstack:get_name())
+               print_to_everything("[callbacks:callback_item_1 on_secondary_use] " .. itemstack:get_name())
                local ctrl = user and user:get_player_control() or {}
                if ctrl.sneak then
                        itemstack = ItemStack(itemstack)
@@ -22,7 +27,7 @@ minetest.register_craftitem("callbacks:callback_item_1", {
        end,
 
        on_drop = function(itemstack, dropper, pos)
-               minetest.log("[callbacks:callback_item_1 on_drop] " .. itemstack:get_name())
+               print_to_everything("[callbacks:callback_item_1 on_drop] " .. itemstack:get_name())
                local ctrl = dropper and dropper:get_player_control() or {}
                if ctrl.sneak then
                        itemstack = ItemStack(itemstack)
@@ -33,12 +38,13 @@ minetest.register_craftitem("callbacks:callback_item_1", {
        end,
 
        on_pickup = function(itemstack, picker, pointed_thing, ...)
-               minetest.log("[callbacks:callback_item_1 on_pickup]")
+               print_to_everything("[callbacks:callback_item_1 on_pickup]")
                assert(pointed_thing.ref:get_luaentity().name == "__builtin:item")
                local ctrl = picker and picker:get_player_control() or {}
                if ctrl.aux1 then
                        -- Debug message
-                       minetest.log(dump({...}))
+                       print_to_everything("on_pickup dump:")
+                       print_to_everything(dump({...}))
                end
                if ctrl.sneak then
                        -- Pick up one item of the other kind at once
@@ -61,7 +67,7 @@ minetest.register_craftitem("callbacks:callback_item_1", {
        end,
 
        on_use = function(itemstack, user, pointed_thing)
-               minetest.log("[callbacks:callback_item_1 on_use] " .. itemstack:get_name())
+               print_to_everything("[callbacks:callback_item_1 on_use] " .. itemstack:get_name())
                local ctrl = user and user:get_player_control() or {}
                if ctrl.sneak then
                        itemstack = ItemStack(itemstack)
@@ -71,7 +77,7 @@ minetest.register_craftitem("callbacks:callback_item_1", {
        end,
 
        after_use = function(itemstack, user, node, digparams) -- never called
-               minetest.log("[callbacks:callback_item_1 after_use]")
+               print_to_everything("[callbacks:callback_item_1 after_use]")
                local ctrl = user and user:get_player_control() or {}
                if ctrl.up then
                        itemstack = ItemStack(itemstack)
@@ -89,7 +95,7 @@ minetest.register_craftitem("callbacks:callback_item_2", {
        groups = { callback_test = 1 },
 
        on_use = function(itemstack, user, pointed_thing)
-               minetest.log("[callbacks:callback_item_2 on_use]")
+               print_to_everything("[callbacks:callback_item_2 on_use]")
                itemstack = ItemStack(itemstack)
                itemstack:set_name("callbacks:callback_item_1")
                return itemstack
@@ -103,7 +109,7 @@ minetest.register_on_item_pickup(function(itemstack, picker, pointed_thing, time
        if item_name ~= "callbacks:callback_item_1" and item_name ~= "callbacks:callback_item_2" then
                return
        end
-       minetest.log("["..item_name.." register_on_item_pickup]")
+       print_to_everything("["..item_name.." register_on_item_pickup]")
 
        local ctrl = picker and picker:get_player_control() or {}
        if item_name == "callbacks:callback_item_2" and not ctrl.sneak then
index 5cc9c8b70e147f952c4ccf88501b57653c19c10b..80e3f9bed84c7e79dca68bd863f58466f09eb91a 100644 (file)
@@ -1,5 +1,5 @@
 local function print_to_everything(msg)
-       minetest.log("action", msg)
+       minetest.log("action", "[callbacks] " .. msg)
        minetest.chat_send_all(msg)
 end