Save files

32 views
Skip to first unread message

Ca3m0n 0_0

unread,
Oct 5, 2016, 10:29:34 AM10/5/16
to DroidScript
I am making a game, I need to know how the easiest way to save multiple variables. Such as coins that was earned, other recourses and position in the game like progress. I know how to do all that but how can I save all the variables in a private folder?

Robbie Kendall

unread,
Oct 5, 2016, 10:37:41 AM10/5/16
to DroidScript
I'm not sure how it's done myself but The cookie clicker game saved money and upgrades/resources so if you download it you may be able to see how it was done.

Steve Garman

unread,
Oct 5, 2016, 10:37:58 AM10/5/16
to DroidScript
There are a couple of ways.


var coins = 20;
//either
var fldr = app.GetPrivateFolder( "data" );
app.WriteFile( fldr + "/coins", coins );

//or else
app.SaveNumber( "coins", coins );

Symbroson Development

unread,
Oct 5, 2016, 10:44:49 AM10/5/16
to DroidScript
I think the second way is beter because it is more secure

Steve Garman

unread,
Oct 5, 2016, 10:49:41 AM10/5/16
to DroidScript
Both methods are equally secure.

They both write to the app's private space.

The first way is more flexible as it actually writes a file, instead of a value in a database.
It is especially useful if you want to save something that is not text, a number or a boolean value.

Reply all
Reply to author
Forward
0 new messages