"upkeep=free" problem

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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.
User avatar
Ravana
Forum Moderator
Posts: 2244
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: "upkeep=free" problem

Post by Ravana » October 8th, 2019, 6:13 pm

Changing base_income should be the easy way to modify income of all sides during game without having to check which sides exist.

User avatar
josteph
Developer
Posts: 738
Joined: August 19th, 2017, 6:58 pm

Re: "upkeep=free" problem

Post by josteph » October 8th, 2019, 6:51 pm

You could do a lua loop that iterates over all sides and sets the income for each of them: see https://wiki.wesnoth.org/LuaWML/Sides#wesnoth.sides

Lua also has access to wesnoth.game_config.base_income as a read-only.

User avatar
Ravana
Forum Moderator
Posts: 2244
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: "upkeep=free" problem

Post by Ravana » October 8th, 2019, 7:10 pm

Based on wiki it is read-write.

User avatar
josteph
Developer
Posts: 738
Joined: August 19th, 2017, 6:58 pm

Re: "upkeep=free" problem

Post by josteph » October 8th, 2019, 8:55 pm

I stand corrected.

gfgtdf
Developer
Posts: 1190
Joined: February 10th, 2013, 2:25 pm

Re: "upkeep=free" problem

Post by gfgtdf » October 8th, 2019, 11:08 pm

josteph wrote:
October 8th, 2019, 6:51 pm

Lua also has access to wesnoth.game_config.base_income as a read-only.
Be aware though that is is iirc not persistent In saves so.it has.to be set in preload events or other code that runs whenever saves are loaded.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

User avatar
Celtic_Minstrel
Developer
Posts: 1529
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: "upkeep=free" problem

Post by Celtic_Minstrel » October 9th, 2019, 12:36 am

Ravana: That Lua API actually writes straight to the global game config. (Makes me wonder if the config is properly reset every time you start a new scenario? Though it probably is...)

I just checked and it seems I was getting income confused with the village settings (gold/support) - the MP create screen doesn't appear to offer setting the base income as I thought, so for setting income it probably just uses [side]income=.

I do think the ability to override some of these keys on a per-scenario basis would be nice. You could actually implement it in Lua, I believe – use the onload hook to read the keys from the scenario and change them with the API Ravana pointed out. I opened issue #4440 for this.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

User avatar
Ravana
Forum Moderator
Posts: 2244
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: "upkeep=free" problem

Post by Ravana » October 9th, 2019, 6:21 am

gfgtdf wrote:
October 8th, 2019, 11:08 pm
Be aware though that is is iirc not persistent In saves so.it has.to be set in preload events or other code that runs whenever saves are loaded.
I will have to check if changing poison value in orocia can break saves.

User avatar
lhybrideur
Posts: 70
Joined: July 9th, 2019, 1:46 pm

Re: "upkeep=free" problem

Post by lhybrideur » October 9th, 2019, 3:57 pm

Don't know if that help, but [modify_unit] portrait= seems not to be conserved in saves. When I reload them, the portrait is gone. Might be the same for your poison modification, depending on how you implemented it.

User avatar
Celtic_Minstrel
Developer
Posts: 1529
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: "upkeep=free" problem

Post by Celtic_Minstrel » October 10th, 2019, 1:36 am

lhybrideur wrote:
October 9th, 2019, 3:57 pm
Don't know if that help, but [modify_unit] portrait= seems not to be conserved in saves. When I reload them, the portrait is gone. Might be the same for your poison modification, depending on how you implemented it.
Using [modify_unit] like that for permanent effects isn't recommended because it doesn't mix well with the use of objects. What you should do instead is use [modify_unit][object] with an [effect]apply_to=profile - that'll have no issues in save files. In general you should try to use this approach for any permanent change.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

User avatar
lhybrideur
Posts: 70
Joined: July 9th, 2019, 1:46 pm

Re: "upkeep=free" problem

Post by lhybrideur » October 10th, 2019, 3:00 pm

Thanks, I will try that when I have the time.
However I don't think in would work in Ravana's case as it's not a one-unit problem.

Post Reply