dave9664 Posted March 10, 2015 Share Posted March 10, 2015 I'm making character mod and I have no idea how to make everything unequippable except for tools/weapons. My character is not allowed to wear grass/wood/marble/dark armour, any hats, any winter clothing or backpacks, does anyone know how to do this? Thanks. Link to comment Share on other sites More sharing options...
rezecib Posted March 11, 2015 Share Posted March 11, 2015 @dave9664, There are several mods that do this, which you can look at. Shovel Knight comes to mind. There have also been 4-5 threads on it in this subforum that you can find by searching. Link to comment Share on other sites More sharing options...
DrSmugleaf Posted March 11, 2015 Share Posted March 11, 2015 (edited) This is the way I personally use in my mod: local old_Equip = inst.components.inventory.Equip inst.components.inventory.Equip = function(self, item, old_to_active) if item.components.equippable.equipslot == GLOBAL.EQUIPSLOTS.HEAD or item.components.equippable.equipslot == GLOBAL.EQUIPSLOTS.BODY then return false end return old_Equip(self, item, old_to_active) endDon't think you would need the GLOBAL.'s if it's inside your character's prefab.That would be inside your master_postinit if its in your character's prefab. Edited March 11, 2015 by DrSmugleaf Link to comment Share on other sites More sharing options...
dave9664 Posted March 11, 2015 Author Share Posted March 11, 2015 Thanks @DrSmugLeaf! The code works, but when I craft the armour, it disappears. Is there a way to code it so that you can craft it but when you try equip it, it doesn't? I imagine something goes here in the code after the return? if item.components.equippable.equipslot == EQUIPSLOTS.HEAD or item.components.equippable.equipslot == EQUIPSLOTS.BODY then return false And sorry @rezecib I'm new here. Link to comment Share on other sites More sharing options...
DrSmugleaf Posted March 11, 2015 Share Posted March 11, 2015 (edited) @dave9664, You are right, gave you the wrong version of it:local old_Equip = inst.components.inventory.Equip inst.components.inventory.Equip = function(self, item, ...) if item.components.equippable.equipslot == GLOBAL.EQUIPSLOTS.HEAD or item.components.equippable.equipslot == GLOBAL.EQUIPSLOTS.BODY then inst.components.talker:Say("I can't equip this") self:DropItem(item) return false end return old_Equip(self, item, ...)end( Again, you probably don't need the GLOBAL.'s )It was because the character wasn't actually dropping the item. Edited March 11, 2015 by DrSmugleaf Link to comment Share on other sites More sharing options...
dave9664 Posted March 11, 2015 Author Share Posted March 11, 2015 @DrSmugLeaf that works perfectly, thanks so much! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now