Skip to content

Commit

Permalink
Update Adding-a-New-Achievement.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Nov 21, 2024
1 parent 02ba525 commit f5a9934
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/Adding-a-New-Achievement.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,33 @@ Now, you simply need an icon for your achievement. Your icon should be in `asset
I recommend that the image's size should be a square, preferably `150 x 150`.

## Unlocking your Achievement
To actually be able to unlock your custom achievement, you can do it through [scripting](https://github.com/Joalor64GH/Rhythmo-SC/wiki/Scripting). <br>
To actually be able to unlock your custom achievement, you can do it through [scripting](https://github.com/Joalor64GH/Rhythmo-SC/wiki/Scripting).

Example:
```hx
import('states.PlayState');
import('backend.Achievements');
var condition:Bool = false;
var allowEndSong:Bool = false;
function update(elapsed:Float) {
if (PlayState.instance.score >= 1000000)
condition = true;
}
function endSong() {
if (condition) {
if (!allowEndSong && condition) {
Achievements.unlock('road_to_a_million', {
date: Date.now(),
song: PlayState.song.song
}, {
trace('achievement unlocked successfully!');
});
}
allowEndSong = true;
return Function_Stop;
} else
return Function_Continue;
}
```

0 comments on commit f5a9934

Please sign in to comment.