Hi folks. Returning to AGS after a long hiatus and I appear to have forgotten how to do a really simple thing. A whole morning of searching and experimenting has yielded nothing.
I want to be able to easily call an 'interact' animation from room scripts and dialogs. From memory, I needed to define a new function in the global script then call it from the room script. From reading, it seemed I needed to import the function in the header script too.
So I did this in the global script:
function interact_faye_down()
{
player.ChangeView(6);
player.Animate(0, 0, eOnce, eBlock, eForwards);
player.Animate(0, 0, eOnce, eBlock, eBackwards);
player.ChangeView(4);
}
function interact_faye_left()
{
player.ChangeView(6);
player.Animate(1, 0, eOnce, eBlock, eForwards);
player.Animate(1, 0, eOnce, eBlock, eBackwards);
player.ChangeView(4);
}
function interact_faye_right()
{
player.ChangeView(6);
player.Animate(2, 0, eOnce, eBlock, eForwards);
player.Animate(2, 0, eOnce, eBlock, eBackwards);
player.ChangeView(4);
}
function interact_faye_up()
{
player.ChangeView(6);
player.Animate(3, 0, eOnce, eBlock, eForwards);
player.Animate(3, 0, eOnce, eBlock, eBackwards);
player.ChangeView(4);
}
(Actually, to start with I tried to create a function with a definable string of up/down/left/right and used if/else conditions, but this didn't seem to work, so I tried breaking it down like this to see if I had any more joy.)
Then, in the header script, I've got:
import interact_faye_down;
import interact_faye_left;
import interact_faye_right;
import interact_faye_up;
But I'm getting the following error whenever I try to compile:
expected variable or function after import, not 'interact_faye_down'
Banging my head against the wall because I've done this in two previous games, as second nature, but years ago. Any help desperately appreciated. Thanks!
You must define the full declaration of imported symbol, or other scripts would not know what is this and how to use it.
import function interact_faye_down();
import function interact_faye_left();
import function interact_faye_right();
import function interact_faye_up();
*slaps forehead* -- knew it would be super simple.
Thanks!
Regarding using a single function:
//header
enum Loop {
eLoopDown, // numbering starts at 0
eLoopLeft,
eLoopRight,
eLoopUp
};
import function interact_faye(Loop loop);
//script
function interact_faye(Loop loop)
{
player.LockView(FAYEINTERACT);
player.Animate(loop, 0, eOnce, eBlock, eForwards);
player.Animate(loop, 0, eOnce, eBlock, eBackwards);
player.UnlockView();
}