intfiction.org

The Interactive Fiction Community Forum
It is currently Thu May 23, 2013 11:46 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Mon May 07, 2012 8:52 am 
Offline

Joined: Mon May 07, 2012 8:43 am
Posts: 7
Hi I'm a student in a game design course in tafe and i really need help with my hat issue. I have tried to add hats into my game but every time i test it i can stick a hat on top of another hat with a hat all ready on my head. I really do not want this.

Example of code:
Instead of taking suspicious hat:
Say "You fling it on your head";
Now the player is wearing suspicious hat.

How I tried to fix the hat problem:
Instead of wearing a hat when the player is wearing a hat:
Say "you have to take off the other hat first."


I really don't know how to fix it but i have tried. Can anyone help?


Top
 Profile Send private message  
 
PostPosted: Mon May 07, 2012 8:57 am 
Offline

Joined: Tue Jan 22, 2008 5:55 am
Posts: 841
Location: The Netherlands
What's going wrong is that the first rule fires when the action is taking the suspicious hat, while the second rule fires when the action is wearing the suspicious hat. (Note that the phrase "now the player is wearing the suspicious hat" does not start the wearing action: it just makes it so that it is the case that the player wears the hat.)

What you want is this:
* Taking the suspicious hat leads to wearing it.
* Wearing a hat is only possible when the player is not wearing another hat.

So we write:

Instead of taking suspicious hat:
try wearing suspicious hat.

Instead of wearing a hat when the player is wearing a hat:
say "you have to take off the other hat first.".

(Untested, but I think it should work.)


Top
 Profile Send private message  
 
PostPosted: Mon May 07, 2012 9:35 am 
Offline
User avatar

Joined: Mon Oct 03, 2011 12:03 pm
Posts: 636
Location: Stoke Barehills
I was hoping that you needed millinery sartorial advice, which as an owner of a great many hats I am well able to offer.


Top
 Profile Send private message  
 
PostPosted: Mon May 07, 2012 10:08 am 
Offline

Joined: Wed Feb 29, 2012 2:00 pm
Posts: 674
VictorGijsbers wrote:
Instead of taking suspicious hat:
try wearing suspicious hat.


This is dangerous code because the wearing action includes an implicit take so you end up in an infinite loop.

Narspicious wrote:
Instead of taking suspicious hat:
Say "You fling it on your head";
Now the player is wearing suspicious hat.


I wouldn't suggest converting taking a hat to wearing a hat because there is already an action for wearing, which responds to the command "wear hat". However, you may want to hint that you can wear a hat when just taking it. Try this.

Code:
"Test"

Report taking a hat:
say "You take [the noun]. You can also 'wear [the noun]' as well.";
rule succeeds.

After wearing a hat: say "You fling [the noun] on your head.".

Check wearing a hat when the player is wearing a hat (called the chosen hat): say "You have to take off [the chosen hat] first." instead.

The Testing Room is A Room. A hat is a kind of thing. A hat is always wearable. The red hat is a hat in the testing room. The blue hat is a hat in the testing room.

Test me with "take red / take blue / drop red / drop blue / wear red / wear blue".


Hope this helps.

PS. I believe this post should be under "Inform 6 and 7 Development" rather than "Getting Started and General Game Design". If this is so, then can one of the wizards of this forum bestow the relevant magic on this post? Thanks.

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


Top
 Profile Send private message  
 
PostPosted: Mon May 07, 2012 10:13 am 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 2128
Location: Burlington, VT
Victor's diagnosis is right, but part of his solution unfortunately won't work. When you try to wear something you're not holding, Inform by default has you automatically try to take it first. But then the "instead of taking the hat" rule redirects us to wearing the hat, and Inform has you automatically try to take it first, and... we get an infinite loop.

We can fix this by changing "Instead of taking the suspicious hat: try wearing the suspicious hat" to

Code:
After taking the suspicious hat: try wearing the suspicious hat.


That lets you pick up the hat normally, and then has you try to put it on after you've picked it up.

[On preview: climbingstars has already said the same thing, and I agree with him that you might just want to leave "take hat" so the player can pick up a hat without wearing it. But if you want to automatically wear a hat when you pick it up, this should work.]


Top
 Profile Send private message  
 
PostPosted: Mon May 07, 2012 3:05 pm 
Offline

Joined: Fri May 06, 2011 7:15 pm
Posts: 489
Location: The Big Apple
Most hatters recommend that you always pick up a hat by the brim (preferably with both hands). Handling the crown may eventually wear through the felt. And remember: Next week (I believe its May 15) is National Straw Hat Day.



Robert Rothman


Top
 Profile Send private message  
 
PostPosted: Mon May 07, 2012 4:20 pm 
Offline
User avatar

Joined: Mon Oct 03, 2011 12:03 pm
Posts: 636
Location: Stoke Barehills
Robert Rothman wrote:
Most hatters recommend that you always pick up a hat by the brim (preferably with both hands). Handling the crown may eventually wear through the felt.

This lesson I have learned the hard way :(


Top
 Profile Send private message  
 
PostPosted: Tue May 08, 2012 6:36 am 
Offline

Joined: Wed Feb 29, 2012 2:00 pm
Posts: 674
Robert Rothman wrote:
Next week (I believe its May 15) is National Straw Hat Day.


Never heard of that one before.

JoeyJones wrote:
This lesson I have learned the hard way :(


Well, at least you can't go wrong with a straw dog! :)

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


Top
 Profile Send private message  
 
PostPosted: Mon May 14, 2012 8:44 pm 
Offline

Joined: Mon May 07, 2012 8:43 am
Posts: 7
Thanks for all the help. Sorry i only got to this now. I will test them all and once again thanks.


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: 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