+Richard en Monja Posted December 29, 2020 Posted December 29, 2020 Hello, I am new to Wherigo cartridges en lua scripts..... I looking for an lua script that plays a mp3 soundfile once at startup of a game. Thanks in advance. Richard. Quote
+capoaira Posted December 29, 2020 Posted December 29, 2020 Try to use a Wherigo-builder like urwigo. These have defined many methods. Also one to start an audio. Quote
+Richard en Monja Posted December 29, 2020 Author Posted December 29, 2020 Thanks for the reply, but what I want is following: Before Wherigo.ShowScreen(Wherigo.MAINSCREEN) I want to add an lua script to play an audio mp3 file. If I add an audio file with Urwigo "Play Sound" than it plays the mp3 file, but then the game does not start up anyfurther. When the Lua script is added directly in the Lua user functions it might work. Thanks in advance. Quote
+capoaira Posted December 29, 2020 Posted December 29, 2020 I would use the blocks for anything I can. I only use lua source code for arrays or moving zones - it's easier;) To see how a sound is played you can try the following: 1. Create a cartridge that plays a sound in the onStart event 2. Create a .gwz file 3. Unzip the .gwz file 4. There should be a lua file. Search there how Urwigo implemented the play sound file. (Sorry for my english. I used google to translate.) Quote
+Hügh Posted December 30, 2020 Posted December 30, 2020 (edited) If my memory serves me right, you first must create a Wherigo.ZMedia object and pass your cartridge to its constructor. audio = Wherigo.ZMedia(cart) You then must set its Resources field accordingly. audio.Id = "00000000000000000000000000000000" audio.Name = "Sound Effect" -- the Name and Id fields probably aren't strictly -- necessary, but I've never tested that myself so -- I'm not sure. Some players may crash w/o them. audio.Resources = { { Type = "mp3", -- waveforms (wav) should also be vaild. Filename = "path_to_effect_in_gwz.mp3", Directives = {} } } To play the audio, you can call the Wherigo.PlayAudio method, and pass the audio object instance as the first argument. function cart:OnStart() Wherigo.PlayAudio(audio) end As a precaution, though, you should probably follow the steps described by @capoaira above and figure out how the regular builders implement this. Edited December 30, 2020 by Hügh Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.