I have a room that has two exits (left and right). When you enter the right side it works normaly, but for left side throws and ERROR that says, NewRoom..** is already quied....
This is the code i wrote:
//enter new area arrows----------------------------------------------------
if (GetWalkableAreaAt(mouse.x,mouse.y)==11) SetMouseCursor(0); //up
else if (GetWalkableAreaAt(mouse.x,mouse.y)==12) SetMouseCursor(1); //down
else if (GetWalkableAreaAt(mouse.x,mouse.y)==13) SetMouseCursor(3); //left
else if (GetWalkableAreaAt(mouse.x,mouse.y)==14) SetMouseCursor(5); //right
else SetDefaultCursor();
if ((IsButtonDown(RIGHT) || IsButtonDown(LEFT)) ==1){
if (GetWalkableAreaAt(mouse.x, mouse.y) > 9){
RestoreWalkableArea(10);
}
else RemoveWalkableArea(10);
}
//if (GetWalkableAreaAt(player.x,player.y) == 11) NewRoomEx(87,40,89);
//if (GetWalkableAreaAt(player.x,player.y) == 12) NewRoomEx(87,40,89);
if (GetWalkableAreaAt(player.x,player.y) == 13) NewRoomEx(104,299,130);
if (GetWalkableAreaAt(player.x,player.y) == 14) NewRoomEx(102,53,145);
//end of mouse cursor interface--------------------------------------------
Explanation of the code:
When mouse cursor goes over the walkable area 11,12,13 and 14it shows custom cursor (left,right, up and down arrow). In our cas only the left and right. When player clicks on that walkable area, walkable area 10 goes ON, so player can move trough it. But as i complicate thing while writing :) i uploaded this picture:
If I put line"if (GetWalkableAreaAt(player.x,player.y) == 14) NewRoomEx(102,53,145);" higher than "if (GetWalkableAreaAt(player.x,player.y) == 13) NewRoomEx(104,299,130);" it works, but this is still strange. (i tried using {} too, but it is the same).
(http://x3.putfile.com/7/18608360061.jpg)
All other rooms work normaly with this code, except this one.
I think it's because it continues to run the script to the end even though the room has changed. So the player coordinates change to (299, 130) which is in walkable area 14, and the second NewRoomEx() command is issued.
(It works when you swap it because (53, 145) is not in walkable area 13.)
You should put elses before each check like you did in the SetMouseCursor block:
//if (GetWalkableAreaAt(player.x,player.y) == 11) NewRoomEx(87,40,89);
//else if (GetWalkableAreaAt(player.x,player.y) == 12) NewRoomEx(87,40,89);
else if (GetWalkableAreaAt(player.x,player.y) == 13) NewRoomEx(104,299,130);
else if (GetWalkableAreaAt(player.x,player.y) == 14) NewRoomEx(102,53,145);
thanx, i will try to do that