intfiction.org

The Interactive Fiction Community Forum
It is currently Mon May 20, 2013 8:39 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Apr 25, 2012 4:28 pm 
Offline

Joined: Fri Feb 24, 2012 10:56 pm
Posts: 34
Hey ya'll. So I have a scene where I want the player to pawn an item (rare coin). I want the player to try giving a number of items to Pawn Broker, trying to figure out which item he's interested in. I've got the code working great for giving the rare coin to the Pawn Broker and getting the cash in return. The problem is how I can block giving for other items. I've been trying things like:

Code:
Instead of giving [noun] to Pawn Broker when [noun] is not rare coin: say "'No thanks.'".


That doesn't seem to work. Any ideas?

Thanks in advance.


Top
 Profile Send private message  
 
PostPosted: Wed Apr 25, 2012 4:53 pm 
Offline

Joined: Fri May 06, 2011 7:15 pm
Posts: 489
Location: The Big Apple
Doesn't the following work?

Code:
Instead of giving something other than the coin to the pawn broker, say "No thanks."



Robert Rothman


Top
 Profile Send private message  
 
PostPosted: Wed Apr 25, 2012 4:57 pm 
Offline

Joined: Thu May 20, 2010 9:33 pm
Posts: 479
For the record, when you use square brackets outside of quoted text, it means that the text they contain is a comment. Inform just skips right over them, so it sees
Code:
Instead of giving [noun] to Pawn Broker when [noun] is not rare coin: say "'No thanks.'"
as
Code:
Instead of giving to Pawn Broker when is not rare coin: say "'No thanks.'"


Top
 Profile Send private message  
 
PostPosted: Wed Apr 25, 2012 5:18 pm 
Offline

Joined: Fri Feb 24, 2012 10:56 pm
Posts: 34
I'm getting this error message with the new, suggested code:

Code:
Problem. You wrote 'Instead of giving something other than coin to Pawn Broker' , which seems to introduce a rule taking effect only if the action is 'giving something other than coin to Pawn Broker'. But that did not make sense as a description of an action. I am unable to place this rule into any rulebook.



Hmmmmmm.


Top
 Profile Send private message  
 
PostPosted: Wed Apr 25, 2012 5:30 pm 
Offline

Joined: Thu May 20, 2010 9:33 pm
Posts: 479
Yeah, it's a bit confusing that Inform uses brackets to mean two fairly different things. If you're using syntax highlighting in the IDE and not using a screen reader -- in other words, if different parts of your code are different colors based on what purpose they serve -- you'll see that comments are colored differently from text Inform reads. For me, comments are green and slightly smaller, and I think that's the OSX default.


Top
 Profile Send private message  
 
PostPosted: Wed Apr 25, 2012 5:40 pm 
Offline

Joined: Fri Feb 24, 2012 10:56 pm
Posts: 34
That is confusing. You wouldn't have any idea how to solve the block giving issue would you? The code he suggested didn't work.


Top
 Profile Send private message  
 
PostPosted: Wed Apr 25, 2012 6:18 pm 
Offline

Joined: Thu May 20, 2010 9:33 pm
Posts: 479
Hm, is it that it needs to say "rare coin" instead of "coin"? If that doesn't work, you can try a syntax closer to your original attempt:
Code:
Instead of giving something (called the offering) to the Pawn Broker:
   if the offering is not the rare coin:
      say "'No Thanks.'";
   otherwise:
      [whatever code you want here].


Top
 Profile Send private message  
 
PostPosted: Wed Apr 25, 2012 6:20 pm 
Offline
User avatar

Joined: Sat May 08, 2010 9:25 pm
Posts: 959
Location: The Seattle Massive
Most of the standard front-ends for I7 include some limited syntax colouring, which makes obvious the distinction between square-brackets in text and square-brackets to comment out code. But of course this doesn't help everyone.

In I7 a more-specific rule always takes precedence over a less-specific one, so you can just do this:
Code:
Instead of giving something to the Pawn Broker, say "'No.'"
Instead of giving the rare coin to the Pawn Broker:
 (whatever you want that to do)"


Top
 Profile Send private message  
 
PostPosted: Wed Apr 25, 2012 6:40 pm 
Offline

Joined: Wed Feb 29, 2012 2:00 pm
Posts: 672
You could try this.

Code:
"Test"

The block giving rule is not listed in the check giving it to rulebook.

Instead of giving something to the pawn broker when the noun is not the rare coin: say "'No thanks.'".

The Testing Room is A Room. The pawn broker is a person in the testing room. The player holds a rare coin and and a straw dog.

Test me with "give dog to broker / give coin to broker".


This only allows the player to give the coin to the pawn broker. If you want to add other items, you can say "when the noun is not the rare coin and the noun is not the treasure and ..." and so on for the other items.

Hope this helps.

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


Top
 Profile Send private message  
 
PostPosted: Wed Apr 25, 2012 8:25 pm 
Offline

Joined: Fri Feb 24, 2012 10:56 pm
Posts: 34
Thanks climbingstars - that worked!


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