Jump to content

Recommended Posts

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.

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)	end

Don'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 by DrSmugleaf

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.

@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 by DrSmugleaf

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...