Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: fitbo on Mon 27/03/2006 15:04:18

Title: blocking script
Post by: fitbo on Mon 27/03/2006 15:04:18
Hey, I have a little problem:

the player is waiting for the bus. Once the bus arrives the player can click on the open door and so enters the bus. Then the bus closes its door and moves out of the screen.Here is what I wrote:


if ((mouse.IsButtonDown(eMouseLeft))&&(mouse.Mode == eModeWalkto)&&(mouse.x >=228)&&(mouse.x <=256)&&(mouse.y >=79)&&(mouse.y <=170)&&(timer >=301))

player.Walk(240, 192, true)&&
character[ARTHUR].ChangeView(25)&&
object[16].SetView(24, 3)&&
object[2].Animate(2, 3, eOnce, eNoBlock, eBackwards)&&
object[2].Move(500, 190, 1, eNoBlock, eAnywhere);


if ((timer >=301)&&(character[ARTHUR].View ==25))
object[16].Visible =false;


if ((timer ==305)&&(character[ARTHUR].View ==25))
object[2].Animate(1, 1, eRepeat, eNoBlock, eForwards);

if ((timer ==305)&&(character[ARTHUR].View ==25))
object[2].Move(500, 190, 1, eBlock, eAnywhere);



if ((timer ==310)&&(character[ARTHUR].View ==25))
object[2].Move(500, 190, 2, eBlock, eAnywhere);



if ((timer ==315)&&(character[ARTHUR].View ==25))
object[2].Move(500, 190, 3, eBlock, eAnywhere);


if ((timer ==320)&&(character[ARTHUR].View ==25))
object[2].Move(500, 190, 4, eBlock, eAnywhere);


if ((timer ==325)&&(character[ARTHUR].View ==25))
object[2].Move(500, 190, 5, eBlock, eAnywhere);


if ((timer >=330)&&(object[2].X >=450))
player.ChangeRoom(10,274,122);

The problem is that the sript only executes the first two commands, and then stops. I set the player to view 25, which is a black screen, so that the player becomes invisible. Object[2] is the bus and object[16] is the open door of the bus. So when the player clicks on the open door, the player disappears and comes back as a part of object[16] (the backside of the player can be seen, when he stands on the stairs of the bus, and then completely disappears when the bus closes it's door. I don't know what the problem is, but it looks like a blocking script.

I've already wasted too much time with this,  help would be great

Title: Re: blocking script
Post by: DoorKnobHandle on Mon 27/03/2006 15:17:10
I didn't read through all your code, but one thing you can't do is connecting lines of code with "&&".

Example:

Wrong

DoSomething ( ) &&
DoSomethingElse ( );


Right

DoSomething ( );
DoSomethingElse ( );
Title: Re: blocking script
Post by: SSH on Mon 27/03/2006 15:22:28
Well, actually you probably can do it like that, but as soon as the first function retunrs non-zero, the rest will fail to execute.
Title: Re: blocking script
Post by: fitbo on Tue 28/03/2006 10:06:58
if i don't use "&&", then the player instantly disappears when he first enters the room, and the bus stops on the wrong place, the door is open, and when I click with the emodewalkto on the door, the bus closes its door and moves out of the screen. So the end is ok, but the beginning is a clomplete mess. Can't it be that I wrote the script too long winded and not simple enough?
Title: Re: blocking script
Post by: SSH on Tue 28/03/2006 10:38:17
I think what you're missing is curly braces around the group of statements after the first if.
Title: Re: blocking script
Post by: Pumaman on Tue 28/03/2006 19:16:00
In other words, it should look like this:


if ((mouse.IsButtonDown(eMouseLeft))&&(mouse.Mode == eModeWalkto)&&(mouse.x >=228)&&(mouse.x <=256)&&(mouse.y >=79)&&(mouse.y <=170)&&(timer >=301))
{
Ã,  player.Walk(240, 192, true);
Ã,  character[ARTHUR].ChangeView(25);
Ã,  object[16].SetView(24, 3);
Ã,  object[2].Animate(2, 3, eOnce, eNoBlock, eBackwards);
Ã,  object[2].Move(500, 190, 1, eNoBlock, eAnywhere);
}