Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: RickDeckard on Tue 03/03/2009 20:25:07

Title: Link to many rooms with one edge
Post by: RickDeckard on Tue 03/03/2009 20:25:07
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!
Title: Re: Link to many rooms with one edge
Post by: Trent R on Tue 03/03/2009 20:57:34
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
Title: Re: Link to many rooms with one edge
Post by: RickDeckard on Tue 03/03/2009 21:05:58
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.
Title: Re: Link to many rooms with one edge
Post by: Trent R on Tue 03/03/2009 21:41:32
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
Title: Re: Link to many rooms with one edge
Post by: RickDeckard on Tue 03/03/2009 22:29:26
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.
Title: Re: Link to many rooms with one edge
Post by: Pumaman on Tue 03/03/2009 22:57:07
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.
Title: Re: Link to many rooms with one edge
Post by: Trent R on Tue 03/03/2009 22:59:41
Oh duh. I told someone else that the other day... I should've caught that.


~Trent
Title: Re: Link to many rooms with one edge
Post by: RickDeckard on Tue 03/03/2009 23:09:15
Thanks!