Jump to content

Trouble using Global Strings


Recommended Posts

Right now I'm updating some existing character quotes for my modded character in modmain.lua. Even though I've gotten it to work before on similar codes, the game doesn't seem to like what I'm doing.  The only differences between the codes that work and this code is that this code requires brackets and I'm using WILSON instead of GENERIC for speech strings.

does the game automatically set Wilson's speech file as generic, and if so, how do I make custom quotes for wilson that won't affect the generic speech code?

Link to comment
Share on other sites

1 hour ago, mf99k said:

does the game automatically set Wilson's speech file as generic

--these are broken out into their own files for ease of editing
STRINGS.CHARACTERS =
{
	GENERIC = require "speech_wilson",
	WAXWELL = require "speech_waxwell",
	WOLFGANG = require "speech_wolfgang",
	WX78 = require "speech_wx78",
	WILLOW = require "speech_willow",
	WENDY = require "speech_wendy",
	WOODIE = require "speech_woodie",
	WICKERBOTTOM = require "speech_wickerbottom",
	WATHGRITHR = require "speech_wathgrithr",
	WEBBER = require "speech_webber",
}

The game sets a generic speech. Then, when it tries to find the correct string for Wilson:

    return GetSpecialCharacterString(specialcharacter)
        or getcharacterstring(STRINGS.CHARACTERS[character], stringtype, modifier)
        or getcharacterstring(STRINGS.CHARACTERS.GENERIC, stringtype, modifier)
        or ("UNKNOWN STRING: "..(character or "").." "..(stringtype or "").." "..(modifier or ""))

It doesn't find a WILSON key on the speech table. But if you have a WILSON speech in the table I posted, then the game would pick always strings from that one, and in case it doesn't find any, will default to the GENERIC speech.

1 hour ago, mf99k said:

how do I make custom quotes for wilson that won't affect the generic speech code?

I don't understand.

If you are making a custom item, you can do stuff like:

inst:AddComponent("inspectable")
inst.components.inspectable.descriptionfn = function(inst, viewer)
	if viewer and viewer.prefab == "wilson" then
		return "unique_speech_string_for_wilson_for_this_item"
	end
end

If you don't want to touch the generic speech.

Anyways, post whatever the game doesn't like.

Link to comment
Share on other sites

4 minutes ago, DarkXero said:

--these are broken out into their own files for ease of editing
STRINGS.CHARACTERS =
{
	GENERIC = require "speech_wilson",
	WAXWELL = require "speech_waxwell",
	WOLFGANG = require "speech_wolfgang",
	WX78 = require "speech_wx78",
	WILLOW = require "speech_willow",
	WENDY = require "speech_wendy",
	WOODIE = require "speech_woodie",
	WICKERBOTTOM = require "speech_wickerbottom",
	WATHGRITHR = require "speech_wathgrithr",
	WEBBER = require "speech_webber",
}

The game sets a generic speech. Then, when it tries to find the correct string for Wilson:


    return GetSpecialCharacterString(specialcharacter)
        or getcharacterstring(STRINGS.CHARACTERS[character], stringtype, modifier)
        or getcharacterstring(STRINGS.CHARACTERS.GENERIC, stringtype, modifier)
        or ("UNKNOWN STRING: "..(character or "").." "..(stringtype or "").." "..(modifier or ""))

It doesn't find a WILSON key on the speech table. But if you have a WILSON speech in the table I posted, then the game would pick always strings from that one, and in case it doesn't find any, will default to the GENERIC speech.

I don't understand.

If you are making a custom item, you can do stuff like:


inst:AddComponent("inspectable")
inst.components.inspectable.descriptionfn = function(inst, viewer)
	if viewer and viewer.prefab == "wilson" then
		return "unique_speech_string_for_wilson_for_this_item"
	end
end

If you don't want to touch the generic speech.

Anyways, post whatever the game doesn't like.

GLOBAL.STRINGS.CHARACTERS.WILSON.DESCRIBE is what it doesn't like
 

could I add a postinit for strings so that both GENERIC and WILSON work?

Edited by mf99k
Link to comment
Share on other sites

4 minutes ago, mf99k said:

GLOBAL.STRINGS.CHARACTERS.WILSON.DESCRIBE is what it doesn't like

Well, of course.

GLOBAL.STRINGS.CHARACTERS.WILSON is a nil value.

Do

GLOBAL.STRINGS.CHARACTERS.WILSON = {}

before adding the DESCRIBE.

Link to comment
Share on other sites

21 hours ago, DarkXero said:

Well, of course.

GLOBAL.STRINGS.CHARACTERS.WILSON is a nil value.

Do


GLOBAL.STRINGS.CHARACTERS.WILSON = {}

before adding the DESCRIBE.

would I do require "speech_wilson" then?

Link to comment
Share on other sites

4 hours ago, mf99k said:

would I do require "speech_wilson" then?

If you have a "speech_wilson" file, then change the name to "mod_speech_wilson" or whatever, or you risk missing generic strings from "speech_wilson" since the game will load your incomplete speech as the generic speech, which could cause an error.

GLOBAL.STRINGS.CHARACTERS.WILSON = GLOBAL.require("mod_speech_wilson")

Link to comment
Share on other sites

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
 Share

×
  • Create New...