Difference between revisions of "LuaAPI/wesnoth/achievements"

From The Battle for Wesnoth Wiki
Line 1: Line 1:
 
<div class="tright"> __TOC__ </div>
 
<div class="tright"> __TOC__ </div>
 +
 +
{{DevFeature1.17|13}}
  
 
== Achievements ==
 
== Achievements ==
 +
 +
=== wesnoth.achievements.set ===
 +
 +
* {{LuaGameOnly}} '''wesnoth.achievements.set'''(''content_for'',''id'')
 +
 +
* '''content_for''': The [[AchievementsWML|[achievements_group]]] that this achievement is part of.
 +
* '''id''': The id of the achievement.
 +
 +
Sets the specified achievement as completed. Unlike the [set_achievement] tag, this does not display a popup.
 +
 +
=== wesnoth.achievements.has → ''achieved?'' ===
 +
 +
* {{LuaGameOnly}} '''wesnoth.achievements.has'''(''content_for'',''id'')
 +
 +
* '''content_for''': The [[AchievementsWML|[achievements_group]]] that this achievement is part of.
 +
* '''id''': The id of the achievement.
 +
 +
Returns whether the specified achievement has been completed.
 +
 +
'''NOTE:''' This is not safe to use in online multiplayer since different players can have different achievements completed. As such it will always be treated as if the achievement is not completed.
 +
 +
=== wesnoth.achievements.get ===
 +
 +
* {{LuaGameOnly}} '''wesnoth.achievements.get'''(''content_for'',''id'') → ''cfg''
 +
 +
* '''content_for''': The [[AchievementsWML|[achievements_group]]] that this achievement is part of.
 +
* '''id''': The id of the achievement.
 +
 +
'''NOTE:''' While this can be used to retrieve the achievement's actual achievement status for a client in online multiplayer, this is also not safe to use in that situation for the same reason.

Revision as of 05:47, 22 January 2023

(Version 1.17.13 and later only)

Achievements

wesnoth.achievements.set

  • wesnoth.achievements.set(content_for,id)
  • content_for: The [achievements_group] that this achievement is part of.
  • id: The id of the achievement.

Sets the specified achievement as completed. Unlike the [set_achievement] tag, this does not display a popup.

wesnoth.achievements.has → achieved?

  • wesnoth.achievements.has(content_for,id)
  • content_for: The [achievements_group] that this achievement is part of.
  • id: The id of the achievement.

Returns whether the specified achievement has been completed.

NOTE: This is not safe to use in online multiplayer since different players can have different achievements completed. As such it will always be treated as if the achievement is not completed.

wesnoth.achievements.get

  • wesnoth.achievements.get(content_for,id) → cfg
  • content_for: The [achievements_group] that this achievement is part of.
  • id: The id of the achievement.

NOTE: While this can be used to retrieve the achievement's actual achievement status for a client in online multiplayer, this is also not safe to use in that situation for the same reason.