Highscore: Local Highscore

PreviousNext

Overview

If you want to have a highscore that only has to work locally, you can use EM_LOCAL_HIGHSCORE

Creating the highscore

When using make to create the highscore, the highscore will support "name" and "score" as entries. If you want to have more entries, you can create the highscore using make_extended which lets you specify additional keys.

Read local Highscore

You can read the local highscore simply by using the feature read_local.
You don't have to care where the file is read from or written to, however you can specify that location using set_local_file. The default location is a path taken from EM_USER_DIRECTORY.

Access and modify local Highscore

After reading the highscore, you can sort it, crop it and access items. The local highscore is accessible with the attribute local_highscore. The local highscore has the features name, score as well as item to access items when you created an extended highscore.
There is more than one way to add new entries to the highscore. When using the feature add_entry, the new entry will simply be added, even if there's already an equal entry in the highscore. The feature update_entry searches for an entry with the same name and updates it if the new score is better or equal. In order to use this feature you must make sure that an entry with the same name already exists (using has_entry).
The simplest way to add an entry is to use the feature add_or_update_entry, which will add the entry if it doesn't exist yet or update it otherwise.

Note: If you created the highscore using make_extended, you have to use add_entry_extended, update_entry_extended and add_or_update_entry_extended.

Write local Highscore

To write the highscore to disc, you can simply use write_local.