(Solved!) How to Play MIDI Music using room scripts in AGS 3.2.1?

Started by Georgeqgreg, Thu 28/07/2011 20:56:14

Previous topic - Next topic

Georgeqgreg

Okay, this is probably really freakin' stupid for me to ask, but I've been trying to add MIDI music to a game I'm working on. I'm trying to add MIDI music but when I do I get a compile error. For reference that error is "room1.asc(5): Error (line 5): Undefined token 'PlayMusic'" I've look up instructions but they're all for 2.97!
My room script is currently:

// room script file

function room_FirstLoad()
{
PlayMusic(0);
Display("Hello! Welcome to Broken Quest V! The Big Rigs of Adventure Games! player.Walk(228, 128);");
}

Thank you for your time, I am very grateful for it. And if you need anymore info feel free to ask me!

arj0n

Import the midi file: Audio->Music->Rightclick->'Add audio file(s)...'

If, for example, imported as "Midi1" then:

aMidi1.Play();

Georgeqgreg

Nope, Sorry, didn't work. Still getting that stupid undefined token error. :( ???

But thanks a lot for the Prompt reply! ;D

Just so you know, the game now has a thread in: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=44088.0

barefoot

What Arjon told you was correct.

Recap.. Look on the bottom of the trees pane on the top right and you will see an 'Audio' folder. Click it open and Right click Music folder and select Add Audio file. a Box will open and you simply select your Audio file from where its location is.

Once its selected AGS will add it in your music Folder and will show its new filename.

Example: Upload Midi1 will become aMIDI1

Where you want it to play simply code: aMIDI1.Play();

Hope this helps

I May Not Be Perfect but I Have A Big Heart ..

Georgeqgreg

Not trying to sound jerkish or anything, but I've already taken care of that. What I'm trying to do is PLAY it!

Here, take a look at my screen. This should tell you everything you need to know.


arj0n

#5
there seems to be something wrong with your code. Should be something like:

Code: ags

function room_FirstLoad()
{
 aMidi1.Play();
 Display("Hello! Welcome to Broken Quest V! The Big Rigs of Adventure Games!");
 player.Walk(228, 128);
}

barefoot

It may be that it can't find Midi1 file.. check the Music folder and see if it is there.

Possibly run game set up and check settings..

Check that soundcard is not being used elsewhere!

I May Not Be Perfect but I Have A Big Heart ..

Georgeqgreg

No, Arj0n. That is very much intentional. I wrote like like that so It will print that command in text. Have a look!

Yes, that's right! I have a command in text! ;D (for reference, those co-ordinates would'nt work anyway!)

Anyway I solved it myself. The new script is:

function room_FirstLoad()
{
MIDI1.Play();
Display("Hello! Welcome to Broken Quest V! The Big Rigs of Adventure Games! player.Walk(228, 128);");
}

(Yes, that's right, I just had to remove "a")

barefoot

I May Not Be Perfect but I Have A Big Heart ..

Georgeqgreg

And thank you! I couldn't have done it without your help!

monkey0506

There's two things you have to keep in mind here:

1) AGS is case-sensitive. "MIDI.Play()" and "Midi.Play()" are not the same thing. This is very important!

2) The new audio files are listed in the editor by their exact script name. Arj0n was a bit confused (happens to all of us), but if it shows up in the editor as "aMIDI1" then you will need to use "aMIDI1.Play()", but if it just shows up as "MIDI1" then you'll use "MIDI1.Play()". AGS should have automatically added the 'a' to the beginning of the filename, but it's not necessary so long as you use the correct script name. ;)

In any case, welcome to the forums, and the wonderful, wonderful world of AGS. Don't turn into a troll or everyone will laugh at you. :=

SMF spam blocked by CleanTalk