Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function LoadStats(){
- //try to read the SaveFile
- try {
- //gets the last Loaded file witch is stored in the registry
- FilePath = PlayerPrefs.GetString("LastLoadedFile");
- sr = new StreamReader(FilePath);
- var fileContents = sr.ReadToEnd();
- //print("fine:for splitting"); debugging statement
- lines = fileContents.Split(["\n"],System.StringSplitOptions.RemoveEmptyEntries);
- //print("fine:for print loop"); debugging statement
- for(var i=0;i<lines.Length;i++){
- var data:String[] = lines[i].Replace(";","").Split(["="],System.StringSplitOptions.RemoveEmptyEntries);
- var name:String = data[0];
- //print("names" +data[0]); debugging statement
- //print("values"+data[1]); debugging statement
- //Debug.Log("Isworking" + data[1]); debugging statement
- //Debug.Log(data[1].Substring(0, 1)); debugging statement
- if(data[1].Substring(0,1)!="\""){
- values = parseInt(data[1]);
- //Debug.Log(name + "->" + values);
- var index: int = FindIndex(StatNames, name);
- print(index);
- if(!(index==-1)){
- CurValue[index]=values;
- //Debug.Log("got here");
- }
- }
- if((data[1].Substring(0,1)=="\"")){
- data[1] = data[1].Replace("\"","");
- //this line replaces the " symbol
- //print(data[1]);
- PlayerName=data[1];
- //More Sorting Parameters Here
- //data[1] = data[1].Replace(".");
- }
- }
- }
- catch (e) {
- // Let the user know what went wrong.
- print("The file could not be read:");
- print(e.Message);
- return;
- }
- }
- function FindIndex(list:String[], name:String):int {
- //return list.IndexOf(list,name);
- for (var i:int=0; i<list.Length;i++) {
- if (list[i] == name) return i;
- }
- return -1;
- }
Add Comment
Please, Sign In to add comment