Jump to content

Recommended Posts

Hello, I need help trying to make a code then characters with certain value doesn't get effected by inducedinsanity from purple amulet, skeleton hat, ect.

I tried doing this, but it does nothing because my coding skills suck.

Spoiler

AddComponentPostInit("sanity", function(inst)
	if not GLOBAL.TheWorld.ismastersim then return end
	
	local SetInducedInsanity_old = inst.SetInducedInsanity
	inst.SetInducedInsanity = function(inst, src, val)
		if inst.inducedinsanity_immune == true then
        end
        return SetInducedInsanity_old(inst, src, val)
    end
end)

 

Thank you for any help and your time have a great day :D!

Edited by Warbucks
AddComponentPostInit("sanity", function(self)
	if not GLOBAL.TheWorld.ismastersim then return end
	
	local SetInducedInsanity_old = self.SetInducedInsanity
	self.SetInducedInsanity = function(self, src, val)
		if self.inst.inducedinsanity_immune == true then
        end
        return SetInducedInsanity_old(self, src, val)
    end
end)

The variable scope was wrong

Edited by YakumoYukari

Further you should be returning from your callback without calling the old function.

AddComponentPostInit(
    "sanity",
    function(self)
        if not GLOBAL.TheWorld.ismastersim
        then
            return
        end
        local SetInducedInsanity_old = self.SetInducedInsanity
        self.SetInducedInsanity = function(self, ...)
            if self.inst.inducedinsanity_immune == true
            then
                return somethinghere
            end
            return SetInducedInsanity_old(self, ...)
        end
    end
)

 

Edited by CarlZalph
Three shells.

This code seems to work, thanks for all your help guys :D!!

Spoiler

AddComponentPostInit("sanity", function(self)
	if not GLOBAL.TheWorld.ismastersim then return end
	local SetInducedInsanity_old = self.SetInducedInsanity
	self.SetInducedInsanity = function(self, ...)
		if self.inst.inducedinsanity_immune  == true then
			return
		else
			return SetInducedInsanity_old(self, ...)
		end
	end
end)

 

 

Edited by Warbucks

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