NML:Badges: Difference between revisions
Simple site for badges |
m Add nml since. |
||
| (8 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
{{NMLNavPropVarCB}} |
{{NMLNavPropVarCB}} |
||
'''Since''' {{ottd|15.0}} |
'''Since''' {{ottd|15.0}} {{nml|0.9.0}} |
||
item (FEAT_BADGES, item_name) { ... } |
item (FEAT_BADGES, item_name) { ... } |
||
| Line 14: | Line 14: | ||
| label |
| label |
||
| string with <code style="color:green">/</code> as delimiter |
| string with <code style="color:green">/</code> as delimiter |
||
| ''' For sake of compatibility and user experience, consider using [[NML:Badge labels|labels already introduced]] by other NewGRFs.''' |
|||
Badges with label without <code style="color:green">/</code> are considered to be classes. |
|||
Labels for other badges should match following syntax: |
Labels for other badges should match following syntax: |
||
<code style="color:green">"label_of_class_they_belong_to/label_for_the_badge"</code> |
<code style="color:green">"label_of_class_they_belong_to/label_for_the_badge"</code> |
||
| Line 21: | Line 22: | ||
| string |
| string |
||
| Name of this badge or badge class. |
| Name of this badge or badge class. |
||
|- |
|||
| flags |
|||
| bitmask(BADGE_FLAG_XXX, ...); |
|||
| |
|||
; COPY_TO_RELATED_ENTITY |
|||
: Badge can be copied to related entity (e.g. badge on a railtype can be copied to rail vehicles of that railtype.) |
|||
; NAME_LIST_STOP |
|||
: Stops adding more names to the visible name list. |
|||
; NAME_LIST_FIRST_ONLY |
|||
: Add this name to the visible name list only if this is the first name. |
|||
; USE_COMPANY_COLOUR |
|||
: Recolour badge depending on company that player currently controls. |
|||
; NAME_SKIP |
|||
: Allow the badge to be excluded from the badge name list. |
|||
|} |
|} |
||
| Line 29: | Line 44: | ||
! value range |
! value range |
||
! comment |
! comment |
||
|- |
|||
| intro_date |
|||
| date(yyyy, mm, dd) |
|||
| Introduction date of entity (or current date if entity type does not have an introduction date). See <code style="color: green">introduction_date</code> in [[NML:Vehicles#Properties common to all vehicle types|vehicle properties]]. |
|||
|} |
|} |
||
== Badge callbacks == |
== Badge callbacks == |
||
'''Note: By design badges are meant to only be up to 12 pixels tall.''' |
|||
{| class="wikitable sortable" |
{| class="wikitable sortable" |
||
| Line 41: | Line 62: | ||
| spriteset |
| spriteset |
||
| Graphics for the badge or badge class. |
| Graphics for the badge or badge class. |
||
|- |
|||
| |
|||
aircraft<br> |
|||
airports<br> |
|||
airporttiles<br> |
|||
houses<br> |
|||
industries<br> |
|||
industrytiles<br> |
|||
objects<br> |
|||
railtypes<br> |
|||
roadstops<br> |
|||
roadtypes<br> |
|||
roadvehs<br> |
|||
ships<br> |
|||
stations<br> |
|||
trains<br> |
|||
tramtypes<br> |
|||
| spriteset |
|||
| Override default graphics when used by other specific feature. |
|||
|} |
|} |
||
== Prerequisites == |
|||
Badges require a [[NML:Badgetable|badgetable]] to be defined for most common usage scenarios (eg to refer to a badge from an item block). This is not a hard requirement and can be omitted if you are, for example, creating badges that other newGRFs can later refer to |
|||
Eg for <code style="color:green">power/diesel</code> to be used in the badges property for a vehicle, the badge table must contain entries for both <code style="color:green">power</code> and <code style="color:green">power/diesel</code> |
|||
== Example code == |
== Example code == |
||
<pre style="color:blue"> |
<pre style="color:blue"> |
||
badgetable { |
|||
"power", |
|||
"power/diesel", |
|||
"power/steam" |
|||
} |
|||
item (FEAT_BADGES, power) { |
item (FEAT_BADGES, power) { |
||
property { |
property { |
||
| Line 53: | Line 106: | ||
} |
} |
||
# This badge will not show a sprite in the purchase menu |
|||
item (FEAT_BADGES, diesel) { |
item (FEAT_BADGES, diesel) { |
||
property { |
property { |
||
| Line 60: | Line 114: | ||
} |
} |
||
# This badge will show a sprite in the purchase menu |
|||
item (FEAT_BADGES, steam) { |
item (FEAT_BADGES, steam) { |
||
property { |
property { |
||
Latest revision as of 14:34, 15 April 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.
| 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
Badges require a badgetable to be defined for most common usage scenarios (eg to refer to a badge from an item block). This is not a hard requirement and can be omitted if you are, for example, creating badges that other newGRFs can later refer to
Eg for power/diesel to be used in the badges property for a vehicle, the badge table must contain entries for both power and 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;
}
}