Skip to content

Latest commit

 

History

History
1067 lines (949 loc) · 26.7 KB

Text-Styling.md

File metadata and controls

1067 lines (949 loc) · 26.7 KB

Text Styling

Balatro includes a very basic formatting syntax for styling and formatting displayed text in-game. Where supported, text can be styled with the use of style modifier codes included within the text string. For example, the text string:

{C:blue}+1{} hand     

produces

+1 hand

Most SMODS objects that display description text will parse and style text strings automatically when loading from localization files or loc_txt. This includes the text strings of descriptions for Achievements, Consumables, Decks, Jokers, Vouchers, and more.

Style modifiers are not additive - text will only be styled by the modifiers contained within the previous set of curly braces. Using empty braces {} will reset text styling for text after it.

Additionally, multiple modifiers can be combined in a single set of curly braces. For example, the text string:

{X:mult,C:white}X0.5{}     

produces

X0.5

Valid style modifiers are as follows:

Defined text colour {C:colour-key}
Defined background colour {X:colour-key}
Variable/custom text colour {V:colour-index}
Variable/custom background colour {B:colour-index}
Text motion {E:motion-index}
Text hover tooltip {T:tooltip-key}
Text scale {s:scale}
No modifiers (use default styling) {}

Important

Modifiers are case sensitive{s:} must be lowercase, while all other modifiers are UPPERCASE.


Defined text colour modifier {C:}

{C:colour-key} changes the color of the text, where colour-key is the key of a colour defined in G.ARGS.LOC_COLOURS.

Examples

Text string loc_vars Result
{C:mult}+4{} Mult
+4 Mult
{C:attention}1{} free {C:green}Reroll{}
1 free Reroll
{C:green}#1# іn #2#{} chance     
vars = {
  G.GAME.probabilities.normal, -- 1
  card.ability.extra.odds      -- 6
}
1 in 6 chance

Defined background colour modifier {X:}

{X:colour-key} sets the background color of the text, where colour-key is the key of a colour defined in G.ARGS.LOC_COLOURS.

This modifier is usually combined with the text colour modifier to make X3 Mult labels.

This modifier uniquely strips all whitespace from the styled text, so text like {X:gold} W I D E {} is rendered as WIDE. This can be helpful for improving the readability of otherwise dense strings.

Examples

Text string loc_vars Result
{X:mult,C:white}X3{} Mult{}
X3 Mult
{X:chips,C:white} X 1 . 5 {} Chips{}
X1.5 Chips
{X:mult,C:white} X#1# {}     
vars = {
  card.ability.extra.xmult -- 0.5
}
X0.5

Variable/custom text colour modifier {V:}

{V:index} changes the colour of the text to a custom colour provided as an entry in the loc_vars vars.colours table. See Localization for more details.

index is the array index of the colour entry in the vars.colours table.

Examples

Text string loc_vars Result
{V:1}FF00FF{}
vars = {
  colours = { HEX("#FF00FF") }
}
FF00FF
{V:2}#2#{} suit{}     
vars = {
  "Spade",
  "Heart",
  "Club",
  "Diamond",
  colours = { 
    G.C.SUITS.Spades,
    G.C.SUITS.Hearts,
    G.C.SUITS.Clubs,
    G.C.SUITS.Diamonds
  }
}
Heart suit

Variable/custom background colour modifier {B:}

Note

This modifier is added by Steamodded and is not supported by vanilla Balatro.

{B:index} changes the colour of the background to a custom colour provided as an entry in the loc_vars vars.colours table. See Localization for more details.

index is the array index of the colour entry in the vars.colours table.

Unlike the similar Defined background modifier {X:}, {B:} does not remove or change the whitespace of styled text, so displayed contents will remain the same as their input string.

Examples

Text string loc_vars Result
{B:1}00FF00{}
vars = {
  colours = { HEX("#00FF00") }
}
00FF00
{B:1,V:2}Oh no!{} Anyway... 
vars = {
  colours = { 
    {1, 0, 0, 1}, --#FF0000
    {0, 0, 0, 1}  --#000000
  }
}
Oh no! Anyway...
{B:1,V:2}#1#{B:2,V:1}#2#{}     
vars = {
  "Spa",
  "rts",
  colours = { 
    G.C.SUITS.Spades,
    G.C.SUITS.Hearts,
  }
}
Sparts

Text motion modifier {E:}

{E:1} applies a floating animation to each letter in the text.

