Simplest way that I discovered is usage of existing config system API. Let's present its usage on simple temporary leaderboard system that I use:
- create a new config file (for example MyLevelLeaderboard.ini)
- create script file that specifies its content
1: Class LevelLeaderboard extends Object
2: PerObjectConfig
3: Config(MyLevelLeaderboard);
4:
5: var config float bestTime; //specify variables
6: var config int bestScore;
7: var config int bestSteps;
- access and edit data via script
1: local LevelLeaderboard LL;
2:
3: //load old bests (for current level), creates file if not existing
4: //second parameter specifies subsection name in ini file
5: LL = new(None,WorldInfo.GetMapName(false)) class'LevelLeaderboard';
6:
7: //update values
8: LL.bestTime = FMin(totalTime,LL.bestTime);
9: LL.bestScore = FMax(totalScore,LL.bestScore);
10: LL.bestSteps = FMin(totalSteps,LL.bestSteps);
11: LL.SaveConfig(); //save changes
- resulting MyLevelLeaderboard.ini file looks like this
1: [testlevel1 LevelLeaderboard]
2: bestTime=73.390839
3: bestScore=4600
4: bestSteps=218
5:
6: [testlevelpuzzles LevelLeaderboard]
7: bestTime=2.615733
8: bestScore=100
9: bestSteps=3
10:
11: [simplelevel LevelLeaderboard]
12: bestTime=95.921692
13: bestScore=6700
14: bestSteps=336
No comments:
Post a Comment