summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim <t4im@users.noreply.github.com>2015-02-05 16:09:16 +0100
committerTim <t4im@users.noreply.github.com>2015-02-05 16:09:16 +0100
commit6ef34388329902bdf08922a21169232c79b9c2a4 (patch)
treeb2dc2b15756306a2575593a871893c3f57d6a519
parent41a10a86d5d2257778b2e422b8a560ed8ea2cbba (diff)
limit the upgrade slot to one item per slot, as more are ignored anyway
-rw-r--r--technic/machines/register/common.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/technic/machines/register/common.lua b/technic/machines/register/common.lua
index d68be14..b269b06 100644
--- a/technic/machines/register/common.lua
+++ b/technic/machines/register/common.lua
@@ -131,25 +131,30 @@ function technic.machine_can_dig(pos, player)
end
end
-local function inv_change(pos, player, count)
+local function inv_change(pos, player, count, from_list, to_list)
if minetest.is_protected(pos, player:get_player_name()) then
minetest.chat_send_player(player:get_player_name(),
S("Inventory move disallowed due to protection"))
return 0
end
+ if to_list == "upgrade1" or to_list == "upgrade2" then
+ -- only place a single item into it, if it's empty
+ local empty = minetest.get_meta(pos):get_inventory():is_empty(to_list)
+ return empty and 1 or 0
+ end
return count
end
function technic.machine_inventory_put(pos, listname, index, stack, player)
- return inv_change(pos, player, stack:get_count())
+ return inv_change(pos, player, stack:get_count(), nil, listname)
end
function technic.machine_inventory_take(pos, listname, index, stack, player)
- return inv_change(pos, player, stack:get_count())
+ return inv_change(pos, player, stack:get_count(), listname, nil)
end
function technic.machine_inventory_move(pos, from_list, from_index,
to_list, to_index, count, player)
- return inv_change(pos, player, count)
+ return inv_change(pos, player, count, from_list, to_list)
end