-
Notifications
You must be signed in to change notification settings - Fork 21
String identifiers
In-game and during client-server communications most entity types are represented as an integer identifier e.g 17937 - Naïve bloodrager pouch
At the borders between these boundaries the integer is replaced by a human-readable string equivalent.
Removing magic numbers makes code immediately more readable.
if (npc.id == "bob" && option == "Trade") {
player.openShop("bobs_brilliant_axes")
}
if (npc.id == 519 && option == 2) {
player.openShop(1)
}
Note
Integer ids can still be obtained from the relevant definition class e.g. npc.def.id
A string id should follow the following formatting rules to keep them standardised.
- Lowercase
- Underscores not spaces
- Ascii equivalents of diacritics (accents)
- "and" instead of "&"
- All symbols removed
Naïve bloodrager pouch
->naive_bloodrager_pouch
Magic potion (3)
->magic_potion_3
In cases where there is no string id the integer id can be used as a string.
The majority of ids are generated from formatting their cache names.
If there is no known information to separate duplicate ids the second id onwards has a number suffix (i.e first one has no suffix, second one has 2, third 3, etc...)