intfiction.org

The Interactive Fiction Community Forum
It is currently Fri May 24, 2013 4:45 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Sun May 27, 2012 8:55 am 
Offline
User avatar

Joined: Sun May 27, 2012 8:51 am
Posts: 16
Hey guys, I found Inform 7 yesterday, and it's a lot of fun. I've been fiddling around, trying to learn as I go. I've hit a bump with an IF statement.

I want to specify multiple values for the size capacity of a container, so that a tiny box can't hold a large vase for example. Here's how I tried to do it:

Code:
A thing has a number called Largeness.
A container has a number called Sizecap.

A weapon is a kind of thing.
A gun is a kind of weapon.

A gun-belt is a kind of container. A gun-belt is wearable.

The SixGun is a gun. The largeness of the sixgun is 1.
The Gun Belt is a gun-belt. The sizecap of the gun belt is 1.

Check inserting something (called the to-be-inserted) into a container (called the receptacle):
Let Value1 be largeness of to-be-inserted;
Let Value2 be sizecap of receptacle;
[if Value1 is greater than Value2]say "[The noun] doesn't seem to fit in [the second noun].";say "[largeness of to-be-inserted] and [sizecap of receptacle] and [Value1] and [Value2]";rule fails;[otherwise]Continue the action.[end if].


I nabbed some of the code from the net, tried to make it to do what I want it to do. You'll notice I've added a bit of code at the end of the IF statement to print out the values. The values are all being assigned correctly, but I suspect I'm wording the beginning of my statement incorrectly.

Perhaps the statement thinks I'm refering to the internal object ID of Value1, rather than the value stored in it? I can't seem to figure out how to get it to work. It always throws up the failure, never continues the action.

Thanks for any help folks! :D

P.S A side question, I want to call my gun "Six Gun", but when I do that and type "put Six Gun in Gun Belt" into the game itself, the game is unable to parse that. I had to shorten it to SixGun. Know how I might get around that issue, and perhaps why it's happening? :)

_________________
"Space is big. Really big. You just won't believe how vastly, hugely, mindbogglingly big it is. I mean, you may think it's a long way down the road to the chemist's, but that's just peanuts to space" - Douglas Adams.


Top
 Profile Send private message  
 
PostPosted: Sun May 27, 2012 9:09 am 
Offline
User avatar

Joined: Sun May 27, 2012 8:51 am
Posts: 16
Wow. After going and looking at this post, I was able to get it to work. It helped that I went back to good old indentation:

Code:
Check inserting something (called the to-be-inserted) into a container (called the receptacle):
   Let Value1 be largeness of to-be-inserted;
   Let Value2 be sizecap of receptacle;
   if Value1 is greater than Value2:
      say "Nope!";
      rule fails;
   otherwise:
      Continue the action


I spent ages trying to figure it out last night, I guess I was tired :P Out of curiosity, what was I doing wrong?

So....any thoughts on that SixGun/Six Gun issue? :)

_________________
"Space is big. Really big. You just won't believe how vastly, hugely, mindbogglingly big it is. I mean, you may think it's a long way down the road to the chemist's, but that's just peanuts to space" - Douglas Adams.


Top
 Profile Send private message  
 
PostPosted: Sun May 27, 2012 11:08 am 
Offline
User avatar

Joined: Sun May 27, 2012 8:51 am
Posts: 16
Felix wrote:
Inform can't reliably tell whether "six gun" means 'the object called Six Gun' or 'six objects of the gun kind'.

Stick with 'SixGun', explictly give it the printed name "Six Gun", and tell the game to «Understand "Six Gun" or "Gun" as the SixGun.»


Interesting, thanks! I added
Code:
The printed name of the SixGun is "Six Gun". Understand "Six Gun" or "Gun" as the SixGun.
but this doesn't seem to work. When I refer to the "gun", the game thinks I'm refering to the Gun Belt. When I say "put six gun in gun belt", it still doesn't understand the sentence :? Perhaps I'm missing something (Like, you used the word explicitly, but if that's something I can specify in the code I'm not sure how)?

_________________
"Space is big. Really big. You just won't believe how vastly, hugely, mindbogglingly big it is. I mean, you may think it's a long way down the road to the chemist's, but that's just peanuts to space" - Douglas Adams.


Top
 Profile Send private message  
 
PostPosted: Sun May 27, 2012 11:14 am 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 2086
What you want in this case is for the belt to *not* respond to "gun" on its own. So:

The GunBelt is a gun-belt. Understand "belt" or "gun belt" or "gun-belt" as the GunBelt.


Top
 Profile Send private message  
 
PostPosted: Sun May 27, 2012 11:14 am 
Offline
User avatar

Joined: Thu Nov 04, 2010 6:30 am
Posts: 986
Location: Gothenburg, Sweden
I first deleted my previous post because I found that the understand statement didn't work as expected. Sorry. Anyway, the quotes in your post reproduces it in its entirety.
This works:
Code:
Understand "Six Gun" as the SixGun.
.
But for some reason this doesn't:
Code:
Understand "Six Gun" or "Gun" as the SixGun.

I guess the latter just reproduces the ambiguity between the Six Gun and six guns.

_________________
Man ska inte tro allt man tänker.


Top
 Profile Send private message  
 
PostPosted: Sun May 27, 2012 11:24 am 
Offline
User avatar

Joined: Sun May 27, 2012 8:51 am
Posts: 16
Thanks :) Indeed, if I write something like
Code:
Understand "Six Gun" and "Gun" as the SixGun.
then I can easilly for example call the description of the SixGun using either of those terms. It only falls down when I say "put Six Gun in Gun Belt".

......Maybe I'll just change the name of the gun :lol:

_________________
"Space is big. Really big. You just won't believe how vastly, hugely, mindbogglingly big it is. I mean, you may think it's a long way down the road to the chemist's, but that's just peanuts to space" - Douglas Adams.


Top
 Profile Send private message  
 
PostPosted: Sun Jun 03, 2012 8:25 am 
Offline
User avatar

Joined: Sun Mar 27, 2011 9:01 am
Posts: 115
Location: South Australia
Obinice wrote:
......Maybe I'll just change the name of the gun :lol:


Bertha!

_________________
Ever stop to think and forget to start again?


Top
 Profile Send private message  
 
PostPosted: Sun Jun 03, 2012 8:35 am 
Offline

Joined: Wed May 30, 2012 4:53 pm
Posts: 21
Would it work if you did something like "does the player mean doing something to the SixGun: it is very likely." ?


Top
 Profile Send private message  
 
PostPosted: Mon Jun 04, 2012 7:26 am 
Offline

Joined: Wed Feb 29, 2012 2:00 pm
Posts: 674
Trihan wrote:
Would it work if you did something like "does the player mean doing something to the SixGun: it is very likely." ?


You should be careful when using "does the player mean doing something to ..." to make something more likely as it can cause the item specified to be automatically chosen when automatically supplying a missing noun.

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


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