Jump to content

Recommended Posts

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. 

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! :D 

Edited by BraveChicken

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