intfiction.org

The Interactive Fiction Community Forum
It is currently Wed Jun 20, 2018 2:43 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 15 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue Aug 17, 2010 9:34 am 
Offline

Joined: Fri Jul 16, 2010 2:09 pm
Posts: 2163
I'm sure this has been asked before, but hopefully there's a quick answer.

Is there a way to make the initial description of something appear when it is revealed in a container?

Code:
"Potty Mouth"

The bathroom is a room.

The toilet is a closed openable container in the bathroom. "[toilet status].". The description is "[toilet status].". It is fixed in place. Understand "seat/lid/bowl" as the toilet.

To say toilet status:
   say "The toilet lid is [if the toilet is open]up[otherwise]down[end if]"

A toothbrush is in the toilet. "The end of a toothbrush is sticking out of the toilet drain. Thankfully, there's no water in the toilet."


Quote:
Potty Mouth
An Interactive Fiction
Release 1 / Serial number 100817 / Inform 7 build 6E58 (I6/v6.31 lib 6/12N) SD

bathroom
The toilet lid is down.

>open toilet
You open the toilet, revealing a toothbrush.

>x toilet
The toilet lid is up.

In the toilet is a toothbrush.

>look in toilet
In the toilet is a toothbrush.

>x toothbrush
You see nothing special about the toothbrush.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Tue Aug 17, 2010 11:18 am 
Offline

Joined: Sun Mar 01, 2009 8:02 pm
Posts: 1619
Good question! I'd like to know the answer. And for supporters as well as containers. You'll need to modify some of the Standard Rules -- and this is complicated by a couple of factors. Mainly, the rules in question are set up to build a list. If your player puts five more things into the toilet, your game is going to have to be able to construct an appropriate list ... yet your toothbrush will need to be mentioned before the list, and the list will need to start, "Also in [the item] you can see...."

I think this is a worthwhile enhancement to tuck away in an Extension. Maybe someone more experienced than I with the inner workings of the Standard Rules will be motivated to tackle it.

--JA


Top
 Profile Send private message  
Reply with quote  
PostPosted: Tue Aug 17, 2010 11:24 am 
Offline

Joined: Fri Jul 16, 2010 2:09 pm
Posts: 2163
Maybe the most practical solution in this case would be to put the text in an "after opening the toilet for the first time" rule.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Aug 19, 2010 10:34 am 
Offline

Joined: Fri Jul 16, 2010 2:09 pm
Posts: 2163
I'm bumping this topic because now I have a supporter with the same problem. In this case "for the first time" isn't going to work because it's not an issue of opening and closing.

I'm considering lying about the object being on the supporter, and having it actually just be in the location. I think I've noticed others doing the same thing.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Aug 19, 2010 11:19 am 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5289
Location: Burlington, VT
Creating a special report rule for the toilet seems to work up to a point:

Code:
"Potty Mouth"

The bathroom is a room.

The toilet is a closed openable container in the bathroom. "[toilet status].". The description is "[toilet status].". It is fixed in place. Understand "seat/lid/bowl" as the toilet. The toilet can be viewed or unviewed.

To say toilet status:
   say "The toilet lid is [if the toilet is open]up[otherwise]down[end if]"

A toothbrush is in the toilet. "The end of a toothbrush is sticking out of the toilet drain. Thankfully, there's no water in the toilet."

A rubber ducky is in the toilet. "There's a rubber ducky in the toilet, too."

Report an actor opening the toilet (this is the first description of the toilet rule):
   if the toilet is unviewed:
      repeat with item running through every thing in the toilet:
         say "[initial appearance of item] ";
      now the toilet is viewed;
      rule succeeds;
   otherwise:
      continue the action.


