Change Int Variable with script


(Carine Rousseau) #1

Hi,
I watched the two videos about the scripts but I don’t understand how to change int variable with script.
I want add 1 to int variable named “pf”.
I tried this :
VinomaSceneController.PerformOperationOnVariable(int pf, VinomaVarOperation.Add = 1);
I don’t know how to program so I do not know which code I have to type, thanks.

It would be nice in the guide on the Vinoma website to have some lines of code examples (set int, string, switch variable, add or substract int variable, hide/show panel and GameObject (I find these on the forum)), but if you just tell me that one I’d already be happy ^^


(Leslie Young) #2

The function in question look lie this…
PerformOperationOnVariable(string varName, string value, string value2, VinomaVarOperation opt)

  • string varName means it wants the variable’s name, which is a string/text value; thus your “pf”
  • string value mean here it wants some value which will be involved with this action. Again, this is passed as string. Since you want to add 1 to the variable you pass “1” here. Yes, it passed as a string. Vinoma actually store all variable data as strings internally, even the integers.
  • string value2 in some cases an operation requires second value. This would be where that value is passed.
  • VinomaVarOperation opt and finally the operation to perform, which is of enum type VinomaVarOperation. This enum consists of constants: Set, Append, Add, Subtract, Multiply, Divide, and Random and you select one by passing VinomaVarOperation.Add or VinomaVarOperation.Divide, etc

So, what you want to write is…
VinomaSceneController.Instance.PerformOperationOnVariable("pf", "1", "", VinomaVarOperation.Add);


(Carine Rousseau) #3

It’s very clear, thank you for your explanation :slight_smile: