blocking script

Started by fitbo, Mon 27/03/2006 15:04:18

Previous topic - Next topic

fitbo

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


DoorKnobHandle

I didn't read through all your code, but one thing you can't do is connecting lines of code with "&&".

Example:

Wrong
Code: ags

DoSomething ( ) &&
DoSomethingElse ( );


Right
Code: ags

DoSomething ( );
DoSomethingElse ( );

SSH

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.
12

fitbo

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?

SSH

I think what you're missing is curly braces around the group of statements after the first if.
12

Pumaman

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);
}

SMF spam blocked by CleanTalk