ChoiceScript Wiki
Advertisement
ChoiceScript Wiki

    *params requires *gosub or similar commands to function. *params is not compatible with *goto as of the time of this page.

Choicescript uses *params as additional support for subroutines. The command creates temporary variables (or "parameters"), then sets those variables based on the data given through a subroutine command. It essentially "passes" data from a *gosub to the next *params command.

In the following example, the string "John Doe" or "Jane Doe" is passed into the *params.

You are...
*fake_choice
  #Having a charming time with John Doe.
    *gosub dinner "John"
  #Having a charming time with Jane Doe.
    *gosub dinner "Jane"

What a lovely time!
*finish

*label dinner
*params with_who
You had a dinner with ${with_who}.
*return

Advanced *params

Booleans, integers, and strings can be passed through as parameters. Multiple variables of different type can be sent with a single *gosub command.

You are...
*fake_choice
  #Having a charming time with John Doe at 7 o'clock.
    *gosub dinner "John" 7
  #Having a charming time with Jane Doe at 8 o'clock.
    *gosub dinner "Jane" 8

What a lovely time!
*finish

*label dinner
*params with_who what_time
You had a dinner with ${with_who} at ${what_time} o'clock.
*return

You can also send variables. The data in *temp variables can also be carried to a subroutine in another scene. However, it should be acknowledged that the temporary variables will still be deleted after the scene changes. So, code with multiple scenes like the example below are allowed:

startup.txt

*temp dinner_who
*temp dinner_when

You are...
*fake_choice
  #Having a charming time with John Doe at 7 o'clock.
    *set dinner_who "John"
    *set dinner_when 7
  #Having a charming time with Jane Doe at 8 o'clock.
    *set dinner_who "Jane"
    *set dinner_when 8

*gosub_scene dinner dinner dinner_who dinner_when

What a lovely time!
*finish

dinner.txt

*label dinner
*params with_who what_time
You had a dinner with ${with_who} at ${what_time} o'clock.
*return

Notes

This command is not necessary to create a good story. The *params command is more suited for creating complex code structures and reusing common functions. Dan Fabulich, provides this example of a Fibonacci sequence using *params in the original debut[1] about the command:

*create return 0
*gosub_scene startup fib 6
${return}

*finish

*label fib
*params n
*if n < 2
  *set return 1
  *return
*gosub_scene startup fib (n-1)
*temp prev return
*gosub_scene startup fib (n-2)
*set return +prev
*return


More commands / functions
Choice *choice, *fake_choice, *disable_reuse, *hide_reuse, *allow_reuse, *selectable_if
Variable *create, *temp, *set, Arithmetic operators, *delete, *input_number, *input_text, *print, *rand
Conditional *if, *elseif, *else, Multireplace
Goto *label, *goto, *goto_scene, *goto_random_scene, *gosub, *gosub_scene, *finish
Formatting Bold text, Italic text, *image, *line_break, *page_break, *link, *stat_chart
Miscellaneous *comment, *scene_list, *title, *author, *achieve, *achievement, *check_achievements, *bug, *ending, *more_games, *share_this_game, *show_password, *script, Implicit Control Flow
Advertisement