intfiction.org

The Interactive Fiction Community Forum
It is currently Thu May 23, 2013 5:45 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Mar 24, 2011 5:48 pm 
Offline

Joined: Mon Jan 10, 2011 5:41 pm
Posts: 43
HELP!

I am trying to find a method for a pc who drops an object to lose the object. That in itself is simple enough, just define a dobjFor(Drop) and move to it to nil. In the game I would like to have the pc be able to drop items which the pc needs, only in certain places, ie in buildings, while in outdoor rooms the item would be lost. Is there a room property for example to test for the kind of room the pc is in? Using if or switch statements would work but there are about 50 outdoor rooms so far, so if there is an easier way to check for the room type that would be easier. Any ideas anybody?


Top
 Profile Send private message  
 
PostPosted: Thu Mar 24, 2011 6:14 pm 
Offline

Joined: Tue Apr 27, 2010 1:02 pm
Posts: 797
You can use the ofKind method (defined on all objects) to check the room type.

Code:
modify Thing
    dobjFor(Drop)
    {
        action()
        {
            if (!gActor.getOutermostRoom().ofKind(OutdoorRoom))
            {
                "You drop <<theName>>. ";
                inherited();
            }
            else
            {
                "You drop <<theName>>. It is carried away by the wind! ";
                moveInto(nil);
            }
        }
    }
;


Top
 Profile Send private message  
 
PostPosted: Fri Mar 25, 2011 3:57 am 
Offline

Joined: Mon Jan 10, 2011 5:41 pm
Posts: 43
A simple and elegant solution to my problem. Thank you!


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group