Loadstring problem

Monkey Targets Forums/Android/Loadstring problem

jayparker(Posted 2014) [#1]
I try to load some game data with LoadString(). I need to do this two times in a row, and first time I use Loadstring(), I get my data. But the second time I get nothing. And I use mojo.loadstring()

Html5 works fine.


Paul - Taiphoz(Posted 2014) [#2]
Try looking at LoadState if your just saving out some game settings or stats.. Load and SaveState that is.

If your using a Framework like diddy then it probably has a Fake Filesystem class which makes saving out and loading in of data via state's a walk in the park.


jayparker(Posted 2014) [#3]
The files I'm trying to load is .txt files and contains level map etc. stuff. I use diddy.filesystem for save/load game and prefs, what works fine.


Capn Lee(Posted 2014) [#4]
can you provide example code of the problem?


jayparker(Posted 2014) [#5]
Here's my level class. I removed some code, but this is the main structure.
In main program I call first cLevel.Load_Mission_Data(1) after this player can select a vehicle and after that I call cLevel.Load_Map(1,"0101").

As I said before, all this works on HTML5, but not in Android. If I remove cLevel.Load_Mission_Data(1) and leave the second call, I get my data what I want.

'********************************************* ** *  *
'*** LEVEL class
'************************************************  **  *
Class cLevel
		
	'********************************************* ** *  *
	'*** Load mission data
	'************************************************  **  *

	Function Load_Mission_Data(campaign_id:Int)

		level_data=LoadString("campaign/"+campaign_id+"/missions.txt")

		If level_data

			For Local line:String=EachIn level_data.Split("~n")


			Next
		EndIf
						
	End Function

	
	'********************************************* ** *  *
	'*** Load map
	'************************************************  **  *
	Function Load_Map(campaign_id:Int,map_file:String)
	
		Local x:Int,y:Int
		map_data=LoadString("campaign/"+campaign_id+"/map/"+map_file+".txt")
		
		If map_data
					
		EndIf
		
	End Function
		
End Class



jayparker(Posted 2014) [#6]
brl.datastream solved the problem!