Link to many rooms with one edge

Started by RickDeckard, Tue 03/03/2009 20:25:07

Previous topic - Next topic

RickDeckard

I want to get to different rooms over one edge, but it somehow doesn't work.

Thats the way I thought it shold work, but there must be a little mistake somewhere.
I bet this question was asked a million times before, but i was too lazy to look it up.

function room_LeaveTop()
{
int xort;
xort= cFred.x;
if (112<xort<196)cFred.ChangeRoom(4, 25, 144);
if (443<xort<526)cFred.ChangeRoom(11, 60,175);
if (600<xort<669)cFred.ChangeRoom(12, 17,130);
if (700<xort<763)cFerd.ChangeRoom(3, 30, 170);
if (800<xort<848)cFred.ChangeRoom(13, 52,173);
}
Thanks in advance!

Trent R

QuoteI bet this question was asked a million times before, but i was too lazy to look it up.
Not a good attitude for your first post...

But nonetheless I will help. I have a few questions: Is the function linked to the correct event? Have you adjusted your top edge down? Is there a walkable area in that location? Have you considered using Regions (which also might be cleaner code)?


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

RickDeckard

Thanks for your reply!
The edge is set properly, there are walkable areas, but as i pass the top edge, AGS tellst me, that it cant run the command, because there is another "New Room" Command queued. No I never considered using regions, cause I haven't used them yet.

Trent R

Quote from: From the Manual entry 'ChangeRoom'IMPORTANT: This command does not change the room immediately; instead, it will perform the actual room change once your script function has finished (This is to avoid problems with unloading the script while it is still running). This means that you should not use any other commands which rely on the new room (object positionings, and so on) after this command within the same function.

I think that since the command is delayed, it's trying to run all 4 of those ChangeRooms on the same character at once. Try changing those to else if (except the first one, of course)


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

RickDeckard

Now, there is no error message, but i always end up going to the first room (the one with the "if"), no matter where I pass the top edge.

Pumaman

This isn't a valid check:

if (112<xort<196)

you need to do this:

if ((112 < xort) && (xort < 196))

What you're currently doing expands to:

if (112 < xort)  ==> True (1)
if (1 < 196)  ==> True

so the first check will always succeed if xort > 112.

Trent R

Oh duh. I told someone else that the other day... I should've caught that.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune


SMF spam blocked by CleanTalk