Nested IF Statement Woes

Oh IF statements, how I loathe you. Here’s an IF I’ve been working on, but I’m getting a compile error. I have been over and over it, and can’t see a problem, so it’s time for fresh eyes! What am I doing wrong? :confused:

Instead of inserting a gun (called the to-be-inserted) into a container (called the receptacle): if the receptacle is not a gun-belt: if the player has a gun-belt and the gun-belt does not contain a gun: if there is nothing in the gun-belt: say "You begin to wonder if [the noun] wouldn't be better stored in a holster."; otherwise: say "You begin to wonder if [the noun] wouldn't be better stored in a holster, rather than [the list of objects in gun-belt]."; Continue the action. otherwise: Continue the action. otherwise: [If the receptacle IS a gun-belt] if the to-be-inserted is in the receptacle: say "[The to-be-inserted] is already holstered!"; otherwise: say "[The to-be-inserted] fits snugly inside the holster."; continue the action.

For a start, those ‘continue the action’ statements should end with semicolons, not fullstops.

Try changing “Continue the action.” to “Continue the action;”.

Hope this helps.

Gosh darn it, see there you go! I am blind.

I suppose this is a matter of style (though not entirely – since the action continues, you will end up with both your custom response for holstering a gun and the standard inserting rule response for the same action).

Anyway, I think I would write a couple of different rules for this, rather than putting it all in a single one. I find it easier to see what I’m doing that way.

[code]Before inserting a gun into something when the second noun is not a gun-belt:
if the player has a gun-belt (called the holster) and the holster does not contain a gun:
if there is nothing in the holster:
say “You begin to wonder if [the noun] wouldn’t be better stored in a holster.”;
otherwise:
say “You begin to wonder if [the noun] wouldn’t be better stored in a holster, rather than [the list of objects in the holster].”

Instead of inserting a gun into a gun-belt when the noun is in the second noun: say “[The noun] is already holstered!”

After inserting a gun into a gun-belt: say “[The noun] fits snugly inside the holster.”[/code]
Both before and instead rules are considered before the rules that define the standard actions; instead rules automatically stop the action, whereas before rules doesn’t.

After rules are considered before the rule that prints the standard response to the standard actions and it stops the action; so it’s useful when you want to replace that response.