PlayerInventoryUI: Now you can only place items with a specific group in equipment slots. #34
This commit is contained in:
@@ -23,4 +23,42 @@ local function getEquipTab(self, playerName, tabType)
|
|||||||
return EquipTab
|
return EquipTab
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- We only allow items to be placed in equipment slot
|
||||||
|
-- that have groups that match the slot name and index.
|
||||||
|
core.register_allow_player_inventory_action(function(player, action, inventory, inventoryInfo)
|
||||||
|
if action == 'move' then
|
||||||
|
-- Checking if a slot is an equipment slot.
|
||||||
|
local equipGroup = string.match(inventoryInfo.to_list, 'equip_%S+')
|
||||||
|
if equipGroup == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- We receive the item that the player wants to place in the equipment slot.
|
||||||
|
local itemStack = inventory:get_stack(inventoryInfo.from_list, inventoryInfo.from_index)
|
||||||
|
assert(itemStack ~= nil)
|
||||||
|
|
||||||
|
if core.get_item_group(itemStack:get_name(), equipGroup) == inventoryInfo.to_index then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
elseif action == 'put' then
|
||||||
|
-- Checking if a slot is an equipment slot.
|
||||||
|
local equipGroup = string.match(inventoryInfo.listname, 'equip_%S+')
|
||||||
|
if equipGroup == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- We receive the item that the player wants to place in the equipment slot.
|
||||||
|
local itemStack = inventory:get_stack(inventoryInfo.listname, inventoryInfo.index)
|
||||||
|
assert(itemStack ~= nil)
|
||||||
|
|
||||||
|
if core.get_item_group(itemStack:get_name(), equipGroup) == inventoryInfo.index then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
return getEquipTab
|
return getEquipTab
|
||||||
|
|||||||
Reference in New Issue
Block a user