intfiction.org

The Interactive Fiction Community Forum
It is currently Wed Jun 19, 2013 5:22 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Jun 15, 2012 2:47 pm 
Offline

Joined: Wed Jun 13, 2012 9:14 pm
Posts: 14
This feels like a stupid question, but I can't find the answer in any of the documentation.

I have this source code

A basic table called a strange metal table is in The Chamber.
An open transparent container called a glass is on the table.
The glass contains water.
instead of drinking water:
remove the noun from play;
say "It's cool and refreshing."

There is an open container called a silver bowl on the table.
There is an apple in the bowl. The apple is edible.


which appears ingame as this from just seeing the room.

You can see an unusual bed and a strange metal table (on which are a glass (in which is water) and a silver bowl (in which is an apple)) here.


I want it to be cleaner, something like: "You can see an unusual bed and a strange metal table, on which is a glass of water and a silver bowl of fruit."

I'm having a terrible time kenning how to do so though.


Top
 Profile Send private message  
 
PostPosted: Fri Jun 15, 2012 4:17 pm 
Offline
User avatar

Joined: Thu Nov 04, 2010 6:30 am
Posts: 999
Location: Gothenburg, Sweden
Chapter 17.10 of the docs, on the printing the name of something activity, gives an example of how to do this kind of thing using the phrase 'omit contents in listing'.

_________________
Man ska inte tro allt man tänker.


Top
 Profile Send private message  
 
PostPosted: Fri Jun 15, 2012 6:45 pm 
Offline

Joined: Wed Jun 13, 2012 9:14 pm
Posts: 14
Ok, that was exactly what I needed. How would you format it for multiple objects in the container or description? I was trying something like this

Rule for printing the name of the silver bowl while not inserting or removing:
if the silver bowl contains an apple and an orange begin;
say "silver bowl of fruit";
otherwise if the silver bowl contains an orange;
say "silver bowl, there is an orange in it";
otherwise if the silver bowl contains an apple;
say "silver bowl, there is an apple in it";
omit contents in listing.



The glass of water part works fine now, but I can't seem to figure out how to make the bowl do the same using multiple objects. I've tried it with 'if...begin' and 'end if', but the 'omit contents in listing' seems to interfere with the 'end if'. That may be totally wrong anyway. Maybe I'm not using 'otherwise' properly. I'm staring at the documentation 11.08, 17.10 and the cheat sheet, but its not quite coming together.

Edit: Ok, so it looks like the issue is more than just 'otherwise'. It doesn't seem to like the fact this "if the silver bowl contains an apple and an orange" at all. Is there some way to create a condition that uses more than one factor like that? Or did I just
attempt the impossible?

Edit 2: Ok, so this works

Rule for printing the name of the silver bowl while not inserting or removing:
if the silver bowl contains more than one thing, say "silver bowl of fruit";
omit contents in listing.


Going to try and create 'fruit' as a kind of thing to be a little more specific. Still not sure how to have it check for only one specific fruit or the other and get the description correct.

Edit 3: Woo!

Rule for printing the name of the silver bowl while not inserting or removing:
if the silver bowl contains more than one thing begin;
say "silver bowl of fruit";
otherwise if the bowl contains an orange;
say "silver bowl with an orange in it.";
otherwise if the bowl contains an apple;
say "silver bowl with an apple in it.";
end if;
omit contents in listing.


It works!


Top
 Profile Send private message  
 
PostPosted: Sat Jun 16, 2012 2:02 pm 
Offline

Joined: Sun Dec 05, 2010 11:07 am
Posts: 321
Location: ኢትዮጵያ
As an aside, it's generally good practice to make code as general purpose as possible. The following will format the table's nondescript description as you wanted, without hardcoding the display of the contents of the containers on it:

Code:
Chamber is a room.

A basic table is a kind of supporter.

A basic table called a strange metal table is in The Chamber.

An open transparent container called a glass is on the strange table.

Rule for printing the name of the glass when the glass contains something:
   say "glass of [list of things in the glass]".

The glass contains water.
   instead of drinking water:
      remove the noun from play;
      say "It's cool and refreshing."

The strange table supports a silver bowl.

A fruit is a kind of thing. Fruits are usually edible.

There is a fruit called an apple in the bowl. An orange is a fruit in the bowl.

After printing the name of the strange metal table while listing contents:
   if the strange table supports something:
      say ", on which is [a list of things on the strange table]";
      omit contents in listing.

Rule for printing the name of the silver bowl while listing contents:
   if the silver bowl contains more than one thing begin;
      say "silver bowl of [a list of things in the bowl]";
   otherwise;
      say "silver bowl[if the silver bowl contains one thing] with [a list of things in the bowl] in it[end if]";
   end if;
   omit contents in listing.
   
Before listing contents: group fruits together as "fruit".
Rule for grouping together fruits when not taking inventory: say "fruit".


Top
 Profile Send private message  
 
PostPosted: Sat Jun 16, 2012 4:32 pm 
Offline

Joined: Wed Jun 13, 2012 9:14 pm
Posts: 14
Oh, cool. That's good to know. Many thanks.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 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