Game authors and players, please read this thread!

Author Topic: Link to many rooms with one edge  (Read 440 times)  Share 

Link to many rooms with one edge
« on: 03 Mar 2009, 20:25 »
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

  • "I am the weapon" -Richard Cypher
    • I can help with AGS tutoring
    •  
    • I can help with scripting
    •  
Re: Link to many rooms with one edge
« Reply #1 on: 03 Mar 2009, 20:57 »
Quote
I 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

Re: Link to many rooms with one edge
« Reply #2 on: 03 Mar 2009, 21:05 »
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

  • "I am the weapon" -Richard Cypher
    • I can help with AGS tutoring
    •  
    • I can help with scripting
    •  
Re: Link to many rooms with one edge
« Reply #3 on: 03 Mar 2009, 21:41 »
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

Re: Link to many rooms with one edge
« Reply #4 on: 03 Mar 2009, 22:29 »
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

  • Creator of AGS
  • Administrator
  • Mittens TRAITOR
  • I sense danger.
    • Lifetime Achievement Award Winner
    •  
Re: Link to many rooms with one edge
« Reply #5 on: 03 Mar 2009, 22:57 »
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

  • "I am the weapon" -Richard Cypher
    • I can help with AGS tutoring
    •  
    • I can help with scripting
    •  
Re: Link to many rooms with one edge
« Reply #6 on: 03 Mar 2009, 22:59 »
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

Re: Link to many rooms with one edge
« Reply #7 on: 03 Mar 2009, 23:09 »
Thanks!