From 79e4f20505a0cffc66f316560d20ba9be3727be3 Mon Sep 17 00:00:00 2001 From: jp Date: Mon, 3 Aug 2015 12:08:30 +0200 Subject: [PATCH] Cleanup mailbox code --- mailbox.lua | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/mailbox.lua b/mailbox.lua index 3084b7d..9af0a40 100644 --- a/mailbox.lua +++ b/mailbox.lua @@ -24,23 +24,19 @@ xdecor.register("mailbox", { local meta = minetest.get_meta(pos) if owner == player then - minetest.show_formspec( - clicker:get_player_name(), - "default:chest_locked", + minetest.show_formspec(player, "default:chest_locked", xdecor.get_mailbox_formspec(pos)) - else - minetest.show_formspec( - clicker:get_player_name(), - "default:chest_locked", + else minetest.show_formspec(player, "default:chest_locked", xdecor.get_mailbox_insert_formspec(pos)) end end, - can_dig = function(pos,player) + can_dig = function(pos, player) local meta = minetest.get_meta(pos) local owner = meta:get_string("owner") local inv = meta:get_inventory() + local player = clicker:get_player_name() - return player:get_player_name() == owner and inv:is_empty("main") + return player == owner and inv:is_empty("main") end, on_metadata_inventory_put = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) @@ -52,20 +48,15 @@ xdecor.register("mailbox", { end end, allow_metadata_inventory_put = function(pos, listname, index, stack, player) - if listname == "main" then - return 0 - end + if listname == "main" then return 0 end if listname == "drop" then local meta = minetest.get_meta(pos) local inv = meta:get_inventory() - if inv:room_for_item("main", stack) then - return -1 - else - return 0 - end + if inv:room_for_item("main", stack) then return -1 + else return 0 end end - end, + end }) function xdecor.get_mailbox_formspec(pos)