Argh!
Been since yesterday trying to get this to work, but to no avail!
I'm trying to get some NPCs to go from one point to another, then to yet another point and then move room. And this will be true for 7 or 9 characters.
This will be running on the background, so the player can go on doing whatever he/she likes.
So I go this code in room1, which works just fine, except that it's calling the character by name and not variable (using Move because I have yet to create more than one sprite for the NPCs).
Code: ags
As I said, this works just fine. However, I really don't want to have to write the same for 7 or more characters and just change the names. Ideally my character name needs to be a variable, that I can either read from a txt file or from a set of strings.
so I've been trying to use extender functions, but seems like every time I put an IF in the function, it stops from reading the remaining lines.
Here's the code:
Code: ags
Code: ags
I've been following this thread to try and figure it out: http://www.adventuregamestudio.co.uk/forums/index.php?topic=39894.msg525594#msg525594
(And no, I have yet to try coding the name variable, but if I can't get the code to work when it's "simple", then there's no point in continuing, right?)
Been since yesterday trying to get this to work, but to no avail!

I'm trying to get some NPCs to go from one point to another, then to yet another point and then move room. And this will be true for 7 or 9 characters.
This will be running on the background, so the player can go on doing whatever he/she likes.
So I go this code in room1, which works just fine, except that it's calling the character by name and not variable (using Move because I have yet to create more than one sprite for the NPCs).
function repeatedly_execute_always()
{
if (cJake.x>446)
{
oBubble.StopAnimating();
background_animation=false;
object[1].Visible=false;
}
else if (background_animation==false)
{
object[1].Visible=true;
oBubble.SetView (28, 0, 1);
oBubble.Animate(0, 10, eRepeat, eNoBlock);
background_animation=true;
SetTimer(1, 200);
}
else if (IsTimerExpired(1)==1)
{
cMRandy.SayBackground("... Mick ...");
cMick.Move(516, 274, eNoBlock, eAnywhere);
SetTimer(2, 200);
cMick.SayBackground("1");
}
else if (IsTimerExpired(2)==1)
{
checked_in=true;
cMick.SayBackground("2");
cMick.Move(200, 240, eNoBlock, eWalkableAreas);
SetTimer(1, 400);
}
else if ((cMick.Moving==0) & (checked_in==true))
{
cMRandy.SayBackground("3");
cMick.ChangeRoom(3);
checked_in=false;
}
}
As I said, this works just fine. However, I really don't want to have to write the same for 7 or more characters and just change the names. Ideally my character name needs to be a variable, that I can either read from a txt file or from a set of strings.
so I've been trying to use extender functions, but seems like every time I put an IF in the function, it stops from reading the remaining lines.

Here's the code:
// main global script file
bool checked_in=false;
function RollCall (Character*chartobecalled)
{
cMRandy.SayBackground("... Mick ...");
chartobecalled.Move(516, 274, eNoBlock, eAnywhere);
SetTimer(2, 200);
chartobecalled.SayBackground("1");
if (IsTimerExpired(2)==1)
{
checked_in=true;
chartobecalled.SayBackground("2");
chartobecalled.Move(200, 240, eNoBlock, eWalkableAreas);
SetTimer(1, 400);
}
else if ((cMick.Moving==0) & (checked_in==true))
{
cMRandy.SayBackground("3");
chartobecalled.ChangeRoom(3);
checked_in=false;
}
}
// room script file
bool background_animation = false;
bool checked_in = false;
import function RollCall (Character*chartobecalled);
function repeatedly_execute_always()
{
if (cJake.x>446)
{
oBubble.StopAnimating();
background_animation=false;
object[1].Visible=false;
}
else if (background_animation==false)
{
object[1].Visible=true;
oBubble.SetView (28, 0, 1);
oBubble.Animate(0, 10, eRepeat, eNoBlock);
background_animation=true;
SetTimer(1, 200);
}
else if (IsTimerExpired(1)==1)
{
RollCall(cMick);
}
I've been following this thread to try and figure it out: http://www.adventuregamestudio.co.uk/forums/index.php?topic=39894.msg525594#msg525594
(And no, I have yet to try coding the name variable, but if I can't get the code to work when it's "simple", then there's no point in continuing, right?)