Increment variable not working


I’m trying to add an increment system on a variable in chapbook.
Let’s say I have the variable money set to 10 (money: 10) and i want on next passage to increase it by 1.

Looking at the documentation I should do money: money + 1 but when I do that I end up with money = 101 instead of 11. And if I continue it’ll just go 1011, 10111 etc…

BUT when I do money: money - 1 it’s working and print money = 9… What’s going wrong ?

Sounds like it’s treating it as a string: + is used both for adding numbers and appending to strings. But if you subtract, then - is only used for subtracting numbers so it treats it as a number.

I’m not sure why it would be a string in the first place: can you share which version of Twine and which version of Chapbook you’re using? And copy/paste your exact code so we can see it?

Thanks for the fast answer !

I’m using Twine 2.7.0 and Chapbook 1.2.3.


config.body.transition.duration: "350ms"
config.header.left: "" ""
config.header.right: "" "#4A3F35" "top" "{back link} | {restart link}"
config.footer.left: ""
config.footer.right: "" "blue-7" "none" "blue-3" "underline" "gray-2 on gray-9"
[align center]
[align left]


Beginning: "<img class='hf' src='img/header.jpg'>"
config.header.left:"" "<img class='hf' src='img/footer.jpg'>{back link} | {restart link}"
config.footer.left: ""
config.footer.right: ""
money: "10"

You have {money}$

[[keep talking]]

keep talking:

money: money + 1

Money increased by one, you now have {money}$



money: money - 1
You lost 1$ and now have {money}$

Using quotes sets the variable to a string. To set it to a numerical value, use 10 without the quotes:

money: 10
1 Like

Thank you :sweat_smile: