Custom Variable Cnfrontation

Using Naninovel C# APIs: adding custom actor implementations or commands, overriding engine services, integrating with other systems, etc.
Post Reply
drunkrobot
Posts: 17
Joined: 14 Jul 2020 16:52

Custom Variable Cnfrontation

Post by drunkrobot »

Hi I taked a naninovel custom variable from c# with this method:
public Naninovel.CustomVariableManager G_PunteggioMC = Engine.GetService<Naninovel.CustomVariableManager>();
void SetVariableValue()
{
G_PunteggioMC.SetVariableValue("G_PunteggioMC", Mathf.RoundToInt(scoreCount).ToString());

My problem it's that i'm tryng to confront it with other naninovel custom variable that are number, while this is a string and the SetVariableValue command accepts only a string for value.
How can i do this confrontation? There is a way in naninovel to do the typecast of the number to the string or also better of the string to the number?
Thanks for help.

Elringus
admin
Posts: 521
Joined: 11 May 2020 18:03

Re: Custom Variable Cnfrontation

Post by Elringus »

Just parse the string to the required type and then cast it back to string when saving. All the custom variable values are stored as strings in Naninovel.

drunkrobot
Posts: 17
Joined: 14 Jul 2020 16:52

Re: Custom Variable Cnfrontation

Post by drunkrobot »

But there is a way to do it in Naninovel script or i have to do it in c# ?

Elringus
admin
Posts: 521
Joined: 11 May 2020 18:03

Re: Custom Variable Cnfrontation

Post by Elringus »

In naninovel the conversion is performed automatically.

drunkrobot
Posts: 17
Joined: 14 Jul 2020 16:52

Re: Custom Variable Cnfrontation

Post by drunkrobot »

oh ok so i am doing somethings else wrong, thank you

Post Reply