Jump to content

Induce insanity when someone else equips custom item....


Recommended Posts

I have created a custom character with a custom item.  I do not want to make the item character specific or I would use the tutorial for that.  Instead I would simply like to induce insanity like the Nightmare Amulet when when a character other than the custom character welds it.  I am putting this bit of code below in the local function onequip of the custom item.  I know I am not either calling the right variables or not calling them correctly for the "if" statement.   I am trying to test if the owner is not playercharacter ninjajoe.  If not then induce insanity.

 

So

 

If ninjajoe equips the item = nothing happens

 

if wilson (or any other character) equips the item = induce insanity.

	if owner ~= ("ninjajoe") then	owner.components.sanity:SetInducedInsanity()	end

Any suggestions?

Link to comment
Share on other sites

This is the purple amulet code:

---PURPLElocal function induceinsanity(val, owner)    if owner.components.sanity ~= nil then        owner.components.sanity:SetInducedInsanity(val)    endendlocal function onequip_purple(inst, owner)    owner.AnimState:OverrideSymbol("swap_body", "torso_amulets", "purpleamulet")    if inst.components.fueled then        inst.components.fueled:StartConsuming()            end    induceinsanity(true, owner)endlocal function onunequip_purple(inst, owner)    owner.AnimState:ClearOverrideSymbol("swap_body")    if inst.components.fueled then        inst.components.fueled:StopConsuming()            end    induceinsanity(nil, owner)end

 

What you want:

local function induceinsanity(val, owner)    if owner.components.sanity ~= nil and owner.prefab ~= "ninjajoe" then        owner.components.sanity:SetInducedInsanity(val)    endendlocal function onequip(inst, owner)    owner.AnimState:OverrideSymbol("swap_body", "torso_amulets", "purpleamulet")    induceinsanity(true, owner)endlocal function onunequip(inst, owner)    owner.AnimState:ClearOverrideSymbol("swap_body")    induceinsanity(nil, owner)end

 

With onequip, and onunequip being the locals you want.

Replacing torso_amulets and purpleamulet with whatever you made your item and put where.

Although I don't know if it's a hat or armor or amulet what you have. I assume you know.

Edited by DarkXero
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...