Display current village upkeep information?
Moderator: Forum Moderators
Forum rules
Before posting a new idea, you must read the following:
Before posting a new idea, you must read the following:
Display current village upkeep information?
Hi, what I miss a lot on the game's top information bar is how many unit levels my current villages can support (i.e. how many unit levels will be free according to the number of villages I currently own).
I can only keep recruiting till the expenses counter stops showing "0/xx"...
I think that would be easy to implement, there is enough space available on that top bar.
I can only keep recruiting till the expenses counter stops showing "0/xx"...
I think that would be easy to implement, there is enough space available on that top bar.
Re: Display current village upkeep information?
That is just number of village x village support. If you miss it you can implement it in your addon.
Re: Display current village upkeep information?
Except that the players don't necessarily know what the scenario creator decided to set as "village support". Could be anything...
So it's still useful information for the player, something they would like to know to be able to plan their recruiting.
Besides, AFAIK it's not 1:1, it's "unit levels":village (isn't it?), which means that it will change every time one of your units levels. For this reason ideally it should display something like "owned unit levels"/"village supported unit levels".
So it's still useful information for the player, something they would like to know to be able to plan their recruiting.
Besides, AFAIK it's not 1:1, it's "unit levels":village (isn't it?), which means that it will change every time one of your units levels. For this reason ideally it should display something like "owned unit levels"/"village supported unit levels".
Re: Display current village upkeep information?
Sure, feel free to implement it. https://wiki.wesnoth.org/LuaAPI/wesnoth ... me_display and/or https://wiki.wesnoth.org/ThemeWML
Re: Display current village upkeep information?
Lua is definitely a bridge too far for me. You have seen the level of difficulties I already have to ask for help with...
I'm not a developer, just somebody who dabbles in WML (mostly copying and adapting stuff seen elsewhere)...
I'm not a developer, just somebody who dabbles in WML (mostly copying and adapting stuff seen elsewhere)...
Re: Display current village upkeep information?
Fair enough. Example how you can implement seeing how many levels worth of support there are still left.
If you want to test it, find in hotkeys show lua console, give it hotkey, and you can enter this.
Code: Select all
-- wesnoth.interface.game_display.upkeep = _G.old_upkeep
local old_upkeep = wesnoth.interface.game_display.upkeep
function wesnoth.interface.game_display.upkeep()
local s = old_upkeep()
--print(wml.tostring(s))
local village_support = #wesnoth.map.find{owner_side=wesnoth.current.side} * wesnoth.sides[wesnoth.current.side].village_support
local total_upkeep = #wesnoth.units.find{side=wesnoth.current.side, upkeep=1}+ 2* #wesnoth.units.find{side=wesnoth.current.side, upkeep=2}+ 3* #wesnoth.units.find{side=wesnoth.current.side, upkeep=3}+4* #wesnoth.units.find{side=wesnoth.current.side, upkeep=4}
--print(village_support)
--print(total_upkeep)
--_s = s
--wesnoth.interface.game_display.upkeep = old_upkeep
s[1][2].text = "&" .. tostring(village_support-total_upkeep)
--print(s[1][2].text)
return s
end
- Spannerbag
- Posts: 952
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Display current village upkeep information?
If you want a "dirty hack" in WML (I'm good at thosekurt751 wrote: August 2nd, 2026, 10:09 am Hi, what I miss a lot on the game's top information bar is how many unit levels my current villages can support (i.e. how many unit levels will be free according to the number of villages I currently own).
I can only keep recruiting till the expenses counter stops showing "0/xx"...
I think that would be easy to implement, there is enough space available on that top bar.
DISCLAIMER: I've never done this so can't guarantee it'll work as I expect.
[store_side] is your friend.
(Or you could use the game_config defaults of 1 if you haven't changed anything - but as my idea involves storing side(s) every turn you might as well use the actual value?)village_support: The number of unit levels this side is able to support (does not pay upkeep on) per village it controls.
To calculate the number of levels supported each turn.
Sadly I think you'll need to store each side of interest every side turn refresh plus that side's owned villages (because the number of villages changes).
[store_location] or [store_villages] can do this.
The number of levels that can be supported is (I guess) simply:
Number of villages owned (i.e. array length) * side's village_supportThe whole thing could be wrapped in a macro that basically sets a few variables and calls an event (done this way to reduce bloat).
It'd probably be prudent to explain/clarify to the player (at very least on easiest difficulty?) that this is the number of Level 1 units that can be supported and that higher level units cost their level number in 1st level units. Also might be worth saying that leaders, loyals and zero levels do not incur upkeep. (How you do this I'll leave to you.
)
From there it's easy (and maybe more useful) to display the available/unused upkeep (or not) so the player knows how many more levels that can recruit without going to negative gold (on current village holding) - or how many units they need to lose to stop losing gold each turn.Other side variables you might find useful:
Hope this helps!income: Income for this side (base income + all village income. AKA gross income. Note that this is different from the [side] income key).
village_gold: The amount of gold given to this side per village it controls per turn.
Cheers!
Re: Display current village upkeep information?
Guys, guys, thank you both, but I can (and prefer to) live without it. Life (and Wesnoth) is already complicated enough...
I saw this forum as a kind of wish list for future "The Battle for Wesnoth" game features, and thought I'd suggest this feature, because it's actually the only thing I'm missing. (That, and a better, faster, smoother scrolling.)
Unfortunately I'm no developer (have I mentioned it?...), so I'm definitely not the one who will implement it.
I saw this forum as a kind of wish list for future "The Battle for Wesnoth" game features, and thought I'd suggest this feature, because it's actually the only thing I'm missing. (That, and a better, faster, smoother scrolling.)
Unfortunately I'm no developer (have I mentioned it?...), so I'm definitely not the one who will implement it.
Re: Display current village upkeep information?
You can wrap Lua in modification to select it as addon.
Code: Select all
[modification]
id=t60876
name=_"t60876"
description=_"https://forums.wesnoth.org/viewtopic.php?t=60876"
require_modification=no
type=hybrid
[event]
name=preload
first_time_only=no
[lua]
code=<<
local old_upkeep = wesnoth.interface.game_display.upkeep
function wesnoth.interface.game_display.upkeep()
local s = old_upkeep()
local village_support = #wesnoth.map.find{owner_side=wesnoth.current.side} * wesnoth.sides[wesnoth.current.side].village_support
local total_upkeep = #wesnoth.units.find{side=wesnoth.current.side, upkeep=1}+ 2* #wesnoth.units.find{side=wesnoth.current.side, upkeep=2}+ 3* #wesnoth.units.find{side=wesnoth.current.side, upkeep=3}+4* #wesnoth.units.find{side=wesnoth.current.side, upkeep=4}
s[1][2].tooltip = s[1][2].tooltip .. " / " .. s[1][2].text
s[1][2].text = "&" .. tostring(village_support-total_upkeep)
return s
end
>>
[/lua]
[/event]
[/modification]
Re: Display current village upkeep information?
I understand all the individual words, but not the phrase.
How does that work?
The Wiki is once again particularly vague: "A modification is, practically speaking, a bunch of events which get included into the scenario if the modification is enabled.". That description does fit anything in a scenario (except the map and the side definitions)...
Re: Display current village upkeep information?
Basically if you put what I wrote to _main.cfg you can enable it in game.
Re: Display current village upkeep information?
I see, thanks.
I'll try it tomorrow.
I'll try it tomorrow.