Option weight
There are often situation in which some options are mutually exclusive. To avoid an unnecessary number of nested conditionals, options in plato have an integer weight that serves two purposes:
- if two options have the same weight, the one that was added earlier is presented as a choice
- the options that are presented as choice are sorted by their weight
This allows, for example, to do things like
plato.option_once(1, "option 1", "entry1") if plato.get_state("a") plato.option(1, "option 2", "entry2") end plato.option(1, "option 3", "entry3")
where "option 1" is presented, but once it has been selected the next time we go through the
dialogue it will be skipped and be replaced by "option 2" if state "a" is true or by "option 3".
Note that only the order in which options are added within a given weight is important, and that weight don't have to be continguous, as the choices are sorted by weight and not by order of addition. For example
plato.option(99, "option 4", "entry4") plato.option(1, "option 1a", "entry1a") plato.option(1, "option 1b", "entry1b") plato.option(5, "option 3", "entry3") plato.option(2, "option 2", "entry2")
will result in choices ordered as
"option 1a""option 2""option 3""option 4"
generated by LDoc 1.5.0