intfiction.org

The Interactive Fiction Community Forum
It is currently Sat May 18, 2013 6:50 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: Thu Jul 19, 2012 7:12 pm 
Offline

Joined: Thu Jul 19, 2012 7:05 pm
Posts: 8
I know that I'm being awfully ambitious with my first IF, but I wanted to author something for my students that will fit different demographics. In the intro, a shadowy figure presents the player with two objects: a dagger or a rose. The story will then change according to which object is picked (action or romance). My initial trouble (of a likely many) is undoing the native language of Inform7 that includes the "Take all" command. I'd rather the "Take all" command results in the man telling the player to choose only one object.

Any help appreciated. I look forward to being an active member on these boards.


Top
 Profile Send private message  
 
PostPosted: Thu Jul 19, 2012 7:39 pm 
Offline
User avatar

Joined: Sat May 08, 2010 9:25 pm
Posts: 956
Location: The Seattle Massive
Dealing with ALL and other multiple-object things is, in a word, fiddly; the following code draws heavily on the example The Left Hand of Autumn.
Code:
Group-description-complete is a truth state that varies.

Before reading a command:
    now group-description-complete is false.
   
Check taking:
if group-description-complete is true, stop the action;

Check taking:
if the number of entries in the multiple object list > 1 begin;
   say "I'm sorry, you must choose a single object here.[paragraph break]";   
   now group-description-complete is true;
   stop the action;
end if;

The silently announce items from multiple object lists rule is listed instead of the announce items from multiple object lists rule in the action-processing rules.

This is the silently announce items from multiple object lists rule:
   unless taking:
      if the current item from the multiple object list is not nothing, say "[current item from the multiple object list]: [run paragraph on]".

Definition: a thing is matched if it is listed in the multiple object list.


Top
 Profile Send private message  
 
PostPosted: Fri Jul 20, 2012 3:53 am 
Offline

Joined: Sun Dec 05, 2010 11:07 am
Posts: 321
Location: ኢትዮጵያ
Probably the simplest way is to redefine the verbs in question to apply only to one thing, rather than "things":

Code:
Understand the commands "get" and "pick" and "take" as something new. 

Understand "take [something]" as taking.
Understand "get [something]" as taking.
Understand "pick up [something]" and "pick [something] up" as taking.


Then it's simply a matter of enabling the other actions associated with these verbs:

Code:
Understand  "take inventory" as taking inventory.
Understand "take off [something]" and "take [something] off" as taking off.
Understand "take [something] from [something]" and "take [something] off [something]" as removing it from.

Understand "get out/off/down/up" as exiting.
Understand "get in/on" and "get in/into/on/onto [something]" as entering.
Understand "get off/down [something]" as getting off.
Understand "get [something] from [something]" as removing it from.

There is room. A dagger and a rose are here.

Test me with "take all".
All of this understood syntax is taken straight from the Actions subtab of the Index tab.


Top
 Profile Send private message  
 
PostPosted: Fri Jul 20, 2012 9:36 am 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 2127
Location: Burlington, VT
It seems to me that disabling "take all" everywhere in the game may be a bit overpowered for what you want to do, which is to prevent the player from taking both the dagger and the rose. I think you can handle this a bit more finely using rules for deciding whether all include (section 17.34 in the manual) and adjusting the parser error message with rules for printing a parser error (section 17.33). This is what I came up with:

Code:
Choice made is a truth state that varies. Choice made is false.

