Psych Engine Logo
Psych Engine - Lua Script API

Achievements Functions

Functions to make softcoded Achievements.


getAchievementScore

getAchievementScore(name:String):Float

Returns the score for Achievements with counters (like "Roadkill Enthusiast").
Returns -1 and throws an error if the Achievement couldn't be found.

Examples:


setAchievementScore

setAchievementScore(name:String, ?value:Float = 0, ?saveIfNotUnlocked:Bool = true):Float

Sets the score for Achievements with counters (like "Roadkill Enthusiast") and returns its new value.
Returns -1 and throws an error if the Achievement couldn't be found.

Examples:


addAchievementScore

addAchievementScore(name:String, ?value:Float = 1, ?saveIfNotUnlocked:Bool = true):Float

Adds score for Achievements with counters (like "Roadkill Enthusiast") and returns its new value.
Returns -1 and throws an error if the Achievement couldn't be found.

Examples:


unlockAchievement

unlockAchievement(name:String):String

Unlocks a named achievement and returns its name, returns null if already unlocked.
Throws an error if achievement doesn't exist and returns null.

Examples:


isAchievementUnlocked

isAchievementUnlocked(name:String):Dynamic

Checks if achievement is unlocked and returns true/false for it.
Returns null and throws an error if achievement doesn't exist.


achievementExists

achievementExists(name:String):Bool

Checks if achievement exists returns true/false for it.