NML:Badges: Difference between revisions
→Prerequisites: Remove misinformation about having to define badge classes in badge tables |
→Badge callbacks: Add comment about maximum badge width |
||
| Line 52: | Line 52: | ||
== Badge callbacks == |
== Badge callbacks == |
||
'''Note: By design badges are meant to only be up to 12 pixels tall.''' |
'''Note: By design badges are meant to only be up to 12 pixels tall, and up to 24 pixels wide. Sprites larger than this may overlap or be clipped.''' |
||
{| class="wikitable sortable" |
{| class="wikitable sortable" |
||
Latest revision as of 20:48, 5 May 2026
Vehicles, Stations, Roadstops, Canals, Towns, Houses, Industries (Tiles), Cargos, Airports+Tiles, Objects, Railtypes, Roadtypes, Tramtypes, Bridges, Badges, Terrain
- common props | vars | CBs
- train | roadveh | ship | aircr props
- common variables
- industry props | vars | CBs
- tile props | vars | CBs
- airport props | vars | CBs
- tile props | vars | CBs
item (FEAT_BADGES, item_name) { ... }
Badge properties
| property | value range | comment |
|---|---|---|
| label | string with / as delimiter
|
For sake of compatibility and user experience, consider using labels already introduced by other NewGRFs.
Badges with label without |
| name | string | Name of this badge or badge class. |
| flags | bitmask(BADGE_FLAG_XXX, ...); |
|
Badge variables
| name | value range | comment |
|---|---|---|
| intro_date | date(yyyy, mm, dd) | Introduction date of entity (or current date if entity type does not have an introduction date). See introduction_date in vehicle properties.
|
Badge callbacks
Note: By design badges are meant to only be up to 12 pixels tall, and up to 24 pixels wide. Sprites larger than this may overlap or be clipped.
| callback | return value | comment |
|---|---|---|
| default | spriteset | Graphics for the badge or badge class. |
|
aircraft |
spriteset | Override default graphics when used by other specific feature. |
Prerequisites
A badgetable is required to reference badges (e.g. to refer to a badge from an item block). No badgetable is required for NewGRFs that only define sets of badges, but do not use them.
Eg for power/diesel to be used in the badges property for a vehicle, the badge table must contain an entry for power/diesel
Example code
badgetable {
"power",
"power/diesel",
"power/steam"
}
item (FEAT_BADGES, power) {
property {
label: "power";
name: string(STR_POWER);
}
}
# This badge will not show a sprite in the purchase menu
item (FEAT_BADGES, diesel) {
property {
label: "power/diesel";
name: string(STR_POWER_DIESEL);
}
}
# This badge will show a sprite in the purchase menu
item (FEAT_BADGES, steam) {
property {
label: "power/steam";
name: string(STR_POWER_STEAM);
}
graphics {
default: sprite_steam;
}
}