Tony Li wrote: ↑Thu Oct 06, 2022 3:25 pm
The catch is that's not a command per se. When you click Apply, it will generate this Lua code:
Code: Select all
Variable["Examples.MeanGuy.NumTimesSpoken"] = Variable["Examples.MeanGuy.NumTimesSpoken"] + 0
Instead, you can write your own C# method (like my IncrementVariable() example) that does the same thing except it can also make an RPC call to tell other clients to update their Variable[] table value, too:
customIncrementVariable.png
Or, if you're using UNET or Mirror, you could use the LuaNetworkCommands component, and do this:
Code: Select all
NetSetNumber("Examples.MeanGuy.NumTimesSpoken", Variable["Examples.MeanGuy.NumTimesSpoken"] + 0)
Alright I thought my previous question was going to be the final one, but I have one more quickie
Lets say I was using this function (from LuaNetworkCommands.cs)
Code: Select all
Lua.RegisterFunction("NetSetBool", this, SymbolExtensions.GetMethodInfo(() => NetSetBool(string.Empty, false)));
...
public void NetSetBool(string variableName, bool value)
{
CmdSetBool(variableName, value);
}
When I am using the command from within a dialogueEntry, I have to manually enter the string for "variableName". We have a ton of variables and they have pretty long names (like NPC.Blacksmith.PerformedUpgrade1, etc).
I'd like to be able to select the name of the variable from a list, like in this screenshot:
Is there any built-in way to have that "selection menu" popup, so I could select the variable that I want to be applied to the "string variableName" field? I assume this would be related to parameter settings on the CustomLuaFunctionInfo scriptableObject.
If there isn't a built-in way to do it, I was thinking I could maybe do some hacking and add another enum value to the "CustomLuaParameterType", and look at the code behind the CustomLuaParameterType.Variable (which has the variable-selection-popup-menu as part of it). I don't mind looking through the code to figure out a way to hack that together, but if for some reason it wouldn't be possible I'd appreciate it if you'd let me know, LOL.
Thanks Tony!