why can not change 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 not change income
Code: Select all
[event]
name=start
first_time_only=yes
[lua]
code = <<
side1.base_income = side1.base_income + {S1G}
>>
[/lua]
[/event]
S1G is variable
Last edited by WhiteWolf on February 5th, 2023, 8:09 am, edited 1 time in total.
Reason: [code]
Reason: [code]
Re: why can not change income
Base income and income are two different things. I don't use lua for changing income. I do this:
I'm not sure if this helps. Good luck.
Code: Select all
[side]
side=1
gold=150
income=3 # bonus added to base income 2
village_gold=2 # default=1
...etc.
[/side]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: why can not change income
i need it work on other map or cfg,not have help
Re: why can not change income
Even if S1G is variable, {S1G} is table. Adding table to income does not do anything useful.
Are you sure you want to use Lua?
Are you sure you want to use Lua?
Re: why can not change income
I didn't find a way to modify "turn/gold" in WML, I think only LUA can do it
- Lord-Knightmare
- Discord Moderator
- Posts: 2364
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: why can not change income
Code: Select all
[event]
name="turn 2"
[modify_side]
income=12
gold=50
[/modify_side]
[/event]
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: why can not change income
Even if you wanted to do that in Lua, you're doing it wrong. There is no such variable as
If for some reason Lord-Knightmare's suggestion doesn't do what you want, you could try this:
Although, substituting macros directly into Lua code is generally not a good idea, so it would be better to write it like this:
On the other hand, you mentioned that S1G is a variable. I'd assumed you were misusing terminology and it was actually a macro. However, if I'm wrong and it really is a WML variable, then you would have to write it like this instead:
And if it's a Lua variable, which I assume is unlikely but is not impossible if you had other Lua code somewhere that assigns it as a global variable, then you would need to write your code like this:
But there's no need to do any of this if
side1
. Also, it looks like you're trying to substitute in a macro with {S1G}
, but the Lua code is wrapped in `<< >>` which prevents macro substitution.If for some reason Lord-Knightmare's suggestion doesn't do what you want, you could try this:
Code: Select all
[event]
name=start
first_time_only=yes
[lua]
code = "
wesnoth.sides[1].base_income = wesnoth.sides[1].base_income + {S1G}
"
[/lua]
[/event]
Code: Select all
[event]
name=start
first_time_only=yes
[lua]
code = <<
local args = ... # this line just lets you use anything from the [args] tag in your code
wesnoth.sides[1].base_income = wesnoth.sides[1].base_income + args.add
>>
[args]
add={S1G}
[/args]
[/lua]
[/event]
Code: Select all
[event]
name=start
first_time_only=yes
[lua]
code = <<
wesnoth.sides[1].base_income = wesnoth.sides[1].base_income + wml.variables["S1G"]
>>
[/lua]
[/event]
Code: Select all
[event]
name=start
first_time_only=yes
[lua]
code = <<
wesnoth.sides[1].base_income = wesnoth.sides[1].base_income + S1G
>>
[/lua]
[/event]
[modify_side]
does what you need.