Disable the trash button outside of creative mode
authorShadowNinja <noreply@gmail.com>
Wed, 25 Sep 2013 02:04:29 +0000 (22:04 -0400)
committerShadowNinja <noreply@gmail.com>
Wed, 25 Sep 2013 02:04:29 +0000 (22:04 -0400)
unified_inventory/register.lua

index 0baea9b89268c2b178541b3971a33e643acd6aad..ad85537ff8940fa18e01926ae43f37e490dbd890 100644 (file)
@@ -99,7 +99,15 @@ unified_inventory.register_button("clear_inv", {
        type = "image",
        image = "ui_trash_icon.png",
        action = function(player)
-       local player_name = player:get_player_name()
+               local player_name = player:get_player_name()
+               if not unified_inventory.is_creative(player_name) then
+                       minetest.chat_send_player(player_name,
+                                       "This button has been disabled outside"
+                                       .." of creative mode to prevent"
+                                       .." accidental inventory trashing."
+                                       .." Use the trash slot instead.")
+                       return
+               end
                player:get_inventory():set_list("main", {})
                minetest.chat_send_player(player_name, 'Inventory Cleared!')
                minetest.sound_play("trash_all",