Tagscript

FiftyFiftyParser

Render the payload half the time, and nothing the other half.

5050 renders its payload on a coin flip. The other half of the time it renders nothing at all.

For template authors

Syntax

{5050:message}

Examples

Hello!{5050: Nice to see you again.}
Example output
Hello! Nice to see you again.
Example output
Hello!
Open in playground

Because the tag renders an empty string on a miss, comparing it against empty gives you a plain coin flip:

I pick {if({5050:.}!=):heads|tails}
Example output
I pick heads
Example output
I pick tails
Open in playground

Aliases

5050, 50, ?

For developers

Register the parser

import { Interpreter, FiftyFiftyParser } from 'tagscript';
const ts = new Interpreter(new FiftyFiftyParser());

Behaviour

The payload is required and no parameter is used. parse picks between '' and the payload with Math.random(), so the odds are an even split and not configurable. For other odds, compare a range roll with if.

API reference

FiftyFiftyParser

Last updated on

On this page

Edit on Github