IF statement (if value1 > value2)?

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].[/code]

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

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

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:

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 :stuck_out_tongue: Out of curiosity, what was I doing wrong?

So…any thoughts on that SixGun/Six Gun issue? :slight_smile:

Interesting, thanks! I added 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 :confused: 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)?

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.

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:

Understand "Six Gun" as the SixGun. .
But for some reason this doesn’t:

Understand "Six Gun" or "Gun" as the SixGun.

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

Thanks :slight_smile: Indeed, if I write something like 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 :laughing:


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.