New Lua functions.

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderator: Forum Moderators

Forum rules
Before posting a new idea, you must read the following:
Post Reply
mentos987
Posts: 15
Joined: September 17th, 2021, 10:47 pm

New Lua functions.

Post by mentos987 »

I have some requests listed here in order of perceived importance:
  • 1. --Edit: This feature does already exist. --
    Spoiler:

  • 2. A function to place a "halo"-type multihex image that is layered above the tiles but underneath the units would enable modders to create a lot more beauty.
  • 3. ~ROTATE and ~SCALE for wesnoth.interface.add_hex_overlay() is currently very taxing for the CPU and cause a lot of lag. Would be nice if they where optimized. Or if we could preload the animation for later use.
Last edited by mentos987 on April 3rd, 2024, 1:03 pm, edited 2 times in total.
User avatar
Ravana
Forum Moderator
Posts: 3011
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: New Lua functions.

Post by Ravana »

1 sounds useful.

2 has nothing to do with Lua functions.

3 I got impression if it difficult to improve performance.
mentos987
Posts: 15
Joined: September 17th, 2021, 10:47 pm

Re: New Lua functions.

Post by mentos987 »

Ravana wrote: March 23rd, 2024, 7:20 pm 2 has nothing to do with Lua functions.
I am not loooking for a specific image. I am looking for a function to place a multihex image above the terrain layer but below the unit layer. Much like how halos work.

I want a new option for this Lua function: wesnoth.interface.add_hex_overlay(x, y, {x = x, y = y, halo = "data/add-ons/addon/images/folder/pic01.png"})

Where "halo" is the layer, I want the option of a third layer.
Shiki
Developer
Posts: 350
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: New Lua functions.

Post by Shiki »

I think World Conquest does use this functionality actually. Setting sth. undocumented like z-index.
Try out the dark board theme.
User avatar
Celtic_Minstrel
Developer
Posts: 2233
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: New Lua functions.

Post by Celtic_Minstrel »

For 1 you could look into the sound source functionality. It might be able to do what you want, but I'm not sure.

For 3, yes, we would like to use the GPU for IPFs, but we're not quite there yet. Compiling IPFs down into shader code is possible and would probably greatly boost performance for things using a lot of IPFs, not to mention reducing the size of the image cache…
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
mentos987
Posts: 15
Joined: September 17th, 2021, 10:47 pm

Re: New Lua functions.

Post by mentos987 »

Shiki wrote: March 23rd, 2024, 9:59 pm I think World Conquest does use this functionality actually. Setting sth. undocumented like z-index.
Are you refering to the 2nd point? I scanned the files of World Conquest but didn't find much, not that I know what to look for.
Last edited by mentos987 on March 23rd, 2024, 10:49 pm, edited 2 times in total.
mentos987
Posts: 15
Joined: September 17th, 2021, 10:47 pm

Re: New Lua functions.

Post by mentos987 »

Celtic_Minstrel wrote: March 23rd, 2024, 10:04 pm For 1 you could look into the sound source functionality. It might be able to do what you want, but I'm not sure.
Do you mean wesnoth.audio.sources ? If I understand that correctly it handles sources that can play sound files. Not any sounds that are actively playing.
The reason why this is so important for narration is that if the player skips dialogue we want to cancel the voiceover.
mentos987
Posts: 15
Joined: September 17th, 2021, 10:47 pm

Re: New Lua functions.

Post by mentos987 »

Celtic_Minstrel wrote: March 23rd, 2024, 10:04 pm For 3, yes, we would like to use the GPU for IPFs, but we're not quite there yet.
That is fine, this is not a major issue.
User avatar
Celtic_Minstrel
Developer
Posts: 2233
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: New Lua functions.

Post by Celtic_Minstrel »

mentos987 wrote: March 23rd, 2024, 10:38 pm Do you mean wesnoth.audio.sources ? If I understand that correctly it handles sources that can play sound files. Not any sounds that are actively playing.
The reason why this is so important for narration is that if the player skips dialogue we want to cancel the voiceover.
The intended use-case for sound sources is to support spatialized sound that can fade away as you move further away from it. However, it's entirely possible to use it for other things, and I think there's a pretty good chance that it could do what you want. In fact, I think they've been used for narration before by other people.

That said, there should probably be a function to stop a non-source sound as well… it just doesn't come up much because they're usually used for short sound effects.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
mentos987
Posts: 15
Joined: September 17th, 2021, 10:47 pm

Re: New Lua functions.

Post by mentos987 »

Celtic_Minstrel wrote: March 26th, 2024, 4:30 am The intended use-case for sound sources is to support spatialized sound that can fade away as you move further away from it. However, it's entirely possible to use it for other things, and I think there's a pretty good chance that it could do what you want. In fact, I think they've been used for narration before by other people.
I did not dig deep into this subject but I talked to several modders and they said it is not possible. The workaround that other mods uses is to run the narration as music and to run a "silent track" to mute the narration. A very clunky solution with a lot of issues.

(I have not tested this) I think that the effects "sound that can fade away as you move further away from it" only changes the initial setup of a sound and its repetition. I do not think you can stop any sound that is playing, unless it is playing on repeat, in which case you can only prevent it from repeating.
User avatar
Celtic_Minstrel
Developer
Posts: 2233
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: New Lua functions.

Post by Celtic_Minstrel »

mentos987 wrote: April 2nd, 2024, 4:12 pm I do not think you can stop any sound that is playing, unless it is playing on repeat, in which case you can only prevent it from repeating.
You can remove a sound source from the map. If it still continues to play after you do that, then that's clearly a bug.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
mentos987
Posts: 15
Joined: September 17th, 2021, 10:47 pm

Re: New Lua functions.

Post by mentos987 »

Celtic_Minstrel wrote: April 2nd, 2024, 5:51 pm You can remove a sound source from the map. If it still continues to play after you do that, then that's clearly a bug.
Just tested it and I was wrong. You can instantly cancel a playing sound by using:
Spoiler:
then:
Spoiler:
My apologies

An added fade out option to this function would be nice, for those that wants to suddenly stop the sound.
Post Reply