{E:2} applies a bumping animation to each letter in sequence.

Examples

Text string Result
{C:green,E:1}probabilities{}     
probabilities
{E:2}Joker{}
Joker
{C:red,E:2}self destructs{}
self destructs

Text hover tooltip modifier {T:}

{T:tooltip-key} adds tooltip functionality to the text, which displays a small tooltip UI above the text when the text is hovered over.

tooltip-key must be the name of a key found in either G.P_CENTERS or G.P_TAGS. See the entries in the SMODS.Center category and SMODS.Tag for more.

Examples

Text string Result


{C:tarot,T:v_crystal_ball}Crystal Ball{}     
Crystal Ball with Tooltip Animation

Text scale modifier {s:}

Important

This modifier requires the lowercase s, unlike other modifiers which must be UPPERCASE.

{s:scale} changes the size of the text.

scale is a decimal value where the default size is 1.0.

Vanilla Balatro only uses s:0.8, s:0.85 and s:1.1 text scales.

Examples

Text string Result
{s:0.8}0.8 {s:1.0}1.0 {s:1.1}1.1{}     
0.8 1.0 1.1

Combinations

Some style codes can be combined within one set of curly braces, like {X:mult,C:white}.

  • {T:} and {s:} are compatible with all other modifiers.

  • Background modifiers {X:} or {B:} can be used in conjunction with text colour modifiers {C:} or {V:}.

  • {C:} and {V:} are exclusive - if both are used, {C:} will be ignored.

  • {X:} and {B:} are exclusive - if both are used, {X:} will be ignored.

Examples

Text string loc_vars Result
{X:mult,C:white}X0.5{}
X0.5
{C:edition,E:1,s:2}YOU WIN!{}
YOU WIN!
{s:0.8}({V:1,s:0.8}lvl.#1#     
{s:0.8}){} Level up{}
vars = {
  G.GAME.hands[card.config.hand_type].level,
  colours = { 
    G.C.HAND_LEVELS[math.min(7,
      G.GAME.hands[card.config.hand_type].level
    )]
  }
}
(lvl.2) Level up)

Named colours dictionary (G.ARGS.LOC_COLOURS)

Colour Key Value Example Note
#FE5F55FF red G.C.RED +1 discard
#FE5F55FF mult G.C.MULT +4 Mult
#009DFFFF blue G.C.BLUE +1 hand
#009DFFFF chips G.C.CHIPS +50 Chips
#4BC292FF green G.C.GREEN 1 in 6 chance
#F3B958FF money G.C.MONEY Earn $4
#EAC058FF gold G.C.GOLD Earn $4
#FF9A00FF attention G.C.FILTER +1 hand size
#8867A5FF purple G.C.PURPLE Purple Seal
#FFFFFFFF white G.C.WHITE Joker
#88888899 inactive G.C.INACTIVE (Must have room)
#403995FF/#4F31B9FF spades G.C.SUITS.Spades Spades Suit colours
affected by
High Contrast
setting
#F03464FF/#F83B2FFF hearts G.C.SUITS.Hearts Hearts
#235955FF/#008EE6FF clubs G.C.SUITS.Clubs Clubs
#F06B3FFF/#E29000FF diamonds G.C.SUITS.Diamonds Diamonds
#A782D1FF tarot G.C.SECONDARY_SET.Tarot Tarot card
#13AFCEFF planet G.C.SECONDARY_SET.Planet Planet card
#4584FAFF spectral G.C.SECONDARY_SET.Spectral Spectral card
EDITION edition G.C.EDITION YOU WIN! Animated colours
DARK EDITION dark_edition G.C.DARK_EDITION Add Negative
#009DFFFF common G.C.RARITY.Common Added by
Steamodded
#4BC292FF uncommon G.C.RARITY.Uncommon
#FE5F55FF rare G.C.RARITY.Rare
#B26CBBFF legendary G.C.RARITY[4] or
G.C.RARITY.Legendary
Legendary Joker
#8389DDFF enhanced G.C.SECONDARY_SET.Enhanced Enhancement
#4F6367FF default G.C.UI.TEXT_DARK Joker

This dictionary is initially assigned by the loc_colour function in functions/misc_functions.lua.

Steamodded automatically adds additional entries to LOC_COLOURS for all custom objects in:

which can be used as colour keys in the same way by {C:} and {X:}. When referring to custom Rarity, Gradient, Consumable or Suit colours added by SMODS, the key must be prefixed with the mod prefix.