intfiction.org

The Interactive Fiction Community Forum
It is currently Sat Jan 19, 2019 4:48 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Multiple Item Actions
PostPosted: Mon Jan 07, 2019 7:27 pm 
Offline
User avatar

Joined: Mon Jun 11, 2018 3:15 pm
Posts: 20
Been playing around with multiple item actions. It bugs me when taking a bunch of the same thing and I get:
Quote:
shiny: Taken.
shiny: Taken.
shiny: Taken.
shiny: Taken.

I tried to group the taking by borrowing shamelessly from the "Western Art History 305" example as follows:
Code:
The plural of shiny is shinies. A shiny is a kind of a thing.

A multiple action processing rule when the action name part of the current action is the taking action (this is the getting shinies rule):
   let L be the multiple object list;
   let F be L;
   let the shiny count be 0;
   repeat with item running through L:
      if the item is a shiny:
         silently try taking the item;
         if the player encloses the item:
            increment the shiny count;
         remove the item from F;
   if the shiny count is greater than zero:
      say "[Shiny count in words] shin[if shiny count is one]y[otherwise]ies[end if]: Taken.";
   if the number of entries in F is less than the number of entries in L:
      alter the multiple object list to F.
      
Cave of Wonders is a Room.
Twelve shinies are in the Cave.
A transparent container called a crystal pumpkin is in the cave. The pumpkin contains three shinies. The pumpkin is closed. The pumpkin is fixed in place.

It works fine until there are shinies that can't be taken for some reason. Here's what I get with the above code:
Quote:
>get all
The crystal pumpkin isn't open.

The crystal pumpkin isn't open.

The crystal pumpkin isn't open.

twelve shinies: Taken.

There must be a better way. I mean, it would be really cool if it said "The crystal pumpkin isn't open" just once. Or maybe is there a way to check to see if an item is retrievable without actually trying to take it?

What's the preferred way to do this?

_________________
~Esad


Top
 Profile Send private message  
Reply with quote  
PostPosted: Mon Jan 07, 2019 9:36 pm 
Offline

Joined: Mon Dec 15, 2014 9:15 am
Posts: 402
Here's one rather crude way. (I haven't altered your rule, except to add a couple of lines. [*])

Code:
A container can be shiny-barred.
A rule for reaching inside a shiny-barred container when the noun is a shiny: deny access.
Every turn: now every container is not shiny-barred.

A multiple action processing rule when the action name part of the current action is the taking action (this is the getting shinies rule):
   let L be the multiple object list;
   let F be L;
   let the shiny count be 0;
   repeat with item running through L:
      if the item is a shiny:
         silently try taking the item;
         if the player encloses the item:
            increment the shiny count;
         otherwise if the holder of the item is a container:                                             [*]
            now the holder of the item is shiny-barred;                                                  [*]
         remove the item from F;
   if the shiny count is greater than zero:
      say "[Shiny count in words] shin[if shiny count is one]y[otherwise]ies[end if]: Taken.";
   if the number of entries in F is less than the number of entries in L:
      alter the multiple object list to F.


By the way, you don't need to tell Inform the plural of "shiny".


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Jan 09, 2019 12:24 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5526
Location: Burlington, VT
I don't think this helps much in this case, but I wrote an extension Actions on Groups that automates some aspects of doing actions on multiple things. It's more designed for things like The Left Hand of Autumn, though, which is an example where you need to special-case some particular combinations (like "take bell, book, and candle"). Also it was written for the version of I7 before the multiple action processing rulebook was included, so it bypasses it.

Checking if something is takeable without taking it is quite an undertaking. There's an extension, I think Hypothetical Questions by Jesse McGrew, which allows for this sort of thing by doing something like doing the action and then hacking the undo buffer to restore the action while retaining the information about whether it succeeded.

If you're looking for super general solutions, another thing you can try is running Text Capture by Eric Eve to gather up all the failure messages without printing them, reorganize them somehow into some more sensible output, and print them out at the end. Again, complicated stuff.

So the best thing to do is probably what jrb did--if the specific reason you're getting multiple messages has to do with a shiny being stuck in a container, set a flag that prevents you from trying to take any more shinies from that container. Or whatever is specifically causing problems, set a flag so that problem only happens once.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Jan 09, 2019 2:45 pm 
Offline
User avatar

Joined: Mon Jun 11, 2018 3:15 pm
Posts: 20
Thanks to both of you.

_________________
~Esad


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

All times are UTC - 6 hours [ DST ]


Who is online

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