Unable to set Variables via LUA or C#
Posted: Tue May 11, 2021 4:32 pm
So I auto-generate a lot of stuff when a new player game is started (names, locations, etc.). I've tried to assign these variables to the design system database as they'll be referenced in a lot of places and I dont' want to pay the performance cost of the reflection methods every time i need to pull up one of these strings if I can avoid it.
I've created a series of methods like the following:
and registered as noted:
I've then tried to update the variable both via C#:
and via the Lua script on the first conversation's start node:
Referencing the Get methods directly (lua[PlayerTitle()]) works so I know the methods are functional, but no matter what I do, any attempt to reference the variable shows the old (default) value.
I've created a series of methods like the following:
Code: Select all
public string PlayerName()
{
return PlayerData.PlayerName;
}
public string PlayerTitle()
{
return PlayerData.CurrentTitle;
}
Code: Select all
void OnEnable()
{
Lua.RegisterFunction("PlayerName", this, SymbolExtensions.GetMethodInfo(() => this.PlayerName()));
Lua.RegisterFunction("PlayerTitle", this, SymbolExtensions.GetMethodInfo(() => this.PlayerTitle()));
}
void OnDisable()
{
Lua.UnregisterFunction("PlayerName");
Lua.UnregisterFunction("PlayerTitle");
}
Code: Select all
DialogManager.masterDatabase.variables.FirstOrDefault(v => v.Name == "PlayerName").InitialValue = sheet.PlayerName;
DialogManager.masterDatabase.variables.FirstOrDefault(v => v.Name == "PlayerTitle").InitialValue = sheet.CurrentTitle;
Code: Select all
Variable["PlayerTitle"] = PlayerTitle();