Rule for deciding whether all includes something when the player can touch the dagger and the player can touch the rose and choice made is false: it does not. [This disables "take all" in a room with the dagger and the rose when we haven't chosen yet.]
Rule for printing a parser error when the latest parser error is the nothing to do error and the dagger is in the location and the rose is in the location: say "You must choose one of the dagger and the rose."

Carry out taking the dagger: now choice made is true.
Carry out taking the rose: now choice made is true.

Starter is a room. A dagger and a rose are here.
North Room is north of starter. A hoojab, a whatsit, and a whatchamacallit are here.

Test me with "take all/n/take all/take all/drop all/s/take rose/take all".
Test oops with "n/take all/s/drop all".


The "nothing to do error" is the parser error that usually prints the message "There are none at all available!" As the first "test me" script shows, that will still behave normally when the player isn't trying to take both the dagger and the rose.

As the "test oops" script shows, this will mess up when the player tries "drop all" when she should be choosing between the rose and the dagger. You may not need to worry about this in your game, but in any case it can be fixed with a bit of (very useful) I6 trickery. The "To decide what action-name is the action-to-be" line lets us figure out what action the player was trying to do, even when the command didn't compile:

Spoiler: show
Code:
Choice made is a truth state that varies. Choice made is false.

To decide what action-name is the action-to-be: (- action_to_be -).

Rule for deciding whether all includes something when the player can touch the dagger and the player can touch the rose and choice made is false and the action-to-be is the taking action: it does not. [This disables "take all" in a room with the dagger and the rose when we haven't chosen yet.]
Rule for printing a parser error when the latest parser error is the nothing to do error and the dagger is in the location and the rose is in the location and the action-to-be is the taking action: say "You must choose one of the dagger and the rose."

Carry out taking the dagger: now choice made is true.
Carry out taking the rose: now choice made is true.

Starter is a room. A dagger and a rose are here.
North Room is north of starter. A hoojab, a whatsit, and a whatchamacallit are here.

Test me with "take all/n/take all/take all/drop all/s/take rose/take all".
Test oops with "n/take all/s/drop all".


(There may be a better way to fix that.)

Also, it sounds like the choice is dramatic enough that you might not want to let the player do anything other than choose the dagger or the rose when it's presented. No trying to go north, no taking your inventory, no nothing. So you might have something like this:

Quote:
The man says, "You must choose between the dagger and the rose."

Will you take the dagger or the rose? i

You must make a choice now.

Will you take the dagger or the rose? rose

You take the rose from the man, and you find yourself transported to an arboretum....


Section 5.2 of the Inform Recipe Book has several examples of ways to do this.

Incidentally, if the shadowy figure is actually carrying the dagger and the rose, the normal taking action won't work anyway unless you rewrite the "can't take other people's possessions" rule.


Top
 Profile Send private message  
 
PostPosted: Fri Jul 20, 2012 11:55 am 
Offline

Joined: Tue Nov 08, 2011 8:11 am
Posts: 79
Instead of messing with the actions could you modify whatever mechanic triggers the scene change to not work if both objects are held?

"You've chosen both, which is not my intention. Please give one back to me now."


Top
 Profile Send private message  
 
PostPosted: Fri Jul 20, 2012 2:31 pm 
Offline

Joined: Thu Jul 19, 2012 7:05 pm
Posts: 8
Some good workarounds here. Thanks for all your code and help. Several work very well. (Perhaps I should have this story be open-sourced and have ya'll write it for me :D .)

Clearly, I need to delve deeper into the Inform documentation to understand how you arrive at these.

Cheers


Top
 Profile Send private message  
 
PostPosted: Fri Jul 20, 2012 6:52 pm 
Offline

Joined: Tue Jul 17, 2012 5:06 pm
Posts: 17
Following is what I came up with. It builds a little functionality onto maga's example in that it only tries to stop the player from taking more than one plot-critical thing -- taking multiple non-critical things is OK, and taking more than one key item while taking multiple non-key items is also handled. Probably more than you are looking for, but it does use many interesting features you'll probably want to get acquainted with and that I enjoyed the chance to learn more about (i.e. new properties, scenes, after rules, "was" conditions [see 9.13] for detecting intra-turn changes, every turn rules, action variables, lists).

Overall, though, I think maybe matt w's suggestion of forcing the choice and only the choice is the right call. It is probably simpler to implement, and it really does highlight the significance of the decision to the player.


Code:
Place is a room.

A thing can be plot-critical.

A cat is here. A hat is here. A bat is here. [to simulate likely presence of non-critical plot items in your scenario]

The stranger is a man in Place. "A stranger is here, offering you a choice between [a list of visible plot-critical things]." The stranger carries a rose and a dagger and a golden signet. The rose and the dagger are plot-critical.

After taking the dagger when the dagger was carried by the stranger, say "Troubled by thoughts of the conflict ahead, you reach for the dagger. Its heft is comforting."

After taking the rose when the dagger was carried by the stranger, say "Thinking wistfully of times past, you reach for the rose. Its fragrance wafts gently skyward, and you inhale deeply."

Warning given is a truth state that varies. [Has to be outside action variables, it seems, to be accessible to the reading a command activity.]

Before reading a command:
    now warning given is false.

The taking action has a list of things called grab bag.
The taking action has a list of things called exclusory items.

Setting action variables for taking:
   repeat with coveted item running through the multiple object list:
      if coveted item is not plot-critical, add coveted item to grab bag;
      otherwise add coveted item to exclusory items.

The Choice is a scene. The Choice begins when play begins.

Check taking a plot-critical thing while warning given is false and the number of entries in exclusory items is greater than 1 during the Choice (this is the intercept attempts to take multiple plot-critical things at once rule):
   now warning given is true;
   say "The stranger, seeing that you are about to take [the exclusory items with definite articles] catches your eagerly outstretched hand in an iron grip. 'You must choose, and choose carefully,' he warns. 'The path you set foot on now is the path you must walk in the trials ahead.'" instead.

Check taking a plot-critical thing while warning given is true and the number of entries in exclusory items is greater than 1 during the Choice (this is the suppress attempts to take multiple plot-critical things after the first one rule):
   stop the action.

A procedural rule when taking a plot-critical thing carried by the stranger during The Choice (this is the it's OK to take what The Choice offers rule):
   ignore the can't take people's possessions rule.

Every turn while the number of entries in the list of plot-critical things enclosed by the player is greater than 1 during The Choice (this is the emergency backup logic for plot-critical choice rule):
   say "The stranger gently retrieves [the list of plot-critical things enclosed by the player] from your hands. 'You can choose but one path,' the stranger explains.";
   now the stranger carries every plot-critical thing.

The Choice ends when the player carries exactly one plot-critical thing.

When The Choice ends, say "The stranger nods. 'Your path is chosen,' he says."

This is the silently announce items from multiple object lists rule:
   unless taking a plot-critical thing while The Choice is happening:
      if the current item from the multiple object list is not nothing, say "[current item from the multiple object list]: [run paragraph on]".

The silently announce items from multiple object lists rule is listed instead of the announce items from multiple object lists rule in the action-processing rules.

test rose with "scenes / take all / take rose / take dagger".
test dagger with "scenes / take all / take dagger / take rose".


Top
 Profile Send private message  
 
PostPosted: Mon Jul 23, 2012 1:10 pm 
Offline

Joined: Tue Jan 11, 2011 8:19 pm
Posts: 20
Does this code ever fail to produce the warning? "Before reading a command" happens every turn, so it seems to me that it would constantly reset "warning given" back to false, and never give the "suppress attempts to take multiple plot-critical things after the first one rule" a chance to fire. Unless I'm misunderstanding something.


Top
 Profile Send private message  
 
PostPosted: Mon Jul 23, 2012 1:36 pm 
Offline
User avatar

Joined: Thu Nov 04, 2010 6:30 am
Posts: 984
Location: Gothenburg, Sweden
The command "take all" lets you perform several taking actions during a single turn (and the before reading a command rule only resets the warning given variable before the first of them).

_________________
Man ska inte tro allt man tänker.


Top
 Profile Send private message  
 
PostPosted: Mon Jul 23, 2012 3:31 pm 
Offline

Joined: Tue Jan 11, 2011 8:19 pm
Posts: 20
Ah, of course. Otherwise the message would be produced instead of taking the dagger, and then immediately again instead of taking the rose (which is part of the same turn, but not the same action). So the purpose is to produce the warning whenever you try to take both, but only once per turn. Thanks for clarifying that.


Top
 Profile Send private message  
 
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: Peter Pears and 2 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