Indi_ Posted July 31, 2023 Share Posted July 31, 2023 Hello! Does anyone know how to have a item that when used will restore some sanity and the character will say dialogue? If not that's fine, I might eventually figure it out or just move on lol. Thank you. Link to comment https://forums.kleientertainment.com/forums/topic/150046-how-to-make-custom-item-restore-sanity-when-used-and-for-character-to-say-dialouge/ Share on other sites More sharing options...
Indi_ Posted July 31, 2023 Author Share Posted July 31, 2023 (edited) I forgot to mention I'd also like for the dialogue to be randomized and there to be 4 different lines maybe. Like how when a character will carry a heavy statue they will say different lines occasionally. I'd also like to know if I can make it so it can be placed and picked back up? If not, that's understandable. I tried googling it and nothing came up. (This is for a custom character btw, and they spawn with it) Edited July 31, 2023 by Indi_ Link to comment https://forums.kleientertainment.com/forums/topic/150046-how-to-make-custom-item-restore-sanity-when-used-and-for-character-to-say-dialouge/#findComment-1656103 Share on other sites More sharing options...
_zwb Posted July 31, 2023 Share Posted July 31, 2023 12 hours ago, Indi_ said: when used will restore some sanity What do you mean by "when used"? When equipped? Or turned on? Or directly used like Wanda watches? Link to comment https://forums.kleientertainment.com/forums/topic/150046-how-to-make-custom-item-restore-sanity-when-used-and-for-character-to-say-dialouge/#findComment-1656222 Share on other sites More sharing options...
Indi_ Posted July 31, 2023 Author Share Posted July 31, 2023 1 hour ago, _zwb said: What do you mean by "when used"? When equipped? Or turned on? Or directly used like Wanda watches? I wanted it to be like, when you used the item like if you left clicked for example. So the character would use the item and then say some dialogue, and then their sanity would go up a bit. 5 minutes ago, Indi_ said: I wanted it to be like, when you used the item like if you left clicked for example. So the character would use the item and then say some dialogue, and then their sanity would go up a bit. I might just make it so when you hold it, it makes you regain sanity slowly because I already know how to code that lol. Though I'd still like dialogue to occasionally happen. Link to comment https://forums.kleientertainment.com/forums/topic/150046-how-to-make-custom-item-restore-sanity-when-used-and-for-character-to-say-dialouge/#findComment-1656244 Share on other sites More sharing options...
_zwb Posted August 1, 2023 Share Posted August 1, 2023 19 hours ago, Indi_ said: I wanted it to be like, when you used the item like if you left clicked for example. So the character would use the item and then say some dialogue, and then their sanity would go up a bit. So you want to activate the effect by right clicking or something similar? Then what? Is there a cool down? Does it have finite uses? Sorry I don't really understand what do you want it to do. 19 hours ago, Indi_ said: I might just make it so when you hold it, it makes you regain sanity slowly because I already know how to code that lol. Though I'd still like dialogue to occasionally happen. If you do it this way then I've came up with something for the quotes -- in your custom item file -- you can probably optimise the code a bit but again I don't know what you want to achieve so I can't do that local function say_random_quote(player) if player then if player.components.talker then player.components.talker:Say(--choose a random string from a table) end end end local function onequip(inst, owner) if owner.prefab == "your_custom_character_prefab" then if owner.say_quote_task then owner.say_quote_task:Cancel() owner.say_quote_task = nil end -- replace 10 with the time between quotes in seconds owner.say_quote_task = owner:DoPeriodicTask(10, say_random_quote, owner) end end local function onunequip(inst, owner) if owner.say_quote_task then owner.say_quote_task:Cancel() owner.say_quote_task = nil end end local function onequiptomodel(inst, owner, from_ground) -- this is for when item is equipped to mannequin -- do stuff depending on your item type end local function fn() inst = CreateEntity() --[[ insert other stuff you want to do --]] inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(onequip) inst.components.equippable:SetOnUnequip(onunequip) inst.components.equippable:SetOnEquipToModel(onequiptomodel) --[[ insert other stuff you want to do --]] return inst end 1 Link to comment https://forums.kleientertainment.com/forums/topic/150046-how-to-make-custom-item-restore-sanity-when-used-and-for-character-to-say-dialouge/#findComment-1656393 Share on other sites More sharing options...
Indi_ Posted August 2, 2023 Author Share Posted August 2, 2023 8 hours ago, _zwb said: So you want to activate the effect by right clicking or something similar? Then what? Is there a cool down? Does it have finite uses? Sorry I don't really understand what do you want it to do. If you do it this way then I've came up with something for the quotes -- in your custom item file -- you can probably optimise the code a bit but again I don't know what you want to achieve so I can't do that local function say_random_quote(player) if player then if player.components.talker then player.components.talker:Say(--choose a random string from a table) end end end local function onequip(inst, owner) if owner.prefab == "your_custom_character_prefab" then if owner.say_quote_task then owner.say_quote_task:Cancel() owner.say_quote_task = nil end -- replace 10 with the time between quotes in seconds owner.say_quote_task = owner:DoPeriodicTask(10, say_random_quote, owner) end end local function onunequip(inst, owner) if owner.say_quote_task then owner.say_quote_task:Cancel() owner.say_quote_task = nil end end local function onequiptomodel(inst, owner, from_ground) -- this is for when item is equipped to mannequin -- do stuff depending on your item type end local function fn() inst = CreateEntity() --[[ insert other stuff you want to do --]] inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(onequip) inst.components.equippable:SetOnUnequip(onunequip) inst.components.equippable:SetOnEquipToModel(onequiptomodel) --[[ insert other stuff you want to do --]] return inst end Thank you!!! Sorry what I was saying was unclear, I can try to explain it better. What I meant is, this item is basically something that my character will talk to and every time he does so he'll regain sanity, and it'll have infinite uses but a cooldown. My character loses sanity fast so I want an item to combat that. I'm sorry for the misunderstanding. And thank you so much for helping me out I really appreciate it!!!! Link to comment https://forums.kleientertainment.com/forums/topic/150046-how-to-make-custom-item-restore-sanity-when-used-and-for-character-to-say-dialouge/#findComment-1656520 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now