playMaker

Author Topic: Saved!  (Read 3191 times)

VictorRayDev

  • Playmaker Newbie
  • *
  • Posts: 35
Saved!
« on: April 23, 2013, 02:24:33 PM »
Hi!
Can someone help me on this one?
https://www.assetstore.unity3d.com/#/content/4739
I think it most be simple. here is the code that call them.
LevelDefinition ld = PrefHelper.GetLevelDefintion(“Level01”);
// Retrieve the player score as a string, even when it is defined as an integer.
String playerScoreAsString = ld[“iPlayerScore”];
// Convert the string to an integer, add 100 and place it back into the indexer as a string.
int newPlayerScore = ( Convert.ToInt(playerScoreAsString) + 100 );
ld[“iPlayerScore”] = newPlayerScore.ToString();
ld.SaveToPrefs();
Reading and Writing Values as T
Since you’ve done your job when setting up the database definition and you strong typed your keys we can manage the PlayerPrefs much easier using generics.
LevelDefinition ld = PrefHelper.GetLevelDefintion(“Level01”);
// Retrieve the player score as an int.
int playerScore = ld.GetValue<int>(“iPlayerScore”);
// Add 100 and place it back.
int newPlayerScore = playerScore + 100; ld.SetValue<int>(“iPlayerScore”, newPlayerScore); ld.SaveToPrefs();

thx!!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Saved!
« Reply #1 on: April 23, 2013, 03:09:05 PM »
Hi,

 You will need to create custom actions for this, namely being able to get a property of a levelDefinition.

Is that the problem for you or is it the other part of that script?

 bye,

 Jean

VictorRayDev

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Saved!
« Reply #2 on: April 23, 2013, 03:13:28 PM »
the problem is that i'm too noob to write custom action :p
do you know a good tutorial or pointing me in the right direction?
« Last Edit: April 23, 2013, 03:21:52 PM by drfantome »