Parse error: on Play();

Started by Sularias, Fri 08/06/2012 21:18:34

Previous topic - Next topic

Sularias

Let me start by saying I read not only the tutorial/Help file I also looked this up on the net as well.

I have never really programmed before (I'm a graphics guy by trade)

I have been trying to add audio to my first project and I keep getting a parse error.

I imported an MP3 Hang1.mp3 into the music folder under audio.

The Script name of said file is aHang1

according to the documentation I should type

aHang1.Play();   in the room1asc Script.

When I do this and hit build I get error    Parse error: unexpected 'aHang1'

Whiskey Tango Foxtrot!?

There is no other text in the script.

Deu2000

You say the whole file is like this?

Code: AGS

aHang1.Play();


In other case, please post your code.



monkey0506

AGS script events have to go inside of a function, so AGS knows when to run the code. In the room editor, with the room itself open (not just the room script), you can click the lightning bolt icon to select the room's events. From there you can select the appropriate event, say "Enters room (after fade-in)", click the "..." button to create the function in the room script, and then put your code inside the function (between the curly braces):

Code: ags
// room script

function room_AfterFadeIn()
{
  aHang1.Play();
}


Of course, this depends on when you want it to happen. The tutorial should cover most of the basic events, so just pick the appropriate function and put the command inside of it.

steptoe

Seeing as you say you only have the one line then you should check that you have a semi colon ; rather than a colan : at the end of the line.

Should be this
aHang1.Play();

And not this:
aHang1.Play():

It's not over until the fat lady sings..

monkey0506

Granted that such a typo could happen, not only did no one else type a colon in place of a semicolon, but it would generate a totally separate and distinct error message:

Quoteroom1.asc(1): Error (line 1): expected semicolon after ')'

So...I understand you're trying to be helpful, but posting things that are totally unrelated to the problem at hand typically aren't.

Khris

Helpful reply score: 1/3 (actually: 1/4, counting this one, but I had to comment on this... (roll)).

Sularias

My apologies for knowing well... nothing. I tried exactly that code... No sound started... I have not set up a fade in or anything at this point. But it didn't crash this time and I felt if not like a big man.. at least like a medium size man.


Quote from: monkey_05_06 on Fri 08/06/2012 21:41:23

Code: ags
// room script

function room_AfterFadeIn()
{
  aHang1.Play();
}



monkey0506

Quote from: monkey_05_06 on Fri 08/06/2012 21:41:23In the room editor, with the room itself open (not just the room script), you can click the lightning bolt icon to select the room's events. From there you can select the appropriate event, say "Enters room (after fade-in)", click the "..." button to create the function in the room script, and then put your code inside the function (between the curly braces).

Did you do that? If you did, then there's obviously some other issue with your sound (no sound card installed, volume muted, no midi driver but using midi sound, corrupted sound file, just to name some of the very basic, although also very limited reasons why sound wouldn't be working if you did). If you didn't do that, then do.

If you did it, just to prove to me that you did, change the code to this:

Code: ags
// room script

function room_AfterFadeIn()
{
  aHang1.Play();
  AbortGame("THE %c%c%c%c%c%c IS DOWN.", 83, 89, 83, 84, 69, 77);
}


I would like you to copy and paste the results, if possible.

And yes, this is me being a bit rude, but it's the second time I'm saying the same thing now. :D

SMF spam blocked by CleanTalk