Currently Online

Latest Posts

Topic: How to use play_sound?

kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2550
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: Yesterday 18:00

I am trying to use the play_sound function in a scenario, but somehow this does not work for me. I get always failures similar to:

FATAL EXCEPTION: [:0] FXset: No files matching the pattern 'thunderstorm_<numbers>.ogg' found in directory scripting/sounds/

The soundfile "thunderstorm_00.ogg" is stored in scripting/sounds below the map folder. The documentation for playsound says it should be stored below the data/ folder, but this isn't available for map/scenario authors.

Regardless which pattern i use the file can not be found. The following i have tried:

play_sound("scripting/sounds/thunderstorm_00.ogg")
play_sound("scripting/sounds/thunderstorm")            -- According to documentation this should work?
play_sound("map:scripting/sounds/thunderstorm_00.ogg")
play_sound("map:scripting/sounds/thunderstorm")

Which mistake i do?
How can play_sound be used for scenarios?


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2738
Ranking
One Elder of Players
Location: Bavaria
Posted at: Yesterday 20:51

I had a similar issue once before when trying to add images to scenariospecific units.
you have to specify the complete path of the scenario relative to the data folder

play_sound("campaigns/emp04.wmf/scripting/sounds/thunderstorm" or

play_sound("maps/my_scenario.wmf/sounds/thunderstorm"


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2550
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: Today 09:50

hessenfarmer wrote:

you have to specify the complete path of the scenario relative to the data folder

"relative to the data folder" is relative face-grin.png

Ahh, i think i misunderstand "data folder" with the main data folder of widelands, but meant is the folder where maps and savegames are stored (.widelands)?

play_sound("maps/my_scenario.wmf/sounds/thunderstorm"

This works for me, but probably will not work for others. E.g. if the scenario is installed as an add-on (".widelands/addons/som/name/"" or if the map is stored in a different folder than My_Maps, e.g. .widelands/maps/Downloaded.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2738
Ranking
One Elder of Players
Location: Bavaria
Posted at: Today 09:57

if you provide the map as a real addon you should use the addon file system.

see https://github.com/widelands/widelands/issues/6490

this would make it probably save for everyone using the map


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2738
Ranking
One Elder of Players
Location: Bavaria
Posted at: Today 09:59

kaputtnik wrote:

hessenfarmer wrote:

you have to specify the complete path of the scenario relative to the data folder

"relative to the data folder" is relative face-grin.png

Ahh, i think i misunderstand "data folder" with the main data folder of widelands, but meant is the folder where maps and savegames are stored (.widelands)?

AFAIK the main data folder is meant in this definition. However it may be possible that .widelands/maps is linked to data/maps


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2550
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: Today 10:16

hessenfarmer wrote:

if you provide the map as a real addon you should use the addon file system.

see https://github.com/widelands/widelands/issues/6490

this would make it probably save for everyone using the map

Thanks face-smile.png


Top Quote