Jump to content

Help with raising the Critters cap for a character


Recommended Posts

Ok, so I'm trying to make my character have up to 3 critters, but there's this on builder.lua which prevents me crafting another critter

        elseif recipe.level.ORPHANAGE > 0 and (
                self.inst.components.petleash == nil or
                self.inst.components.petleash:IsFull() or
                self.inst.components.petleash:HasPetWithTag("critter")
            ) then
            return false, "HASPET"

how do I circumvent this? Thanks in advance.

Link to comment
Share on other sites

5 hours ago, Doxarez said:

Ok, so I'm trying to make my character have up to 3 critters, but there's this on builder.lua which prevents me crafting another critter


        elseif recipe.level.ORPHANAGE > 0 and (
                self.inst.components.petleash == nil or
                self.inst.components.petleash:IsFull() or
                self.inst.components.petleash:HasPetWithTag("critter")
            ) then
            return false, "HASPET"

how do I circumvent this? Thanks in advance.

Increasing the petleash maxpets coupled with a extension of the HasPetWithTag function to always return false for the "critter" tag for your character should probably do it.

  • Like 2
Link to comment
Share on other sites

inst.components.petleash:SetMaxPets(3)	
local _HasPetWithTag = inst.components.petleash.HasPetWithTag
	function inst.components.petleash:HasPetWithTag(tag, ...)
		--test if have less than three pets, if you do return false, otherwise return true
		
    	--always run the original function when possible
    	return _HasPetWithTag(self, tag, ...)
	end

Ok, so someone told me to use this, but since I suck, I don't know what checks to put where it's commented.

Link to comment
Share on other sites

inst.components.petleash:SetMaxPets(X)
    local _HasPetWithTag = inst.components.petleash.HasPetWithTag
    function inst.components.petleash:HasPetWithTag(tag, ...)
		if inst.components.petleash.numpets < X then
			return false
			end
    	return _HasPetWithTag(self, tag, ...)
	end

Fixed it! I'm posting the code here for anyone that wants it, remember to replace X with your desired number.

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...