Why can’t I increase side income?
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Why can’t I increase side income?
Can someone enlightnen me why doesn’t this work?
The intend is, hopefully, fairly obvious: side {SIDE} should have its base income increased by {AMOUNT}.
However, the effects I get are far from intended…
Assume side 2 has set income=0. Then $_increase_income_stored_side.income holds value of 2 (I presume this is because of the global base income?) But after calling {INCREASE INCOME 2 20} side 2 has base income of… 4. And I’d like it to be 22.
What am I doing wrong?
Code: Select all
#define INCREASE_INCOME SIDE AMOUNT
[store_side]
side={SIDE}
variable=_increase_income_stored_side
[/store_side]
[modify_side]
side={SIDE}
income="$_increase_income_stored_side.income+{AMOUNT}"
[/modify_side]
#enddef
However, the effects I get are far from intended…
Assume side 2 has set income=0. Then $_increase_income_stored_side.income holds value of 2 (I presume this is because of the global base income?) But after calling {INCREASE INCOME 2 20} side 2 has base income of… 4. And I’d like it to be 22.
What am I doing wrong?
Re: Why can’t I increase side income?
There is no + syntax like that. You can do it in two ways:
The traditional way to do arithmetic in WML:
And using a formula:
The traditional way to do arithmetic in WML:
Code: Select all
#define INCREASE_INCOME SIDE AMOUNT
[store_side]
side={SIDE}
variable=_increase_income_stored_side
[/store_side]
[set_variable]
name=_increase_income_stored_side.income
add={AMOUNT}
[/set_variable]
[modify_side]
side={SIDE}
income=$_increase_income_stored_side.income
[/modify_side]
#enddef
Code: Select all
#define INCREASE_INCOME SIDE AMOUNT
[store_side]
side={SIDE}
variable=_increase_income_stored_side
[/store_side]
[modify_side]
side={SIDE}
income="$($_increase_income_stored_side.income + {AMOUNT})"
[/modify_side]
#enddef