Digi_056 Posted November 6, 2018 Share Posted November 6, 2018 (edited) I’m trying to create a mod character that says something different when eating monster meat rather than the dialogue when eating other “painful” foods. Does anyone know I would go about doing this? Edited November 11, 2018 by Player_056 Link to comment https://forums.kleientertainment.com/forums/topic/98094-solved-custom-speech-help-needed/ Share on other sites More sharing options...
FleurDuSoleil3 Posted November 8, 2018 Share Posted November 8, 2018 You can do this, and change a few other things if you wish, using the following method: In the modmain, beneath GLOBAL.STRINGS is where I put mine, paste this code: STRINGS.CHARACTERS.YOURPREFABHERE = require "speech_YOURPREFABHERE" Then go into the Don't Starve data files, into scripts, and copy and paste a character's .lua speech file into your mod's scripts folder. Change the name from speech_wilson.lua or whatever to speech_YOURPREFABHERE.lua You can open the new speech file, find whatever you want your character to change, and type out a new response. When Hamlet comes out you will probably need to copy and paste the Hamlet DLC dialogue from a default character's speech script in order to keep yours up to date. Link to comment https://forums.kleientertainment.com/forums/topic/98094-solved-custom-speech-help-needed/#findComment-1111911 Share on other sites More sharing options...
BraveChicken Posted November 8, 2018 Share Posted November 8, 2018 (edited) You can also just go to your modmain.lua and add in there this: GetPlayer = GLOBAL.GetPlayer --add this line only if you don't have it in your modmain.lua already. AddPrefabPostInit("FoodHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then local function nomed (inst, eater) if eater.prefab == "YourCharacterHere" then inst:DoTaskInTime( 0.01, function(inst) GetPlayer().components.talker:Say("What you want your character to say.") end) end end inst.components.edible:SetOnEatenFn(nomed) end end) Or if you want to add this to many different food items then you use this method instead: (This one also goes to your modmain.lua) GetPlayer = GLOBAL.GetPlayer local function OnOmnomnomed(inst) local function nomed (inst, eater) if eater.prefab == "YourCharacterHere" then inst:DoTaskInTime( 0.01, function(inst) GetPlayer().components.talker:Say("What you want your character to say.") end) end end inst.components.edible:SetOnEatenFn(nomed) end AddPrefabPostInit("FoodHere", OnOmnomnomed) Then all you need to do in order to add this to more food items is to copy-paste the line " AddPrefabPostInit("FoodHere", OnOmnomnomed) " as many times as you need and place the prefab name of the food that you want on the marked spot.Example: AddPrefabPostInit("monstermeat", OnOmnomnomed) AddPrefabPostInit("carrot", OnOmnomnomed) AddPrefabPostInit("eggplant", OnOmnomnomed) and so on... This basically simply makes a different speech line appear so fast that it pushed the old one away. I hope that helps. Good luck! Edited November 8, 2018 by BraveChicken Link to comment https://forums.kleientertainment.com/forums/topic/98094-solved-custom-speech-help-needed/#findComment-1112311 Share on other sites More sharing options...
Digi_056 Posted November 9, 2018 Author Share Posted November 9, 2018 22 hours ago, BraveChicken said: This basically simply makes a different speech line appear so fast that it pushed the old one away. I hope that helps. Good luck! This is exactly what I needed! Thank you! Link to comment https://forums.kleientertainment.com/forums/topic/98094-solved-custom-speech-help-needed/#findComment-1112934 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