Learning ChoiceScript: Part 6: Fairmath

Learning ChoiceScript

ChoiceScript is a scripting language from Choice of Games LLC for creating choose-you-own-adventure games.


Fairmath

Along with the ability to add or subtract from values, ChoiceScript also includes functionality for preforming “fairmath”: percentage-based arithmetic.

Instead of increasing or decreasing a fixed number, the fairmath system changes a value by a percentage of the change as a ratio to the original number. In other words, major changes will shift a value up to a point while smaller, consistent changes can shift a value over time (or across multiple choices).

It is often easier to think of fairmath as a default of 50%. Changing by 50% would be significant, but so would small changes of 10% in regard to making choices in regard to, for example, a reputation system or as part of changing character statistics.

Screenshot 2018-08-24 23.21.42

Using the fairmath system, the percentage symbol, %, goes in front of the operation.

Screenshot 2018-08-24 23.40.07

Like with the 50% change example, adding or subtracting 20% using the fairmath system would adjust the value proportionally.

Percentage

GitHub Gist Version:

*title Example
*author Dan Cox
*scene_list
startup
*create trust 50
CHAPTER 1: THE JOURNEY BEGINS
[i]You may have heard of us…[/i]
I look up from the first page of the journal I had just written as my brother calls my name. "Jacob! Jacob! Stop wasting our ink. We still have many miles to travel and I can't have you wasting supplies!"
"Yes, William," I reply, glancing at the top of the page where I have carefully written our names before closing the journal and carefully putting it away.
[i]The Brothers Grimm[/i]
He nodded as the journal disappeared into my bag. "Good. Now that I have your attention. [b]Do you remember where father told us to look next?[/b]"
I looked around and considered my options.
*choice
#The woods?
*image woods.jpg
William paused for a moment to think back to the conversation we had with our father before we set out. "Yes," he finally replied, nodding to himself. "We were told to go into the woods next."
*set trust %+20
*finish
#The mountains?
William paused for a moment to think back to the conversation we had with our father before we set out. "No," he finally replied, frowning at me. "We were told to go into the woods next."
*set trust %-20
*finish
#The lake?
William paused for a moment to think back to the conversation we had with our father before we set out. "No," he finally replied, frowning at me. "We were told to go into the woods next."
*set trust %-20
*finish

view raw
startup.txt
hosted with ❤ by GitHub