NOTE: I don't know much about how events work, but I get the general idea. Mods, feel free to move this to Interface Requests if you feel it's better there.
This suggestion is about a way for mods to add their own achievements via an achievements.lua file.
I don't know how the current 0.13 achievements are coded into the game, but some parameters for it would be name, goal, description, and completed.
name is self-explanatory.
goal is a list, possibly of events, like on_player_death or on_tick. This defines what the goal is. When the event is done, it sets completed to true.
description is a string that allows for a short description for an achievement.
completed is a boolean that shows if the achievement is completed.
An example:
Code: Select all
--achievements.lua
data:extend({
{
name = 'rocket-researched',
description = 'You researched the rocket!',
goal = on_research_finished.research.name('rocket-silo'),
completed = false
},
{
name = '10k-belts',
description = '10k belts placed',
goal = belts_placed >= 10000
completed = false
})
belts_placed = 0
if on_robot_built_entity.created_entity.name['transport-belt'] or on_built_entity.created_entity.name['transport-belt'] do
belts_placed = belts_placed + 1
end