Jump to content

Recommended Posts

I added a "curse" in the game, and when you get cursed the character will say "wait what, i got cursed".

Obviously, i'd like to change it so every character says his own quote, but how? I have no clue.

local Curse = Class(function(self, inst)
    self.inst = inst
    self.remaining_time = 0
    self.task = nil
end)

function Curse:ApplyCurse(time)
    self.inst.components.talker:Say("Wait what, i got cursed!")
    if self.task ~= nil then
        self.task:Cancel()
    end
    self.remaining_time = time > self.remaining_time and time or self.remaining_time
    self.task = self.inst:DoPeriodicTask(1, function(_)
        if self.remaining_time == 0 then
            self.task:Cancel()
            return
        end
        self.inst.components.health:DoDelta(-3)
        self.remaining_time = self.remaining_time - 1
    end)
end

return Curse

Instead of your "Wait what, i got cursed!" string, use this function here:

GetString(self.inst, "ANNOUNCE_I_GOT_CURSED")

So that your line will look like this:

self.inst.components.talker:Say(GetString(self.inst, "ANNOUNCE_I_GOT_CURSED"))

You can use whatever string you prefer instead of "ANNOUNCE_I_GOT_CURSED", just make sure to also add the string to a character in the modmain environment, for example like this:

GLOBAL.STRINGS.CHARACTERS.GENERIC.ANNOUNCE_I_GOT_CURSED = "Wait what, i got cursed!"
  • Health 1
2 hours ago, ClumsyPenny said:

Instead of your "Wait what, i got cursed!" string, use this function here:

GetString(self.inst, "ANNOUNCE_I_GOT_CURSED")

So that your line will look like this:

self.inst.components.talker:Say(GetString(self.inst, "ANNOUNCE_I_GOT_CURSED"))

You can use whatever string you prefer instead of "ANNOUNCE_I_GOT_CURSED", just make sure to also add the string to a character in the modmain environment, for example like this:

GLOBAL.STRINGS.CHARACTERS.GENERIC.ANNOUNCE_I_GOT_CURSED = "Wait what, i got cursed!"

Sorry, bit off-topic but if I want to make so strings are taken from another file (I want to do different language support) I should do
in skilltree file:

whispy_beard_1 = {
title = GetString(self.inst, "WHISPY_SKILL_I"),

in string file:

GLOBAL.STRINGS.WHISPY_SKILL_I = "Beardlord I"

?

1 hour ago, RexySeven said:

Sorry, bit off-topic but if I want to make so strings are taken from another file (I want to do different language support) I should do
in skilltree file:

whispy_beard_1 = {
title = GetString(self.inst, "WHISPY_SKILL_I"),

in string file:

GLOBAL.STRINGS.WHISPY_SKILL_I = "Beardlord I"

?

GetString is specifically for character quotes, not translation. I don't know how mods are supposed to handle translation, so I can't help you there.

4 hours ago, ClumsyPenny said:

Instead of your "Wait what, i got cursed!" string, use this function here:

GetString(self.inst, "ANNOUNCE_I_GOT_CURSED")

So that your line will look like this:

self.inst.components.talker:Say(GetString(self.inst, "ANNOUNCE_I_GOT_CURSED"))

You can use whatever string you prefer instead of "ANNOUNCE_I_GOT_CURSED", just make sure to also add the string to a character in the modmain environment, for example like this:

GLOBAL.STRINGS.CHARACTERS.GENERIC.ANNOUNCE_I_GOT_CURSED = "Wait what, i got cursed!"

i was testing what you said, and it was working.

Until a friend of mine entered and chose a character, at that point my character (walter) started saying winona's quote.

In other words, the last one to enter dictates the quote.

What's the problem?

14 minutes ago, ClumsyPenny said:

Show me your code.

 

local Curse = Class(function(self, inst)
    self.inst = inst
    self.remaining_time = 0
    self.task = nil
end)

function Curse:ApplyCurse(time)
    self.inst.components.talker:Say(GetString(self.inst, "ANNOUNCE_I_GOT_CURSED"))
    if self.task ~= nil then
        self.task:Cancel()
    end
    self.remaining_time = time > self.remaining_time and time or self.remaining_time
    self.task = self.inst:DoPeriodicTask(1, function(_)
        if self.remaining_time == 0 then
            self.task:Cancel()
            return
        end
        self.inst.components.health:DoDelta(-3)
        self.remaining_time = self.remaining_time - 1
    end)
end

return Curse

then i put in a different folder every character quote (every character has its own folder) all linked to modmain

example:

AddPrefabPostInit("woodie", function(inst)
    if GLOBAL.TheWorld.ismastersim then 
    GLOBAL.STRINGS.CHARACTERS.GENERIC.ANNOUNCE_I_GOT_CURSED = "Another day, another curse"
    end
end)

59 minutes ago, Sacco said:

AddPrefabPostInit("woodie", function(inst)
    if GLOBAL.TheWorld.ismastersim then 
    GLOBAL.STRINGS.CHARACTERS.GENERIC.ANNOUNCE_I_GOT_CURSED = "Another day, another curse"
    end
end)

They're not supposed to be in a AddPrefabPostInit, I just said in the modmain environment. Also, instead of GENERIC, you're supposed to change that for each character's prefab (aside for Wilson, who uses the default GENERIC). For example:

GLOBAL.STRINGS.CHARACTERS.GENERIC.ANNOUNCE_I_GOT_CURSED = "Wait what, i got cursed!"
GLOBAL.STRINGS.CHARACTERS.WILLOW.ANNOUNCE_I_GOT_CURSED = "oh no"
GLOBAL.STRINGS.CHARACTERS.WOLFGANG.ANNOUNCE_I_GOT_CURSED = "mighty wolfgang is cursed"
GLOBAL.STRINGS.CHARACTERS.WENDY.ANNOUNCE_I_GOT_CURSED = "yay"
-- etc.

A character's prefab name usually matches their name, but there's some notable exceptions like WX-78 is WX78, Wigfrid is WATHGRITHR and Maxwell is WAXWELL.

  • Like 1

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