Macros are built-in functions that perform some common tasks. Below is a list of some common macros that you can use at any stage in your CSML flows.
Return one the elements of the array passed in the first argument at random.
Useful for randomisation of dialogue parts!
say OneOf(["I like you", "You're awesome"])
Given an array, return it with its elements in a random order.
Especially useful in questions to randomize the available options!
do btn1 = Button("Blue")do btn2 = Button("Red")do btns = Shuffle([btn1, btn2])say Question(title = "Select a pill",buttons = btns)
Return whether a string is contained in another string.
say Find("needle", in="haystack") // falsesay Find("yes", in="well yes, I like cheese") // true
Return the length of a given string or array
say Length("My horse is amazing") // 19say Length([1, 2, 3]) // 3
Return a random floating point number in the range 0-1 (0 included, 1 excluded).
say Random() // 0.03196249773128712say Random() // 0.6416423921015862
Return the largest integer less than or equal to the given number.
say Floor(1.23456) // 1
This is useful to generate a random integer in a given range:
say Floor(Random() * 5) // a random integer between 0-4 (included)say Floor(Random() * 8) + 12 // a random integer between 12 - 19 (included)