I have a bit of in-line Lua that I use to check gender and return the appropriate pronoun or whatever word ("Hey young man/woman").
Code: Select all
You are a [lua(return Variable["Gender"] == "Male" and "male" or "female" )].
Code: Select all
You are a [g("male", "female")].
EDIT:
Nevermind. Looking at FormattedText.cs, it's looking like adding my own tag would be messy so I'm just rolling it out into a function that ends up being [lua(g("male", "female"))], which is close enough.
Here's the code in case anyone else wants to do the same thing:
Code: Select all
public class LUAGenderCheck : MonoBehaviour
{
public string playerGenderVariable = "Male";
private void OnEnable()
{
Lua.RegisterFunction("g", this, SymbolExtensions.GetMethodInfo(() => GetPlayerGender(String.Empty, String.Empty)));
}
public string GetPlayerGender(string male, string female)
{
return playerGenderVariable == "Male" ? male : female;
}
}
Code: Select all
You are a [lua(g("male", "female"))].
Better version in my reply below.