Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: HandsFree on Wed 12/08/2015 17:54:43

Title: import audioclip array [solved]
Post by: HandsFree on Wed 12/08/2015 17:54:43
In GlobalScript.asc I have this:
AudioClip *minstrel_tune[5];

I want to use that elsewhere, so I think I should put an import statement in GlobalScript.ash, is that correct?
If so, how do I write that statement? Cause I keep getting errors.
import AudioClip *minstrel_tune[5]; ??
(Also tried without the *)

thanks
Title: Re: import audioclip array
Post by: Crimson Wizard on Wed 12/08/2015 18:20:25
Regarding import/export, this was explained many times in the past few months; I'd better link to existing thread:
For example: http://www.adventuregamestudio.co.uk/forums/index.php?topic=52018

Regarding erros, can you please copy paste the error text here?
Your declaration looks fine to me. But there could be numerous errors related to variable declaration, that are and aren't relevant to import keyword. This also matters if that's compilation error you get in the Editor, or runtime error you get when running the game.
Title: Re: import audioclip array
Post by: HandsFree on Wed 12/08/2015 18:32:50
Yes, I saw that, but since this one is with an *-sign, I'm not sure how that works.
In GlobalScript.asc:
AudioClip *minstrel_tune[5];

Code (ags) Select

function game_start() {
...
minstrel_tune[0] = aLute_song1;
minstrel_tune[1] = aLute_song2;
...
}

In GlobalScript.ash:
import AudioClip *minstrel_tune[5];

In room14.asc:
MinstrelMusic = minstrel_tune[iMinstrelTune].Play(eAudioPriorityHigh, eRepeat);

Error: Unable to create local script: Runtime error: unresolved import 'minstrel_tune'.

thanks
Title: Re: import audioclip array
Post by: Crimson Wizard on Wed 12/08/2015 18:38:26
You forgot to do "export minstrel_tune;" in GlobalScript.asc.
Title: Re: import audioclip array
Post by: HandsFree on Wed 12/08/2015 18:53:53
Yes, that was it.
thanks