Renaming character in text

Sara377544
10 Sept 2022, 23:34

Let's say I make a character called "Innkeeper" and you can end up discovering his name or not. (Let's say his name is Alex)
How would I go about changing text like "The Innkeeper tells you..." "Alex tells you..."

Should I also name him "Male character' or "Male character (named)" in the object setup thing?


mrangel
12 Sept 2022, 12:20

I think by default, non-named characters will have "a" put in front of their name. So it will say "an innkeeper" in most of the default messages.

If you are using the function GetDefiniteName to generate "the innkeeper", then you can't actually change this – it isn't possible to change an object's types at runtime.

I would recommend giving the innkeeper a separate attribute, initially set to "the " (with a space at the end).
Then in whichever script involves him speaking, you could do:

msg (CapFirst (innkeeper.the) + WriteVerb (innkeeper, "tell") + " you some interesting stuff.")

and when you find out his name, the code would be:

innkeeper.alias = "Alex"
innkeeper.usedefaultprefix = false
innkeeper.prefix = ""
innkeeper.the = ""

(prefix gives a word to be used in place of "a" or "an". By default, named characters have it set to an empty string so just the name is shown. Unfortunately, functions which use "The" check the type rather than the attribute, so if you want to use "the" you need to store it somewhere yourself. Having the innkeeper as a non-named character and then setting his prefix/usedefaultprefix attributes will work for everything except the function GetDefiniteName, which will then say "the Alex" – but the only default message to use that is if Alex is a container and the player tries to open him, it would say "The Alex is already open". This is the only default message that uses "The" as far as I can tell, so you probably don't need to worry about it, and can use your own code to come up with a "The")