[SOLVED] store music ?
Moderator: Forum Moderators
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.
[SOLVED] store music ?
Is there a way to check which song is currently played by the game ?
Maybe a way to store it into a variable to display it to the one who plays the game, or something like that ?
Maybe a way to store it into a variable to display it to the one who plays the game, or something like that ?
Last edited by Adamant14 on October 22nd, 2018, 8:21 pm, edited 1 time in total.
Author of Antar, Son of Rheor ( SP Campaign) | Development Thread + Feedback Thread + Replays of ASoR
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: store music ?
See: https://wiki.wesnoth.org/LuaWML/Display ... music_list
Specifically for your case, you'd want
Specifically for your case, you'd want
wesnoth.music_list.current.__cfg.name
.99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: store music ?
Seems that is what I am looking for, sadly I have no idea how to use LUA.
I guess there is no way to do that with WML ?
I guess there is no way to do that with WML ?
Author of Antar, Son of Rheor ( SP Campaign) | Development Thread + Feedback Thread + Replays of ASoR
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: store music ?
The simplest way would probably be:
then just put that wherever you want to get the name of the current song, and you'll be able to access it from the WML variable
Code: Select all
[lua]
code=<<
wml.variables["my_wml_variable"] = wesnoth.music_list.current.__cfg.name
>>
[/lua]
my_wml_variable
.99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: store music ?
The code works, thank you Pentarctagon.
Only issue is a strange error message:
That is how I use the code:
The error message appears every time I open the menu.
Only issue is a strange error message:
Code: Select all
Invalid WML found: unknown conditional wml: [debug_status] (4)
Invalid WML found: unknown conditional wml: [debug_status] (4)
Invalid WML found: unknown conditional wml: [debug_status] (4)
Invalid WML found: unknown conditional wml: [debug_status] (4)
Code: Select all
[event]
name=prestart
{VARIABLE "check_music" 0}
[/event]
[event]
name=start,side turn,new turn
first_time_only=no
[lua]
code=<<
wml.variables["check_music"] = wesnoth.music_list.current.__cfg.name
>>
[/lua]
[set_menu_item]
[filter]
side=1
[/filter]
id=test_playlist
description="Open Music Menu"
[command]
[message]
[option]
label="Currently playing track: $check_music"
[/option]
[option]
label="Close menu"
[/option]
[/message]
[/command]
[/set_menu_item]
[/event]
The error message appears every time I open the menu.
Author of Antar, Son of Rheor ( SP Campaign) | Development Thread + Feedback Thread + Replays of ASoR
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: store music ?
I am not sure then. When I paste that code as-is into a scenario it works as expected with no error messages.
edit-
Do you have any other add-ons installed? And do you still get the error without any of the music checking code:
edit-
Do you have any other add-ons installed? And do you still get the error without any of the music checking code:
Code: Select all
[event]
name=start,side turn,new turn
first_time_only=no
[set_menu_item]
[filter]
side=1
[/filter]
id=test_playlist
description="Open Music Menu"
[command]
[message]
[option]
label="Currently playing track: "
[/option]
[option]
label="Close menu"
[/option]
[/message]
[/command]
[/set_menu_item]
[/event]
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: store music ?
You are right, the code works .
When I start the campaign new from scenario 1, then the error messages are gone.
They only appear when I start from saveloads, though they shouldn't too.
Thank you for your help, and for the code, and for your time.
EDIT:
I found what caused the error message. It was indeed an other installed AddOn
Sorry for all circumstances.
When I start the campaign new from scenario 1, then the error messages are gone.
They only appear when I start from saveloads, though they shouldn't too.
Thank you for your help, and for the code, and for your time.
EDIT:
I found what caused the error message. It was indeed an other installed AddOn
Sorry for all circumstances.
Author of Antar, Son of Rheor ( SP Campaign) | Development Thread + Feedback Thread + Replays of ASoR