UnityScript is my language of choice.
Im trying to write a save/load function, but when i type what ive seen everyone else type it doesnt work, no saving, no loading, it doesnt debug.log and it doesnt error. ive been thinking on this for a few hours and still dont know where to even begin. any thoughts?
and please write in a way thats easy to understand, i have a rough time understanding others. (thats why i STILL cant understand the tutorials i read) replies, especially explaining how code works should be simple or “idiot proof” if you will…
Please and thank you.
this is my code (excluding most things unrelated to the question)
I am trying to copy my variables values and paste into playerprefs i think… and then call the values from the playerprefs later/after restarting the application.
however neither happen and as i said before, no errors in the compiler.
public var playerCurHp : float;
public var playerMaxHp : float;
public var playerCurMp : float;
public var playerMaxMp : float;
public var playerCurExp : float;
public var playerMaxExp : float;
public var playerLevel : float = 1;
public var str : float = 1;
public var atk : float = 1;
public var def : float = 1;
public var vit : float = 1;
public var mag : float = 1;
playerCurHp = 100;
playerMaxHp = 100;
playerCurMp = 100;
playerMaxMp = 100;
playerCurExp = 1;
playerMaxExp = 20;
regenTime = Time.time;
DontDestroyOnLoad(this.gameObject);
if(Input.GetButtonUp("Jump")){
PlayerPrefs.SetFloat("playerLevel", playerLevel);
PlayerPrefs.SetFloat("playerMaxExp", playerMaxExp);
PlayerPrefs.SetFloat("playerCurExp", playerCurExp);
PlayerPrefs.SetFloat("playerMaxHp", playerMaxHp);
PlayerPrefs.SetFloat("playerCurHp", playerCurHp);
PlayerPrefs.SetFloat("playerMaxMp", playerMaxMp);
PlayerPrefs.SetFloat("playerCurMp", playerCurMp);
Debug.Log("1");
}
if(Input.GetButtonUp("MiddleClick")){
playerCurExp = PlayerPrefs.GetFloat("playerLevel");
playerCurExp = PlayerPrefs.GetFloat("playerMaxExp");
playerCurExp = PlayerPrefs.GetFloat("playerCurExp");
playerCurExp = PlayerPrefs.GetFloat("playerMaxHp");
playerCurExp = PlayerPrefs.GetFloat("playerCurHp");
playerCurExp = PlayerPrefs.GetFloat("playerMaxMp");
playerCurExp = PlayerPrefs.GetFloat("playerCurMp");
Debug.Log("2");
}