Hey there! I'm trying to build a custom variable condition for conversations (more specifically a 'die roll with stat-bonuses rolling against a target number for pass/fail') but I'm running into an error I can't quite understand.
The method I'm trying to LuaRegister is constructed as such:
TestVariable(Variable variable, Variable dc, bool healStam, bool healSanity, bool harmStam, bool harmSanity)
The way it's being called as an example is:
TestVariable(Variable["Physique"], Variable["DCEasy"], true, false, false, false)
But when I attempt to call it as a Script following the instructions to do so as a Custom type, DS runs into an argument exception that 'System.Single' can't be converted to 'DialogueSystem.Variable' before it even reaches the first line of the method itself. I've checked through my code but it seems like I'm using doubles everywhere I can, so I'm not sure where I'm going wrong. A full-text of the method is available at the following link:
Testing variables against random results
Re: Testing variables against random results
Hi,
Lua.RegisterFunction() only registers C# methods that use basic data types -- string, double, and bool. (info)
It looks like you're passing variable values, so you can use doubles, except for the variable name in ModifyStat:
and:
Lua.RegisterFunction() only registers C# methods that use basic data types -- string, double, and bool. (info)
It looks like you're passing variable values, so you can use doubles, except for the variable name in ModifyStat:
Code: Select all
Lua.RegisterFunction("TestVariable", this, SymbolExtensions.GetMethodInfo(() => TestVariable(0, 0, false, false, false, false)));
Lua.RegisterFunction("ModifyStat", this, SymbolExtensions.GetMethodInfo(() => ModifyStat("", 0.0)));
Code: Select all
public void ModifyStat(string variableName, double toModify){
//TODO: Not yet fully implemented
var tgtValue = DialogueLua.GetVariable(variable.Name).asFloat;
DialogueLua.SetVariable(variableName, tgtValue + toModify);
}
public bool TestVariable(double val, doubledc, bool healStam, bool healSanity, bool harmStam, bool harmSanity){
int variableValue = (int)val;
...
}