🧢XTASK.desc

Specifies the description that will appear below the title of an achievement.

▸ Data Type

string

▸ Description

This value will show a description below the title of each achievement. It would be a brief summary of what the player must do in order to complete the achievement.

▸ Example

XTASK.desc = sf( 'Play on the server when there\'s %s or more people. (Bots don\'t count)', tostring( XTASK.param_extra ) )

▸ Structuring String

A string is text that is surrounded by quotation marks.

The description above tells the player they must play on the server with %s players or more.

In-game, the %s will be replaced with the actual number of players required to complete the achievement.

If we break the code apart; it means:

sf is a shortcut for string.format-- you can click here to read about this function on the official Garry's Mod Wiki.

At the end of our string.format; we have placed tostring( XTASK.param_extra )

When the code is ran in-game, %s will be replaced with the value specified for XTASK.params_extra:

XTASK.maxreq        = 1
XTASK.param_extra   = 60
XTASK.desc          = sf( 'Play on the server when there\'s %s or more people. (Bots don\'t count)', tostring( XTASK.param_extra ) )

%s is replaced with 60

string.format example:

sf( 'I like to eat %s and %s.', 'apples', 'bananas' )

The first %s will be replaced with apples; the second %s will be replaced with bananas.

In-game; you see the following:

I like to eat apples and bananas.

▸ Escaping Characters

Finally, backslashes were inserted in the description:

'(Bots don\'t count)'

\ character should be placed before an apostrophe to escape the character or you will receive errors. This can be avoided if you write the string using double quotation marks. Since the beginning of the string starts with ' -- it will see don' as the end of the string.

Both of the following examples are a proper way to write a string for your description:

"(Bots don't count)"

OR

'(Bots don\'t count)'

Last updated