intfiction.org

The Interactive Fiction Community Forum
It is currently Sat Jan 19, 2019 7:18 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Jan 12, 2019 5:17 pm 
Offline

Joined: Fri Oct 06, 2017 8:19 am
Posts: 31
Hi,

Taking my first steps with Inform 7 after a couple of years of using Quest.

How do I return one description of an object if X is true and another if X is false?

I.E. if oject is open/worn/turned on etc.

Thank you.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sat Jan 12, 2019 5:29 pm 
Offline

Joined: Mon Dec 15, 2014 9:15 am
Posts: 404
You can embed conditions into a description.
Code:
The description of the wardrobe is "A big wardrobe of the old sort, with a looking-glass in the door[if the wardrobe is open]. The door is open, 
revealing several coats hanging up - mostly long fur coats[otherwise]. The door is closed[end if]."


(I've taken care to have the final . outside the condition. It looks slightly weird, but it helps Inform to get the spacing right if the description ends in . or !)


Inform doesn't like text subsitutions embedded in one another. If your description is going to be complicated, then it can work better to farm the whole thing out into a "to say" rule:
Code:
The description of the wardrobe is "[wardrobe_description]".

To say wardrobe_description:
      if the wardrobe is open:
           say "(whatever)";
      otherwise:
           say "(whatever else)".


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sat Jan 12, 2019 5:47 pm 
Offline

Joined: Fri Oct 06, 2017 8:19 am
Posts: 31
Thanks so much, that's just the help I needed.


Top
 Profile Send private message  
Reply with quote  
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: howtophil and 18 guests


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