I've seen tutorials on youtube, "How to use AGS" ... etc. ..
What I want is to move a second character in my room, is a secondary character, for which I have just made the sprites to move left and right. My intention is to put in the script of the room, the commands needed for this character to move repeatedly from side to side, and stop when he says something
It turns out that in the tutorial uses a function called: room_AfterFadeIn() which I think is obsolete ... because it does not work anything inside it.
What is the problem? Do you recommend me?
It's not obsolete. The problem is you can't just add that function to the room script, you have to link it to the corresponding event. This is explained in part three of the tutorial in the manual:
http://www.adventuregamestudio.co.uk/acintro3.htm
Instead of adding the look event to the hotspot, add the after fadein event to the room itself.
You'll also need the room's repeatedly_execute event & function.
There are lots of existing threads about how to do character movement in the background, so I recommend to start there (http://www.adventuregamestudio.co.uk/forums/index.php?action=search).
Ok, thank you very much. It works. But now there is another problem, when it is the repetition of character movement, the pointer is a clock waiting ... and the icon-bar disappears ... (wtf)
Yeah, that's because you're using blocking functions for something that's supposed to happen in the background.
You have to use eNoBlock in the .Walk command.
But why don't you post the code you used or at least the thread you based it on so we have something to work with?
Ok you're right, I insert the script of my room, because I still have the same problem after putting in commands eNoBlock Walk. The game continues to show the pointer clock to run...
// room script file
function room_AfterFadeIn()
{
cJack.Walk(55, 112, eNoBlock, eWalkableAreas);
Wait(40);
cJack.Walk(57, 123, eNoBlock, eWalkableAreas);
}
function room_RepExec()
{
cbarry.Walk(180, 114, eNoBlock, eWalkableAreas);
Wait(80);
cbarry.Walk(140, 114, eNoBlock, eWalkableAreas);
Wait(80);
}
You are misusing "repeatable execute" function, a mistake quite common though.
To make this clear: a "repeatable execute" function is meant to process continious events that update very often, and is supposed to be called each game frame.
You should never put Wait call inside "rep exec" except for very specific cases.
Besides, Wait() blocks player controls.
To make character "patrol" over room, use different solution:
// This function is being called like 40 times per second!
function room_RepExec()
{
// What we do here is checking if character is not moving, and
// if he isn't, make him start; if he is moving right now, though,
// we just skip over and continue
if (!cbarry.Moving) // has Barry stopped?
{
// make him move again
if (cbarry.X == 180) // if he's at X 180, then move him to 140
cbarry.Walk(140, 114, eNoBlock, eWalkableAreas);
else // and vice versa
cbarry.Walk(180, 114, eNoBlock, eWalkableAreas);
}
}
Okay, thank you very much for your response Crimson Wizard, and also for your help Khris. The problem has been solved, I just want to add that I need to wait for the character to do, when I type the commands Walk, between the two. But from what you say, I can not include Wait. I can include another command?
Also for the character Jack
function room_AfterFadeIn()
{
cJack.Walk(55, 112, eNoBlock, eWalkableAreas);
cJack.Walk(57, 123, eNoBlock, eWalkableAreas);
}
function room_RepExec()
{
if (cbarry.Moving == false)
{
if (cbarry.x == 180)
cbarry.Walk(140, 114, eNoBlock, eWalkableAreas);
else
cbarry.Walk(180, 114, eNoBlock, eWalkableAreas);
}
}
Quote from: sergiopz86 on Thu 01/11/2012 22:55:27I just want to add that I need to wait for the character to do, when I type the commands Walk, between the two. But from what you say, I can not include Wait. I can include another command?
No no, that is not exactly what I meant.
I said that you should not use Wait inside RepExec. You may use Wait in other functions, like AfterFadeIn.
RepExec is different from others. Try to think about RepExec like about a "check" that is done every second. Instead of waiting for some action to complete, you check for it every now and then. If it is not the time yet, simply quit from function (do nothing).
sergio is asking how to include Wait() without including Wait().
Try this:
int delay;
function room_RepExec()
{
if (cbarry.Moving == false)
{
if (delay > 0) delay--;
else {
delay = 80;
if (cbarry.x == 180)
cbarry.Walk(140, 114, eNoBlock, eWalkableAreas);
else
cbarry.Walk(180, 114, eNoBlock, eWalkableAreas);
}
}
}
OK, IT WORKS PERFECTLY!! (nod)
Problem Solved. Thank you very much to both