Hide HP-XP-overlays with lua

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
User avatar
Toranks
Translator
Posts: 168
Joined: October 21st, 2022, 8:59 pm
Location: Sevilla
Contact:

Hide HP-XP-overlays with lua

Post by Toranks »

Is there a way to hide the energy bars, XP, orbs and overlays, the same way this WML code does?
To be able to apply it more generally in more situations with lua, not only on [animate_unit] with_bars=no, which is the only way in all WML that I can do that.

Code: Select all

    [animate_unit]
        [filter]
            x,y=$x1,$y1
        [/filter]
        flag=healed
        with_bars=no
    [/animate_unit]
User avatar
Celtic_Minstrel
Developer
Posts: 2158
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Hide HP-XP-overlays with lua

Post by Celtic_Minstrel »

I think the only way to hide the bars is animating the unit. In Lua that would mean you use wesnoth.units.create_animator, build up a set of animations, and then run them.

Does that satisfy what you need, or not? I'm not sure if you could permanently hide the bars with this method, if that's what you're going for.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Hide HP-XP-overlays with lua

Post by Helmet »

This is not Lua...

Maybe use [unit_type] to create duplicate units, then change the bar_offset_x, bar_offset_y to put the bars so far off the map that they are not visible, and also turn off halo, ellipse or whatever.

Also, if you simply want a unit standing on the map without their information features visible, you could place their basic unit_standing.PNG on the map like an item.
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.
User avatar
Toranks
Translator
Posts: 168
Joined: October 21st, 2022, 8:59 pm
Location: Sevilla
Contact:

Re: Hide HP-XP-overlays with lua

Post by Toranks »

Celtic_Minstrel wrote: February 1st, 2023, 2:53 pm Does that satisfy what you need, or not? I'm not sure if you could permanently hide the bars with this method, if that's what you're going for.
I wanted it to be changeable manually, with a shortcut or right-click menu. That won't be possible, unless I have a way to automatically replace the game animations with my edited version, too complex.
Helmet wrote: February 1st, 2023, 3:42 pm Maybe use [unit_type] to create duplicate units, then change the bar_offset_x, bar_offset_y to put the bars so far off the map that they are not visible, and also turn off halo, ellipse or whatever.
That gave me hope, but unfortunately it didn't work. What you say is only applicable if I replace the units one by one or creating a unit specifically. But it does not serve to modify existing units without significantly altering them.

I tried this and it is not possible to do it, it has no effect. And there is no other way to change these values to already existing units. [modify_unit_type] only works if I specify the unit id and only in the [campaign] [era] and [modification] tags, not "on-the-fly".

Code: Select all

[modify_unit]
	[filter]
	[/filter]
	bar_offset_x=99999
	bar_offset_y=99999
[/modify_unit]
User avatar
Heindal
Posts: 1343
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Hide HP-XP-overlays with lua

Post by Heindal »

I think Celtric Mistrel is right. Overlays are not shown, when a unit is moving or when it is animated. So one idea could be to make an constant idle with the same unit picture as the standard standing unit (not quite sure it will work, but maybe worth a try). Or making the unit breath in and out all the time, like in a fighting game.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
User avatar
Toranks
Translator
Posts: 168
Joined: October 21st, 2022, 8:59 pm
Location: Sevilla
Contact:

Re: Hide HP-XP-overlays with lua

Post by Toranks »

Overlays are displayed when the unit is attacking too. Only movement animation makes it disappear as far as I know
User avatar
Toranks
Translator
Posts: 168
Joined: October 21st, 2022, 8:59 pm
Location: Sevilla
Contact:

Re: Hide HP-XP-overlays with lua

Post by Toranks »

Ok, I think I understood you better. You say to create an animation with Lua without with_flag that acts all the time while the unit is stopped, right? Although my intention is actually to avoid overlays during attacks as well, and it would not work for that case
User avatar
Skayland
Posts: 20
Joined: March 27th, 2020, 2:59 am
Location: Somewhere only we know.
Contact:

Re: Hide HP-XP-overlays with lua

Post by Skayland »

Hello!
You could try with

Code: Select all

hp_bar_scaling=0.0
and

Code: Select all

xp_bar_scaling=0.0
Inside unit or unit_type tags. Should also work with modify_unit
You can create a macro that applies modify_unit on any unit when you need it
You could then call something like

Code: Select all

{HIDE_BARS unit}
You might also want a macro to {SHOW_BARS} using the default scaling values. You can find the default values here

Alternatively you can edit xp and hp bar scaling for the WHOLE game on this file on your wesnoth root folder
wesnoth/data/game_config.cfg

Hopefully that solves your issue somehow :)
Practice makes perfect, why don't we practice helping others?
User avatar
Toranks
Translator
Posts: 168
Joined: October 21st, 2022, 8:59 pm
Location: Sevilla
Contact:

Re: Hide HP-XP-overlays with lua

Post by Toranks »

I've tried it and it still shows little white lines 1 pixel wide where the start of the XP and HP bars should be. We talked about this on Discord, they're probably going to change that in the future so that 0 really means 0.
User avatar
Toranks
Translator
Posts: 168
Joined: October 21st, 2022, 8:59 pm
Location: Sevilla
Contact:

Re: Hide HP-XP-overlays with lua

Post by Toranks »

Another thing I've tried and it didn't work either, besides using hp_bar_scaling to 0, is editing or deleting bar-energy.png file and editing the line energy="misc/bar-energy.png" in wesnoth\data\game_config.cfg. This did not change the appearance of the bars at all.
Post Reply