I wish we can use +, - ,* ,/ ,//,%,(),^ for numeric variables and being able to use other variables to assign their values to other variables using these arithmetic operations Eg. Debt = Wealth - Income This will help in making better games with more complex world mechanics.
I was about to write the same thing. There are so many things I've wanted to do but couldn't (realistically), due to not being able to directly set variables based on other variables. This is the feature I most want to see right now, by far.
I would like to have the ability to do calculations with more than one variable as well, though I think that won't be enough. To be able to implement complex game mechanics, things like conditionals, logical operators, min/max, and rounding (some calculations might result in floating point numbers) might be necessary as well.
Hmm I wonder how far Friedman (I assume it's Friedman?) is aiming to take this new game mode. Depending on how much he's planning to add, it might be most efficient (albeit still a ton of work) to lean in on the user-generated aspect of the site, implement some fundamentals (loops, functions, setting variables based on other variables, etc.) and then some kinda system to allow users to create and share functions. With that: We could build up from even just bitwise operations to typical arithmetic operations, common rpg systems, various specialty functions like pseudorandom number generators, calculations with more than one variable at once, etc., saving Friedman from having to do any of the work for that stuff himself. Users who have no experience with coding/etc. could easily use many of the useful but complicated systems that other users create. Friedman could just make a few of the very generally useful functions public and referenced in the documentation, for people who don't want to go browsing to add user-made functions that allow them to easily do fundamentals like foo = bar1 × bar2 via something like foo = multiply(bar1, bar2). But honestly I'm just happy game mode got any updates, I wasn't expecting it and it's already much better than it was.
Thank you all for the suggestions! I have now introduced the first version of Game State formulas. When editing a chapter, authors can select Set by formula under Changes to game state for Number, Percent, and Age variables. Formulas can reference other Game State variables, including the value being changed. For example: Code: game:debt = game:wealth - game:income The formula field itself would contain: Code: game:wealth - game:income The first version supports: - +, -, *, /, //, %, ^, and parentheses - comparisons and AND, OR, and NOT - conditional calculations with IF - MIN, MAX, ABS, ROUND, FLOOR, CEIL, and CLAMP - random calculations with DICE and RANDOM - references to Number, Percent, Age, and Yes/No Game State variables Calculations use exact decimal arithmetic internally, avoiding the usual floating-point surprises. The final stored value must currently be a whole number, so ROUND, FLOOR, or CEIL can be used when necessary. Multiple Game State changes in one chapter run from top to bottom, and a formula can see the results of earlier changes. The complete guide, including examples, functions, limits, and troubleshooting, is available here: https://chyoa.com/chapter/Game-State-Formulas.1878510 What would you like to see next? It would be great if you could share an example of how you would use it in a story.
This is amazing and enables so many things! Would it be possible to do the same for action buttons? Something like: {action "Gain income" set game:wealth+=game:income}