mirror of
https://github.com/minetest-mods/technic.git
synced 2024-12-25 10:20:37 +01:00
limit the upgrade slot to one item per slot, as more are ignored anyway
This commit is contained in:
parent
41a10a86d5
commit
6ef3438832
@ -131,25 +131,30 @@ function technic.machine_can_dig(pos, player)
|
|||||||
end
|
end
|
||||||
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
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
minetest.chat_send_player(player:get_player_name(),
|
minetest.chat_send_player(player:get_player_name(),
|
||||||
S("Inventory move disallowed due to protection"))
|
S("Inventory move disallowed due to protection"))
|
||||||
return 0
|
return 0
|
||||||
end
|
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
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
function technic.machine_inventory_put(pos, listname, index, stack, player)
|
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
|
end
|
||||||
|
|
||||||
function technic.machine_inventory_take(pos, listname, index, stack, player)
|
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
|
end
|
||||||
|
|
||||||
function technic.machine_inventory_move(pos, from_list, from_index,
|
function technic.machine_inventory_move(pos, from_list, from_index,
|
||||||
to_list, to_index, count, player)
|
to_list, to_index, count, player)
|
||||||
return inv_change(pos, player, count)
|
return inv_change(pos, player, count, from_list, to_list)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user