Jump to content

Recommended Posts

Hi, 

first post here (hope I’m doing it correctly.)

I am making a character mod and I was wondering if it’s possible to make something similar to wigfrids umlauts? (Replacing the os with ös) for my own character? I’d want to replace some other letter but I’m not sure how I’d go on making that? I can’t find the script with the code anywhere that changes her dialogue. 

 

thanks :)

Wigfrid actually uses a special function of the "talker" component to replace every O in her speech with an Ö.

inst.components.talker.mod_str_fn = Umlautify

"Umlauntify" is a function value found within "stringutil.lua", and looks like this:
 

Spoiler

function Umlautify(string)
    if not Profile:IsWathgrithrFontEnabled() then
        return string
    end

    local ret = ""
    local last = false
    for i = 1, #string do
        local c = string:sub(i,i)
        if not last and (c == "o" or c == "O") then
            ret = ret .. ((c == "o" and "ö") or (c == "O" and "Ö") or c)
            last = true
        else
            ret = ret .. c
            last = false
        end
    end
    return ret
end

 

So, all you have to do is add the first line of code and create a function to make the replacements as you wish.

 

Edited by HarryPPP
  • Thanks 1
17 hours ago, HarryPPP said:

Wigfrid actually uses a special function of the "talker" component to replace every O in her speech with an Ö.


inst.components.talker.mod_str_fn = Umlautify

"Umlauntify" is a function value found within "stringutil.lua", and looks like this:
 

  Hide contents


function Umlautify(string)
    if not Profile:IsWathgrithrFontEnabled() then
        return string
    end

    local ret = ""
    local last = false
    for i = 1, #string do
        local c = string:sub(i,i)
        if not last and (c == "o" or c == "O") then
            ret = ret .. ((c == "o" and "ö") or (c == "O" and "Ö") or c)
            last = true
        else
            ret = ret .. c
            last = false
        end
    end
    return ret
end

 

So, all you have to do is add the first line of code and create a function to make the replacements as you wish.

 

Thank you so much for your response. I feel a bit lost of what to do next though. I am not that experienced and I’m not quite sure how I’d go on creating the function to make it work? What exactly would I be typing out? Do I just copy the already existing function? If so, what is it that I have to edit so it works with my own character? Sorry if it’s kind of a simple question, just want to make sure I’m doing it right.

thanks again!

4 hours ago, waddle_dee said:

What exactly would I be typing out? Do I just copy the already existing function?

I've written a function with some handy comments to try and explain:

function Acutify(string) -- Goal: replace every E with an É.
	local ret = ""
	for i = 1, #string do -- All the letters are taken out of the message, and each one goes through a check:
		local c = string:sub(i,i) -- "c", short for "character"
		
		-- Here, I am checking if the found character is an accentless, capitalized or not, letter "E".
		if c == "e" or c == "E" then
			ret = ret .. ((c == "e" and "é") or (c == "E" and "É") or c) -- Each letter E found will be replaced with an É.
		else
			ret = ret .. c -- If the letter is not E, it will just be put back on its place, with no alterations.
		end
	end
	return ret -- This replaces the original message with the newly compiled one.
end

 

4 hours ago, waddle_dee said:

Sorry if it’s kind of a simple question, just want to make sure I’m doing it right.

thanks again!

Oh, don't worry. It took me a while to figure this out... But it's quite simple with some tips, eh?

 

 

Edited by HarryPPP
  • Thanks 1
4 hours ago, HarryPPP said:

I've written a function with some handy comments to try and explain:


function Acutify(string) -- Goal: replace every E with an É.
	local ret = ""
	for i = 1, #string do -- All the letters are taken out of the message, and each one goes through a check:
		local c = string:sub(i,i) -- "c", short for "character"
		
		-- Here, I am checking if the found character is an accentless, capitalized or not, letter "E".
		if c == "e" or c == "E" then
			ret = ret .. ((c == "e" and "é") or (c == "E" and "É") or c) -- Each letter E found will be replaced with an É.
		else
			ret = ret .. c -- If the letter is not E, it will just be put back on its place, with no alterations.
		end
	end
	return ret -- This replaces the original message with the newly compiled one.
end

 

Oh, don't worry. It took me a while to figure this out... But it's quite simple with some tips, eh?

 

 

ahh thank you so much! The tips sure help a lot!! I will try this tomorrow. :)
 

thanks again!

On 7/31/2022 at 10:47 PM, HarryPPP said:

Oh, don't worry. It took me a while to figure this out... But it's quite simple with some tips, eh?

And here I am back with another question :oops:

I added your function to my character, word for word, just to try it out. I made sure to add the component thingy too, becuase I assume that is what you meant to be the "first line of code"

On 7/31/2022 at 12:23 AM, HarryPPP said:

So, all you have to do is add the first line of code and create a function to make the replacements as you wish.

Well, I tried to run the game with it but nothing really happened or changed? I've been trying to figure out what I am missing but I am so clueless :confused: maybe I am missing where exactly im supposed to put everything. I have tried to look at other scripts with similar stuff but I cannot figure it out 

 

thanks again for your time and patience

On 8/3/2022 at 12:09 AM, waddle_dee said:

I've been trying to figure out what I am missing but I am so clueless :confused: maybe I am missing where exactly im supposed to put everything

Make sure "inst.components.talker.mod_str_fn = Acutify" is inside the "master_postinit" function, and that the "Acutify" function is anywhere above it outside of a function.

On 8/3/2022 at 12:09 AM, waddle_dee said:

thanks again for your time and patience

Don't worry, this has been a learning experience to me too. I never really questioned how Wigfrid's Umlaunts were made...

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