Jump to content

Lua script audio when starting game (Urwigo)

Richard en Monja

Recommended Posts

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.

Link to comment

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.)

Link to comment

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()

As a precaution, though, you should probably follow the steps described by @capoaira above and figure out how the regular builders implement this.

Edited by Hügh
Link to comment

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...