And if I'm not mistaken, it'd be pretty easy to generalize this to every container/supporter, or to every container/supporter that has a certain flag set (though if you did that you might have to manually list this rule before the reveal any newly visible interior rule, which I didn't have to do here).

However, this rule is bugged; if the toilet contains an item that isn't given an initial appearance, then it'll produce a run-time error. You need a way to check whether the item has the initial appearance property, and I don't know how to do that. Hopefully someone does.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Aug 19, 2010 11:31 am 
Offline

Joined: Thu Oct 22, 2009 4:31 pm
Posts: 1301
matt w wrote:
However, this rule is bugged; if the toilet contains an item that isn't given an initial appearance, then it'll produce a run-time error. You need a way to check whether the item has the initial appearance property, and I don't know how to do that. Hopefully someone does.


All things have the initial appearance property, so in nearly all situations you'd only need to check whether that property has anything in it:

Code:
unless the initial appearance of the item is "":


If you wanted to have non-things (say, a direction) in the toilet, you'd need to first check whether it provided the property at all:

Code:
if the item provides the property initial appearance:


--Erik


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Aug 19, 2010 11:53 am 
Offline

Joined: Mon Jun 09, 2008 8:58 pm
Posts: 765
Location: Seattle
Looks like the initial appearance property is used only in the "use initial appearance in room descriptions rule". Which only runs during LOOK.

The Opening actions has the "reveal any newly visible interior" rule which sounds promising. It does this.
Code:
Report an actor opening (this is the reveal any newly visible interior rule):
   if the actor is the player and the noun is an opaque container and the first thing held by the noun is not nothing and the noun does not enclose the actor,
        stop the action with library message opening action number 4 for the noun.


And that message is
Code:
4: print "You open ", (the) x1, ", revealing ";
if (WriteListFrom(child(x1), ENGLISH_BIT+TERSE_BIT+CONCEAL_BIT) == 0) "nothing.";
".";

...which just names the things in there ("toothbrush"), not print any description.

If you wanted initial appearance to fire on response to Examine instead, then, the examine containers rule is
Code:
Carry out examining (this is the examine containers rule):
if the noun is a container:
if the noun is open or the noun is transparent:
if something which is not scenery is in the noun:
issue library message searching action number 7 for the noun;
now examine text printed is true;
otherwise if examine text printed is false:
issue library message searching action number 6 for the noun;
now examine text printed is true;


Which message #7 is
Code:
7: print "In ", (the) x1, " ";
WriteListFrom(child(x1), ENGLISH_BIT+TERSE_BIT+CONCEAL_BIT+ISARE_BIT);
".";


which again only prints names.

I don't know on which command you're wanting initial appearance to appear, but there's a starting point.

_________________
Blog at Gamasutra :: Programmer's Guide to Inform 7 :: Seattle I-F


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Aug 19, 2010 3:30 pm 
Offline

Joined: Fri Jul 16, 2010 2:09 pm
Posts: 2163
Ideally, I'd like the initial appearance to fire both when opening a container and when printing the room description when the item is visibly supported or contained in the location.

Is there an accessible property that can be used to mimic the initial appearance behavior (such as "touched" or "moved")?


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Aug 19, 2010 6:36 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5289
Location: Burlington, VT
ektemple wrote:
matt w wrote:
However, this rule is bugged; if the toilet contains an item that isn't given an initial appearance, then it'll produce a run-time error. You need a way to check whether the item has the initial appearance property, and I don't know how to do that. Hopefully someone does.


All things have the initial appearance property, so in nearly all situations you'd only need to check whether that property has anything in it:

Code:
unless the initial appearance of the item is "":


If you wanted to have non-things (say, a direction) in the toilet, you'd need to first check whether it provided the property at all:

Code:
if the item provides the property initial appearance:


--Erik


Hm. Is this new in 6E? When I ran my code in 5Z, adding "A cardboard tube is in the toilet," I got (after "open lid")

Quote:
*** Run-time problem P11: Although the cardboard tube is allowed to have the property "initial appearance", no value was ever given, so it can't now be used.

UPDATE: But "item provides the property" was exactly what I was looking for, thank you. I changed it to:

Code:
Report an actor opening the toilet (this is the first description of the toilet rule):
   if the toilet is unviewed:
      repeat with item running through every thing in the toilet:
         if item provides the property initial appearance:
            say "[initial appearance of item] ";
         otherwise:
            say "[An item] is in the toilet.";
      now the toilet is viewed;
      rule succeeds;
   otherwise:
      continue the action.


and it works even when an undescribed item is in the toilet. Well, the output is ugly, but that's more of a writing problem than a programming one.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Aug 19, 2010 7:41 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5289
Location: Burlington, VT
I think I have the supporter problem solvedish. You only automatically get the contents of scenery supporters anyway, thanks to the "describe what's on scenery supporters in room descriptions rule," which the documentation describes as controversial and which might not even be in 6E -- I can't remember. Anyway, the way the rule was written, I seemingly had to drop the code into it, and use the resulting rule instead of the preexisting rule. The result is not pretty; someone else may be able to do better.

Big wodge of code below the spoiler tag; it's in 5Z, again.

Spoiler: show
Code:
"Potty Mouth"

The bathroom is a room.

The toilet is a closed openable container in the bathroom. "[toilet status].". The description is "[toilet status].". It is fixed in place. Understand "seat/lid/bowl" as the toilet.

A container can be viewed or unviewed. A container is usually unviewed. A supporter can be viewed or unviewed. A supporter is usually unviewed.

To say toilet status:
   say "The toilet lid is [if the toilet is open]up[otherwise]down[end if]"

A toothbrush is in the toilet. "The end of a toothbrush is sticking out of the toilet drain. Thankfully, there's no water in the toilet."

A rubber ducky is in the toilet. "There's a rubber ducky in the toilet, too."

A cardboard tube is in the toilet.

Report an actor opening a container:
   if the toilet is unviewed:
      repeat with item running through every thing in the noun:
         if item provides the property initial appearance:
            say "[initial appearance of item] ";
         otherwise:
            say "[An item] is in [the noun].";
      now the noun is viewed;
      rule succeeds;
   otherwise:
      continue the action.
      
The kitchen is west of the bathroom. A counter is in the kitchen. The counter is scenery. Some shards are on the counter. "Someone must have been clumsy or angry, because the shards of a broken bowl are scattered over the counter." A glass is on the counter.

For printing a locale paragraph about a thing (called the item)
   (this is the complex describe what's on scenery supporters in room descriptions rule):
   if the item is not undescribed and the item is scenery and the item does not enclose the player:
      set pronouns from the item;
      if a locale-supportable thing is on the item:
         [here's the start of the new stuff]
         if the item is unviewed:
            repeat with possibility running through things on the item:
               if possibility is not mentioned:
                  if the possibility provides the property initial appearance:
                     say "[initial appearance of possibility]";
                     say paragraph break;
                  otherwise:
                     say "[A possibility] is on [the item].";
            now the item is viewed;   
            [what's below this is the standard rule again]
         otherwise:
            repeat with possibility running through things on the item:
               now the possibility is marked for listing;
               if the possibility is mentioned:
                  now the possibility is not marked for listing;
            increase the locale paragraph count by 1;
            say "On [the item] ";
            list the contents of the item, as a sentence, including contents,
            giving brief inventory information, tersely, not listing
            concealed items, prefacing with is/are, listing marked items only;
            say ".[paragraph break]";
   continue the activity.   
   
The describe what's on scenery supporters in room descriptions rule is not listed in any rulebook.

test me with "open lid/close lid/open lid/w/ look".


BTW, when you open a viewed container, the "report an actor opening" rule falls through to the "repeat any newly visible interior" rule that Ron mentioned. It was because that rule was firing that I did it as a "report an actor opening" rule.

I haven't been able to figure out how to do this when walking into a room with a transparent or open container.


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 6 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