Achievement file format: Difference between revisions
(Changed links going to the redirect Data_Types to go to Data types.) |
m (→File Format: fix redirect) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
Yes - this information can be used to "cheat" Factorio by simply writing to the achievement file(s) in such a way as if you had met all the achievement requirements, open up Factorio, and then suddenly have all achievements unlocked. The goal of this document is to share how to _read_ the achievement file(s) - so that third party applications can do new and interesting things with that information. Enjoy! | Yes - this information can be used to "cheat" Factorio by simply writing to the achievement file(s) in such a way as if you had met all the achievement requirements, open up Factorio, and then suddenly have all achievements unlocked. The goal of this document is to share how to _read_ the achievement file(s) - so that third party applications can do new and interesting things with that information. Enjoy! | ||
See the page on [[data types]] for an explanation of the different types of data used in this document. | See the page on [[Data_Types|data types]] for an explanation of the different types of data used in this document. | ||
== File Format == | == File Format == | ||
The overall file format is as follows. Note that in this file, [[#array|array]] length is stored as a [[#short|short]], not an [[#int|int]]! | The overall file format is as follows. Note that in this file, [[Data_Types#array|array]] length is stored as a [[Data_Types#short|short]], not an [[Data_Types#int|int]]! | ||
{| class="wikitable" | {| class="wikitable" | ||
! Type !! Description | ! Type !! Description | ||
|- | |- | ||
| [[#short|short]][4] | | [[Data_Types#short|short]][4] | ||
| The [[ | | The [[Version_string_format|version string]] of Factorio that generated this file. | ||
|- | |- | ||
| [[#array|array]]<[[#Achievement Header Info|bytes]]> | | [[Data_Types#array|array]]<[[#Achievement Header Info|bytes]]> | ||
| [[#Achievement Header Info|Achievement header info]]. Variable length. See the section for more information. | | [[#Achievement Header Info|Achievement header info]]. Variable length. See the section for more information. | ||
|- | |- | ||
| [[#array|array]]<[[#Achievement Content Info|bytes]]> | | [[Data_Types#array|array]]<[[#Achievement Content Info|bytes]]> | ||
| [[#Achievement Content Info|Achievement content info]]. Variable length. See the section for more information. | | [[#Achievement Content Info|Achievement content info]]. Variable length. See the section for more information. | ||
|- | |- | ||
| [[#short|short]][*] | | [[Data_Types#short|short]][*] | ||
| Currently tracked achievements, given as a series of [[#short|shorts]] up until the end of the file, with each representing the index number of an achievement. The order of achievements in this series matches the order of which the player has them tracked in game. | | Currently tracked achievements, given as a series of [[Data_Types#short|shorts]] up until the end of the file, with each representing the index number of an achievement. The order of achievements in this series matches the order of which the player has them tracked in game. | ||
|} | |} | ||
This format has been valid since at least version 0.14.x. | This format has been valid since at least version 0.14.x. | ||
Line 34: | Line 34: | ||
! Type !! Description | ! Type !! Description | ||
|- | |- | ||
| [[#string|string]] | | [[Data_Types#string|string]] | ||
| Achievement type. This determines what kind of data fields this achievement contains in the content array. | | Achievement type. This determines what kind of data fields this achievement contains in the content array. | ||
|- | |- | ||
| [[#string|string]] | | [[Data_Types#string|string]] | ||
| Achievement string id - the one used internally by Factorio. | | Achievement string id - the one used internally by Factorio. | ||
|- | |- | ||
| [[#short|short]] | | [[Data_Types#short|short]] | ||
| Achievement index number. This number is used to map achievements between this header info array, the content info array, and the tracked achievements list in this file. These index numbers are non-normative, so they won't always match up with the same achievement.<br> Note: the mapping of index numbers to achievement ids are continuous, but start at index 1 (there is no index 0) - because LUA tables start at 1. | | Achievement index number. This number is used to map achievements between this header info array, the content info array, and the tracked achievements list in this file. These index numbers are non-normative, so they won't always match up with the same achievement.<br> Note: the mapping of index numbers to achievement ids are continuous, but start at index 1 (there is no index 0) - because LUA tables start at 1. | ||
|} | |} | ||
Line 53: | Line 53: | ||
! Type !! Description | ! Type !! Description | ||
|- | |- | ||
| [[#short|short]] | | [[Data_Types#short|short]] | ||
| Achievement index number. This matches up with the index number in the [[#Achievement Header Info|Achievement header info]]. | | Achievement index number. This matches up with the index number in the [[#Achievement Header Info|Achievement header info]]. | ||
|- | |- | ||
Line 75: | Line 75: | ||
* Unknown format, 4 bytes long. | * Unknown format, 4 bytes long. | ||
|- | |- | ||
| [[Prototype/ | | [[Prototype/CombatRobotCountAchievement|combat-robot-count]] | ||
| | | | ||
* [[#int|int]] | * [[Data_Types#int|int]] | ||
| | | | ||
* The greatest number of combat robots you've had following you. | * The greatest number of combat robots you've had following you. | ||
Line 83: | Line 83: | ||
| [[Prototype/ConstructWithRobotsAchievement|construct-with-robots-achievement]] | | [[Prototype/ConstructWithRobotsAchievement|construct-with-robots-achievement]] | ||
| | | | ||
* [[#int|int]] | * [[Data_Types#int|int]] | ||
* byte[4] | * byte[4] | ||
| | | | ||
Line 91: | Line 91: | ||
| [[Prototype/DeconstructWithRobotsAchievement|deconstruct-with-robots-achievement]] | | [[Prototype/DeconstructWithRobotsAchievement|deconstruct-with-robots-achievement]] | ||
| | | | ||
* [[#int|int]] | * [[Data_Types#int|int]] | ||
| | | | ||
* Total number of objects deconstructed using robots. | * Total number of objects deconstructed using robots. | ||
Line 115: | Line 115: | ||
| [[Prototype/DontUseEntityInEnergyProductionAchievement|dont-use-entity-in-energy-production-achievement]] | | [[Prototype/DontUseEntityInEnergyProductionAchievement|dont-use-entity-in-energy-production-achievement]] | ||
| | | | ||
* [[#double|double]] | * [[Data_Types#double|double]] | ||
| | | | ||
* Maximum number of Joules produced per hour, only including power produced from entities listed under "[[Prototype/DontUseEntityInEnergyProductionAchievement#included|included]]", and excluding those listed under "[[Prototype/DontUseEntityInEnergyProductionAchievement#excluded|excluded]]". | * Maximum number of Joules produced per hour, only including power produced from entities listed under "[[Prototype/DontUseEntityInEnergyProductionAchievement#included|included]]", and excluding those listed under "[[Prototype/DontUseEntityInEnergyProductionAchievement#excluded|excluded]]". | ||
Line 133: | Line 133: | ||
| [[Prototype/KillAchievement|kill-achievement]] | | [[Prototype/KillAchievement|kill-achievement]] | ||
| | | | ||
* [[#double|double]] | * [[Data_Types#double|double]] | ||
| | | | ||
* The greatest number of an entity killed (e.g. trees, spawners). | * The greatest number of an entity killed (e.g. trees, spawners). | ||
Line 139: | Line 139: | ||
| [[Prototype/PlayerDamagedAchievement|player-damaged-achievement]] | | [[Prototype/PlayerDamagedAchievement|player-damaged-achievement]] | ||
| | | | ||
* [[#float|float]] | * [[Data_Types#float|float]] | ||
* [[#bool|bool]] | * [[Data_Types#bool|bool]] | ||
| | | | ||
* The maximum amount of damage you've taken in a single hit. | * The maximum amount of damage you've taken in a single hit. | ||
Line 147: | Line 147: | ||
| [[Prototype/ProduceAchievement|produce-achievement]] | | [[Prototype/ProduceAchievement|produce-achievement]] | ||
| | | | ||
* [[#double|double]] | * [[Data_Types#double|double]] | ||
| | | | ||
* The total number of the item you've produced. | * The total number of the item you've produced. | ||
Line 153: | Line 153: | ||
| [[Prototype/ProducePerHourAchievement|produce-per-hour-achievement]] | | [[Prototype/ProducePerHourAchievement|produce-per-hour-achievement]] | ||
| | | | ||
* [[#double|double]] | * [[Data_Types#double|double]] | ||
| | | | ||
* The maximum amount of the item produced per hour. | * The maximum amount of the item produced per hour. | ||
Line 165: | Line 165: | ||
| [[Prototype/TrainPathAchievement|train-path-achievement]] | | [[Prototype/TrainPathAchievement|train-path-achievement]] | ||
| | | | ||
* [[#double|double]] | * [[Data_Types#double|double]] | ||
| | | | ||
* The longest path (in tiles) planned by a train. | * The longest path (in tiles) planned by a train. |
Latest revision as of 04:08, 29 April 2020
This is a technical description of the achievement file format, used by Factorio to store player's achievement progress in the files "achievements.dat" and "achievements-modded.dat".
Yes - this information can be used to "cheat" Factorio by simply writing to the achievement file(s) in such a way as if you had met all the achievement requirements, open up Factorio, and then suddenly have all achievements unlocked. The goal of this document is to share how to _read_ the achievement file(s) - so that third party applications can do new and interesting things with that information. Enjoy!
See the page on data types for an explanation of the different types of data used in this document.
File Format
The overall file format is as follows. Note that in this file, array length is stored as a short, not an int!
Type | Description |
---|---|
short[4] | The version string of Factorio that generated this file. |
array<bytes> | Achievement header info. Variable length. See the section for more information. |
array<bytes> | Achievement content info. Variable length. See the section for more information. |
short[*] | Currently tracked achievements, given as a series of shorts up until the end of the file, with each representing the index number of an achievement. The order of achievements in this series matches the order of which the player has them tracked in game. |
This format has been valid since at least version 0.14.x.
Achievement Header Info
The header contains information about what type of data fields each achievement has.
Type | Description |
---|---|
string | Achievement type. This determines what kind of data fields this achievement contains in the content array. |
string | Achievement string id - the one used internally by Factorio. |
short | Achievement index number. This number is used to map achievements between this header info array, the content info array, and the tracked achievements list in this file. These index numbers are non-normative, so they won't always match up with the same achievement. Note: the mapping of index numbers to achievement ids are continuous, but start at index 1 (there is no index 0) - because LUA tables start at 1. |
Achievement Content Info
This contains the actual data of each achievement. It's important to note that not every achievement listed in the header has a matching content section here.
Also note that this array always ends with an index number of 0. When reading, either ignore this, or manually add in a blank achievement into your meta table at index zero with no fields.
Type | Description |
---|---|
short | Achievement index number. This matches up with the index number in the Achievement header info. |
byte[*] | The achievement's progress information. The structure and length of this is determined by the achievement's type. See the table below for a list of achievement types. |
Achievement Types
If new achievement types are added in the future, the achievement files will be unparse-able. Please add any new types you find here, thanks!
See the Prototype/Achievement base prototype page for more information about achievement structure.
Achievement Type |
Binary Fields(s) |
Field(s) Description |
---|---|---|
build-entity-achievement |
|
|
combat-robot-count |
| |
construct-with-robots-achievement |
|
|
deconstruct-with-robots-achievement |
| |
deliver-by-robots-achievement |
|
|
dont-build-entity-achievement |
TODO |
TODO |
dont-craft-manually-achievement |
TODO |
TODO |
dont-use-entity-in-energy-production-achievement | ||
finish-the-game-achievement |
TODO |
TODO |
group-attack-achievement |
|
|
kill-achievement |
| |
player-damaged-achievement |
| |
produce-achievement |
| |
produce-per-hour-achievement |
| |
research-achievement |
|
|
train-path-achievement |
|
"combat-robot-count" is currently the only achievement type that doesn't end in "-achievement". This is not an error.