intfiction.org

The Interactive Fiction Community Forum
It is currently Fri May 24, 2013 8:15 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Fri Mar 30, 2012 12:47 am 
Offline

Joined: Fri Feb 24, 2012 10:56 pm
Posts: 34
In my example below, I have a magazine, and when the player tries to take it, a coupon falls out. The idea is that once the coupon appears it appears in his inventory. My code doesn't quite work (probably the last line). Any suggestions?

Code:
A round table is a supporter in Apartment.  On the table is a magazine.
Instead of taking magazine: say "As you grab the magazine, something slides out from between the pages...a coupon for 1 Free Pit Beef Sandwich at Chaps!  You swipe it.".
Now the player carries a Chaps Free Pit Beef Sandwich Coupon.


Thanks in advance :D


Top
 Profile Send private message  
 
PostPosted: Fri Mar 30, 2012 3:55 am 
Offline
User avatar

Joined: Thu Nov 04, 2010 6:30 am
Posts: 986
Location: Gothenburg, Sweden
The last line (the now-phrase) is not inside any rule, and phrases always have to be inside a rule to do their job.
Change the full stop after the output text to a semi-colon, and declare the coupon, and it'll work as expected.
Code:
A Chaps Free Pit Beef Sandwich Coupon is thing.
A round table is a supporter in Apartment.  On the table is a magazine.
Instead of taking magazine:
   say "As you grab the magazine, something slides out from between the pages...a coupon for 1 Free Pit Beef Sandwich at Chaps!  You swipe it.";
   now the player carries a Chaps Free Pit Beef Sandwich Coupon.

(As it stands Inform takes the last line for an assertion: it creates a person called "Now the player" (!), who carries a thing called "Chaps Free Pit Beef Sandwich Coupon"; they're both off stage.)

_________________
Man ska inte tro allt man tänker.


Top
 Profile Send private message  
 
PostPosted: Fri Mar 30, 2012 6:49 am 
Offline

Joined: Sun Dec 05, 2010 11:07 am
Posts: 321
Location: ኢትዮጵያ
If you use an Instead phrase rather than After, the player won't ever be able to take the magazine. And since you probably don't want to make that a magical coupon-relocating machine, you should change the line to
Code:
After taking the magazine for the first time:
so that it never fires more than once.


Top
 Profile Send private message  
 
PostPosted: Fri Mar 30, 2012 10:30 am 
Offline

Joined: Wed Feb 29, 2012 2:00 pm
Posts: 674
You'll need to be careful with rules such as "After taking the magazine for the first time", because if taking the magazine for the first time ends in failure, this rule will never fire.

_________________
"Will you stop breaking the fourth wall? It's costing me an absolute fortune to replace it!"


Top
 Profile Send private message  
 
PostPosted: Fri Mar 30, 2012 12:56 pm 
Offline
User avatar

Joined: Thu Nov 04, 2010 6:30 am
Posts: 986
Location: Gothenburg, Sweden
Right! So:
Code:
After taking magazine when the Chaps Free Pit Beef Sandwich Coupon is off-stage:
   say "As you grab the magazine, something slides out from between the pages...a coupon for 1 Free Pit Beef Sandwich at Chaps!  You swipe it.";
   now the player carries the Chaps Free Pit Beef Sandwich Coupon.

_________________
Man ska inte tro allt man tänker.


Top
 Profile Send private message  
 
PostPosted: Fri Mar 30, 2012 12:59 pm 
Offline

Joined: Sun Dec 05, 2010 11:07 am
Posts: 321
Location: ኢትዮጵያ
Wow, I didn't realize that. That's a little counterintuitive. Thanks!


Top
 Profile Send private message  
 
PostPosted: Fri Mar 30, 2012 11:08 pm 
Offline

Joined: Fri Feb 24, 2012 10:56 pm
Posts: 34
Thanks for the help. It's working for me now. :D


Top
 Profile Send private message  
 
PostPosted: Sat Mar 31, 2012 2:34 am 
Offline

Joined: Mon Oct 11, 2010 1:27 pm
Posts: 455
Felix wrote:
Right! So:
Code:
After taking magazine when the Chaps Free Pit Beef Sandwich Coupon is off-stage:
   say "As you grab the magazine, something slides out from between the pages...a coupon for 1 Free Pit Beef Sandwich at Chaps!  You swipe it.";
   now the player carries the Chaps Free Pit Beef Sandwich Coupon.


I like this, but it introduces another problem in the future. If we want to give the coupon to a cashier, who puts it in a cash register (potentially off-stage, so that we don't have to implement a cash register) we could open the magazine again and re-take the sandwich.

I don't know how complex we want to make this example or if my worries are justified, but here's what I have. It does seem a bit tangled, but hope it adds something.

Code:
the Chaps Free Pit Beef Sandwich Coupon is a thing. The coupon can be unobserved. The coupon is unobserved.

after taking the magazine:
   if coupon is unobserved and player has magazine:
      say "Oops! A coupon fell out!";
      now the coupon is in room 1;
      now the coupon is not unobserved; [yeah, double negative]
      the rule succeeds;
   continue the action;

test takeit with "take magazine/drop magazine/take magazine"


Now we can throw the coupon off-stage easily.


Top
 Profile Send private message  
 
PostPosted: Sat Mar 31, 2012 2:44 am 
Offline

Joined: Tue Dec 25, 2007 10:06 am
Posts: 888
You can just use the built-in property "handled" which will be set when the player first has the thing in their inventory.

Code:
After taking magazine when the Chaps Free Pit Beef Sandwich Coupon is not handled:
    say "As you grab the magazine, something slides out from between the pages... a coupon for 1 Free Pit Beef Sandwich at Chaps! You swipe it.";
    now the player carries the Chaps Free Pit Beef Sandwich Coupon.

_________________
Vorple UI libraryBeta testing siteBlog


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

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: DavidC, Google [Bot] 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