Jump to content

Recommended Posts

How do I make it so that the only thing my character can equip (not including hand items) is his bag? I don't want him to be able to equip anything other than the bag (and heavy items such as the marble and moon altar pieces) in the body or hat slot

I've looked through other posts and tried out the code they provided, and while it did block him from using body/hat items, it also didn't let him pick up his bag (even when trying to make an exception in the code), so I'm not too sure what's going on with it

Link to comment
https://forums.kleientertainment.com/forums/topic/168216-only-equip-bag/
Share on other sites

-- in master_postinit of the character
-- Can only equip his bag
local OldEquip = inst.components.inventory.Equip
inst.components.inventory.Equip = function(self, item, old_to_active)
  if not item or not item.components.equippable or not item:IsValid() then
    return
  end
  if
    (item.components.equippable.equipslot == EQUIPSLOTS.BODY and -- So that the prefab used in the body is only the one you want
    not (item.prefab == "prefab_name")) or
    item.components.equippable.equipslot == EQUIPSLOTS.HEAD -- so that nothing that goes on the head can be equipped
  then
    -- When the prefab is not what you need
    return -- we finished the function
  end
  return OldEquip(self, item, old_to_active) -- If the prefab is the one we are looking for, then we execute the function we overwrote to equip it
end

 

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...