Jump to content

Recommended Posts

Sorry for the thread title I'm tired.

I have items that cause the user to announce a string when the item is equipped.

When the character enters the cave/surface with the items equipped, or otherwise loads into the server with the item on, the character talks. This causes a bug where the character's dialogue gets stuck on the bottom left of the hosts' screen.

I don't know why this happens and can't reliably reproduce it, so the easiest solution seems to be to make the character silent on loading in.

I already have a function in the item's OnEquip to make them not talk under certain circumstances and with a cooldown.

Quote

local silent = owner.sg:HasStateTag("silentmorph") or  owner.sg:HasStateTag("busy") or owner.sg:HasStateTag("talking") or owner.sg:HasStateTag("notalking") or not owner.entity:IsVisible()
            if not silent and owner.shutupBlake == nil then
            owner.components.talker:Say(GetString(owner, "ANNOUNCE_EQUIPBLACKMASK"))
            owner.shutupBlake = owner:DoTaskInTime(TUNING.MASKSPEECHTIMER, shutup_Blake)
            end

what is the easiest and least painful way to stop the character talking on loading in. Because I have to account for every item I feel like I'm massively overthinking this when there is probably a simple tweak I can make.

...I also just tried adding "or owner._loading" to my code, along with putting the PreLoad and OnlLoad bits from Wormwood's prefab into my character's prefab (as he's the only one who can use the items), and that didn't help either. I have literally no idea what I'm doing so I might have just made an error somewhere.

Edited by Chesed

When you enter the world, your character and inventoryitems are spawned. Then, the equipment is equipped to your character according to the savedata, triggering the `Equippable.onequipfn` method. So, I think the solution is to start listening for the event of being equipped only after some delay from the initialization of your equipment.

inst:DoTaskInTime(1, function()
    inst:ListenForEvent("equipped", onequipped)
end)

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