Hi! I'm trying to play a sound, I've imported it to: Audio/Sounds and I've added to room script line:
// room script file
aSound1.Play();
function hLadder_AnyClick(Hotspot *theHotspot, CursorMode mode)
{
cEgo.Say("These are falling apart..shame..");
}
function hHotspot2_AnyClick(Hotspot *theHotspot, CursorMode mode)
{
cEgo.Say("Some old mining machinery. Dead since ages");
}
function oObject0_Look(Object *theObject, CursorMode mode)
{
cEgo.Say("What's that?");
}
(I've pasted whole room code)
Hovever I'm recieving an Parse error: unexpected 'aSound1' line 3
What am I doing wrong? :/
Like
@Snarky explained, commands like that always go
inside functions so AGS knows
when to play the sound.
AGS scripting is event-based, which means when certain events occur (a room loads, hLadder is clicked, etc.) AGS checks if a function is linked to the event, then runs the function. Which means the code inside the function is executed.
Ok...I'm grasping the idea (sort of.. ;) ), but how to set this up? Coud you please give me an example? :)
I've tried chat GPT but still no luck..
// room script file
function room_Load() {
// Kod do odtworzenia dźwięku
aSound1.Play();
}
function hLadder_AnyClick(Hotspot *theHotspot, CursorMode mode)
{
cEgo.Say("These are falling apart..shame..");
}
function hHotspot2_AnyClick(Hotspot *theHotspot, CursorMode mode)
{
cEgo.Say("Some old mining machinery. Dead since ages");
}
function oObject0_Look(Object *theObject, CursorMode mode)
{
cEgo.Say("What's that?");
}
Do NOT use ChatGPT for this.
I explained how here:
https://www.adventuregamestudio.co.uk/forums/beginners-technical-questions/resize-player-character/msg636662736/#msg636662736
Just typing out the function is not enough, it needs to be linked to the event.
This is also explained here:
https://adventuregamestudio.github.io/ags-manual/acintro3.html
And judging from the rest of your room script, you've already done this.
Thank you, it worked!