WML/LUA turn bell
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:
WML/LUA turn bell
Problem solved. The
In the bottom you can find working samples of codes that play sound only to specific side. Save your time and don't read all these below, its irrelevant.
Ok... There was always million of problems with people not hearing turn bell when there is a message displayed on turn refresh or any other event on start of their turn...
a) Could in some future there be a tag that would transfer or add turn bell to the message? ( (b) and/or tag that would show message in popup icon of Windows where time, language and sounds icons are displayed)
c) There could also be event that is fired after turn bell and after turn refresh so we could move new side turn messages there and they would get displayed AFTER turn bell (I was thinking to use time stamp to create this artificially, but I don't want to risk potential OOS and spend lot of time for nothing)
I have tried to add normal sound for message but ALL players in game hear it too, so it would remove the affect of turn bell as it would sound for each player and would become annoying too.
I asked many times about how to add sound that would be heard only for a specific side, but the replies I received were wrong and non-helpful (Please specify the full code including the event if you want to help, not some potentially working part of context).
Thank you very much for everyone who might help with this neverending problem.
[message]
side_for=
now (in 1.14) works for sounds too! unlike in 1.12In the bottom you can find working samples of codes that play sound only to specific side. Save your time and don't read all these below, its irrelevant.
Ok... There was always million of problems with people not hearing turn bell when there is a message displayed on turn refresh or any other event on start of their turn...
a) Could in some future there be a tag that would transfer or add turn bell to the message? ( (b) and/or tag that would show message in popup icon of Windows where time, language and sounds icons are displayed)
c) There could also be event that is fired after turn bell and after turn refresh so we could move new side turn messages there and they would get displayed AFTER turn bell (I was thinking to use time stamp to create this artificially, but I don't want to risk potential OOS and spend lot of time for nothing)
I have tried to add normal sound for message but ALL players in game hear it too, so it would remove the affect of turn bell as it would sound for each player and would become annoying too.
I asked many times about how to add sound that would be heard only for a specific side, but the replies I received were wrong and non-helpful (Please specify the full code including the event if you want to help, not some potentially working part of context).
Thank you very much for everyone who might help with this neverending problem.
Last edited by enclave on May 9th, 2018, 11:02 pm, edited 2 times in total.
Re: WML/LUA turn bell
> I have tried to add normal sound for message but ALL players in game hear it too
If you do it in Lua, you can have it only for clients you want - in described use case checking that current side is local should be enough.
If you do it in Lua, you can have it only for clients you want - in described use case checking that current side is local should be enough.
Re: WML/LUA turn bell
That's exactly what I mean.. I completely don't understand your attempt to help..
How will it work in lua? What current side local? How the check if side local can help at all?
Which lua function will play sound?
wesnoth.play_sound(sound, [repeat_count]) there is no side variable here
wesnoth.set_music(music_entry) no side variable either
wesnoth.music_list no side variable, no current side local variables
wesnoth.sound_volume no side for variable
wesnoth.show_menu(items [, initial] [, markup]) no even sound variable here, not even talking about side variable
wesnoth.show_message_dialog no sound here too
I completely have no clue what you are trying to say. It rather be unanswered than now somebody will confuse your reply with solved problem.. sorry.
Re: WML/LUA turn bell
It doesnt matter what function you use to play sound. If you check is_local, and only run the function if that side is local, then noone else will run the function, so noone else will hear anything.
Code: Select all
if wesnoth.sides[wesnoth.current.side].is_local then
wesnoth.play_sound()
end
Last edited by Ravana on May 9th, 2018, 11:00 pm, edited 1 time in total.
Reason: Replaced play_sound() with wesnoth.play_sound()
Reason: Replaced play_sound() with wesnoth.play_sound()
Re: WML/LUA turn bell
Can you post the code you tried, which isn't working?
It looks like message already supports sound and side_for. If those aren't working then it should be reported as a bug.
It looks like message already supports sound and side_for. If those aren't working then it should be reported as a bug.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: WML/LUA turn bell
I haven't tried it in 1.14, but this what was making sound for all sides in 1.12:
Code: Select all
[message]
caption="Research Complete"
side_for=$side_number
speaker="narrator"
sound="horn-signals/horn-3.ogg"
image="$qc_system.humans.techs[$qc_system.humans.shortcuts.techs.$player[$side_number].research_project].image~SCALE(300,300)"
message="<b>$qc_system.humans.techs[$qc_system.humans.shortcuts.techs.$player[$side_number].research_project].name</b>
<small>
$qc_system.humans.techs[$qc_system.humans.shortcuts.techs.$player[$side_number].research_project].description1
$qc_system.humans.techs[$qc_system.humans.shortcuts.techs.$player[$side_number].research_project].description2
$qc_system.humans.techs[$qc_system.humans.shortcuts.techs.$player[$side_number].research_project].description3</small>
<span color='#cccc33'>$gc_temp_gold.spare_science_gold Gold</span> Was left over from research and returned to you.
<b>What would you like to do next?</b>"
[option]
message="&"+lobby/status-lobby-s.png~FL()~CS(200,-200,0)~SCALE(30,30)+"="+_ "Exit"
[command]
##
{VARIABLE player[$side_number].research_project none}
{VARIABLE player[$side_number].highlight_research true}
[/command]
[/option]
[option]
message="&"+icons/jewelry_ring_prismatic.png~FL()~SCALE(30,30)+"="+_ "<b>Adjust Science Speed</b> = Amount of income to spend on science."
[command]
{VARIABLE player[$side_number].research_project none}
{VARIABLE player[$side_number].highlight_research true}
{HC_FIRE_EVENT qc_research_adjust}
[/command]
[/option]
[option]
message="&"+icons/potion_green_medium.png~FL()~SCALE(30,30)+"="+_ "<b>Select a Research Project</b> = Research a new stronger warrior unit?"
[command]
{VARIABLE player[$side_number].research_project none}
{VARIABLE player[$side_number].highlight_research true}
{HC_FIRE_EVENT qc_research_select}
[/command]
[/option]
[/message]
Although I would prefer a working version straight away...
Thank you Ravana, this looks very clear to me now, so I guess I can put this [lua] code just before message in turn refresh event and only 1 side will hear this sound right before WML [message]?Ravana wrote: ↑May 9th, 2018, 6:51 pm It doesnt matter what function you use to play sound. If you check is_local, and only run the function if that side is local, then noone else will run the function, so noone else will hear anything.Code: Select all
if wesnoth.sides[wesnoth.current.side].is_local then play_sound() end
I will test both ways now and report what the result is..
Re: WML/LUA turn bell
Not before, you replace play_sound() with the code that shows message. Only the part inside conditional is used as unsynced code, everything after and before happens for everyone. It can be wesnoth.wml_actions.fire_event to call WML event containing [message] as well so you dont need to encode complex WML tables manually.
Message with options might still need to be fired on everyone and be synced, but is_local allows you go into unsynced context to make interface changes.
Note that is_local is 1.13 feature. You need to explicitly say you are looking for oldstable solution if you need it work on versions other than current stable.
Message with options might still need to be fired on everyone and be synced, but is_local allows you go into unsynced context to make interface changes.
Note that is_local is 1.13 feature. You need to explicitly say you are looking for oldstable solution if you need it work on versions other than current stable.
Re: WML/LUA turn bell
Ok I can happily say that 1.14 fixed the sound_for sound problem! Now only the side that receives the message with
I have tested exactly same code on 1.12 and 1.14 in both multiplayer and single player and result was sound for all sides on 1.12 and sound only for the
As a bonus in offline games I don't hear the computer player sound and I dont get computer player messages too. The code follows:
Then I also tested Ravana method, and it's really great to know that it works on 1.14 too (no idea about 1.12), in addition there is a nice difference between the message and sound code when you play offline.. Ravana method will give sound for all sides for offline game, while it will only give sound to specific side in online multiplayer. This is great because there is a choice for add-on makers of how they want sound to behave... Code follows:
Thank you very much both of you for your help! This will be helpful for many other people. I'm very sorry for confusing you that it doesn't work, it was not working in 1.12 and now it works perfectly fine in 1.14 (Ravana, please could you edit your post and fix
side_for
can hear the sound..I have tested exactly same code on 1.12 and 1.14 in both multiplayer and single player and result was sound for all sides on 1.12 and sound only for the
side_for
side on 1.14As a bonus in offline games I don't hear the computer player sound and I dont get computer player messages too. The code follows:
Code: Select all
[event]
name=turn refresh
first_time_only=no
[message]
caption="Research Complete"
side_for=$side_number
speaker="narrator"
sound="horn-signals/horn-3.ogg"
image="portraits/monsters/ogre.png"
message="Ugly ogres make a sounds make a sound make a sound"
[/message]
[/event]
Code: Select all
[event]
name=turn refresh
first_time_only=no
[lua]
code = <<
if wesnoth.sides[wesnoth.current.side].is_local then
wesnoth.play_sound("horn-signals/horn-3.ogg")
end
>>
[/lua]
[message]
caption="Research Complete"
side_for=$side_number
speaker="narrator"
image="portraits/monsters/ogre.png"
message="Ugly ogres make a sounds make a sound make a sound"
[/message]
[/event]
play_sound()
into wesnoth.play_sound()
to avoid confusions)Thank you very much for additional informationNot before, you replace play_sound() with the code that shows message. Only the part inside conditional is used as unsynced code, everything after and before happens for everyone. It can be wesnoth.wml_actions.fire_event to call WML event containing [message] as well so you dont need to encode complex WML tables manually.
Message with options might still need to be fired on everyone and be synced, but is_local allows you go into unsynced context to make interface changes.
Note that is_local is 1.13 feature. You need to explicitly say you are looking for oldstable solution if you need it work on versions other than current stable.