Hi guys,
I'm trying to write a custom persistent data script, I've got the variables to save, but how do i load them as integers for application?
Loading saved variables as integers
Re: Loading saved variables as integers
Hi,
Use DialogueLua.GetVariable and DialogueLua.SetVariable. Add ".AsInt" to the end of the GetVariable function to get the variable as an integer.
Use DialogueLua.GetVariable and DialogueLua.SetVariable. Add ".AsInt" to the end of the GetVariable function to get the variable as an integer.
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class MyImportantNumberScript : MonoBehaviour {
public int myNumber;
void OnRecordPersistentData() {
DialogueLua.SetVariable("MyNum", myNumber);
}
void OnApplyPersistentData() {
myNumber = DialogueLua.GetVariable("MyNum").AsInt;
}
}