Decrementing in an if statement
bgmCoder
20 Nov 2020, 22:51My character is feeding the chickens.
This works (as long as there's no space between {
and @
(else it becomes null
):
[give them some corn]:
{if corn>0:{@corn -= 1}}
You now have {corn} handful of corn.
But this doesn't decrement the value
[give them some corn]:
{if corn > 0:{@dec corn}}
You now have {corn} handful of corn.
How come the second statement doesn't work?
bgmCoder
20 Nov 2020, 22:56I tried this, too:
{if corn > 0:{@corn = @dec corn}}
and
{if corn > 0:{@set corn = @dec corn}}
bgmCoder
20 Nov 2020, 22:59Ah, I know why. @dec has to be on it's own line. This works:
[give them some corn]:
{if corn > 0:{
@dec corn
}}
You now have {corn} handful of corn.