What should be a simple problem - moving clothing to player

I want to make it so a character wears underwear and trousers. But when he wears trousers the underwear is invisible. So far I’ve got:

[code]Before wearing the jeans: move the tattered underwear to limbo.

After taking off the jeans: move the tattered underwear to the player. [/code]

Which works ok, I can get the underwear there, but how I get it on him? I see there’s an example in the manual, but it’s way more complex than what I need…


After taking off the jeans: now the player wears tattered underwear.

Do keep in mind that this can lead to the underwear magically reappearing; assuming the player starts wearing the jeans, try “remove jeans/remove underpants/wear jeans/remove jeans.” The simplest way around this might just be to prevent the player from going commando:

Before wearing the jeans when the tattered underwear is not worn: say "The jeans are much too scratchy to wear against your bare skin." instead.

As an aside, you might want to use a Carry out rule instead of a Before rule to move the tattered underwear to limbo. Since Before rules run before anything else, I couldn’t use a Check rule to prevent the player from wearing the jeans without the underwear; by the time the Check rule ran the underwear would already be in limbo.

As another aside, is there a reason that you need the underwear to be in limbo instead of simply out of play? (“Remove the underwear from play” works for that; see 8.10 of the documentation.)

which will only be a problem if the character isn’t a Mormon.

  • Wade

Maybe the player is a never-nude?


Seriously, though, you should change both those rules to carry out rules. As it stands, each of them creates a different problem.

Try this:

[code]The Bluth-Fünke Household is a room. The player wears the jeans. The jeans are plural-named. There is some tattered underwear.

The glass chest is a transparent openable open container in the Bluth-Fünke Household.

Before wearing the jeans:
if the tattered underwear is worn: [if the player can wear the jeans without the underwear, we don’t want the underwear to disappear from the floor when doing so]
remove the tattered underwear from play.

After taking off the jeans:
now the player wears the tattered underwear.

Before wearing the jeans when the tattered underwear is not worn: say “The jeans are much too scratchy to wear against your bare skin.” instead.

Test me with “rules/i/remove jeans/i/put jeans in chest/close chest/i/wear jeans/i”.[/code]

As you can see, “remove jeans” doesn’t produce any output. This is because After rules stop the action before the Report rules run (unless you include “continue the action” in the After rule). See section 7.5. So you almost always want your After rules to be printing things.

Perhaps more insidiously, after you try to put the jeans on when they’re in the glass chest, your underwear disappears! This is because the “Before wearing the jeans” rule runs before any of the stuff that checks whether you actually succeed in wearing the jeans. [The actual rules that makes it fail doesn’t show up in the rules tracing – I think it’s the basic accessibility rule. But the same thing would happen if the action failed on a Check or Instead rule.]

Neither of these problems will arise if you make the rules into Carry Out rules – those don’t stop the action, so the Report rules will run, and they run after Check rules run, so the rule won’t take your underwear away unless you succeeded in wearing the jeans. And then you can turn the rule that prevents the player from wearing jeans without underwear into a Check rule, which it should be.

Section 12.21 of the documentation has a nice primer about when to use Before, Instead, After, Check, Carry Out, etc. rules, though people can and do disagree with some of those recommendations. (For instance, climbingstars never uses “Instead” rules, I believe.)

For Kerkerkruip/ATTACK I had to add an After Reporting rulebook. I wonder if it’d be useful for other situations?

Wow. Thank you for the in-depth reply to my simple, mostly nonsensical issue. This was more for my personal benefit than anything else, because I want to do stuff and I must do it. So this was holding me up.

I will try the first solution first (I wonder bemusedly why I didn’t think of it on my own), as this is mostly a matter of aesthetics and not a puzzle solution. If a person is so obsessed with trying to make the magic underwear appear, then so be it. I will worry about that later.

Perhaps the jeans stay on once the character is in public. I can make them removable later if I need to.

Thanks so much everyone :slight_smile:

If one wants to respect the generic case/special case distinction between Check/Carry Out/Report (all generic) and Before/Instead/After (all special) respectively that the Manual tries to inculcate, I suppose all three of Matt’s rules should be Instead rules.

That’s probably pretty uncontroversial as regards the rule for ‘wearing the jeans when the tattered underwear is not worn’. Instead of wearing the jeans when the tattered underwear is not worn: say "The jeans are much too scratchy to wear against your bare skin." would do the job admirably.

But making the other two rules Instead rules would mean that by default the actions (‘wearing the jeans’ and ‘taking off the jeans’) stopped after they have run, and so the player would be left nude in the one case and wearing both underwear and jeans in the other. In both cases adding the phrase ‘continue the action’ solves the problem.

Instead of wearing the jeans when the tattered underwear is worn:
	remove the tattered underwear from play;
	continue the action.

Instead of taking off the jeans:
	now the player wears the tattered underwear;
	continue the action.

That, I guess, is the solution most in line with the Manuals recommendations.

Alternatively, in this special case, if you just want the underwear not to show up while taking inventory when the player has his/her jeans on, you could remove them just-in-time, as it were, and put them back on afterwards:

The Bedroom is a room.
Some jeans are wearable in the Bedroom.
The player wears tattered underwear.

Instead of wearing the tattered underwear when the jeans are worn: say "Not on top of the jeans!"

Before listing contents of yourself when the jeans are worn and the tattered underwear is worn: now the tattered underwear is off-stage.
After listing contents of yourself when the tattered underwear is off-stage: now the player wears the tattered underwear.

It might be better not to mess with the actual inventory, but to just hide the underwear when they’re worn under the jeans, something like this:

First, let’s define a clothing kind and a many-to-many relation on it. We could just define the relation on all things, but that would be kind of inefficient.

[code]The Dressing Room is a room. The player wears some tattered underwear. The player wears a pair of jeans.

Clothing is a kind of thing. Clothing is usually wearable. The jeans and the underwear are clothing.

Coverage relates various clothing to various clothing. The verb to cover (it covers, they cover, it covered, it is covered, it is covering) implies the coverage relation.

The jeans cover the underwear.
Next, we’ll add a rule saying that covered clothing counts as concealed. If we wanted to be really fancy, we could use pathfinding to make the relation automatically transitive (so that e.g. if a jacket covered a sweater and the sweater covered a T-shirt, then the jacket would automatically cover the T-shirt), but that would be slower and more complicated, and probably not worth it unless you had a huge variety of clothing (in which case you should look into implementing something more modular anyway, like standardized clothing slots).

Rule for deciding the concealed possessions of somebody (called the person): if the particular possession is clothing and the person wears the particular possession and the person wears something that covers the particular possession, yes; otherwise make no decision.
Finally, we need to reimplement the inventory-taking rule to make it skip concealed clothing – the normal inventory command assumes that the player knows their possessions whether or not they’re concealed from others.

[code]The print standard inventory rule is not listed in any rulebook.

Carry out taking inventory (this is the print unconcealed inventory rule):
say “You are carrying: [line break]”;
now all things enclosed by the player are marked for listing;
now all concealed things worn by the player are unmarked for listing;
list the contents of the player, with newlines, indented, giving inventory information, including contents, with extra indentation, listing marked items only.

Test me with “i / remove jeans / i / remove underwear / i / wear jeans / i / remove jeans / drop all / i”.
Note that the effect might be less confusing if we modified the inventory to list carried and worn items separately – see e.g. Chapter 6.7. (Inventory) in the Inform Recipe Book, on which the rule above is based.

All this might seem overkill for just two items of clothing, but this way it’s easy to add more of them:

The ratty T-shirt, the green sweater, the leather jacket, the swirling opera cloak, the pair of plaid socks and the pair of expensive sneakers are clothing in the dressing room. The sweater covers the T-shirt. The jacket covers the T-shirt and the sweater. The cloak covers the T-shirt, the sweater, the jacket, the underwear and the jeans. The sneakers cover the socks. Understand "shirt" as the T-shirt. Understand "shoes" as the sneakers.

I vaguely recall doing this by making an “overlapping” relation, and naming different articles as overwear or underwear and torsoworn and pelvisworn. There was a mind boggling sequence of rules to make sure of things like that the player took off pelvisworn overwear before putting on pelvisworn underwear. The cool part was the player could wear any type of inner/outer combination they wanted. After putting pelvisworn outerwear on over pelvisworn underwear, the overlapping relation was set and the underwear moved offstage. The cool part was since inner layers were off-stage a look would only report the outer clothing. Then I had an “after printing the name of…” rule that made inner layers list in inventory. “A button down dress shirt (worn) (over a crewneck teeshirt)”

Wish I hadn’t lost all that code in a hard drive crash dagnabbit.

Or one might prefer not to mess with the standard inventory rule … :wink:

Yes it’s true, but I do have my reasons.

You may also want to take a look at “Example 234 - Bogart” in the Inform Documentation. It deals with layered clothing.

Hope this helps.

Well, I don’t want to get too deep into exegesis of the manuals, but I don’t think anyone would advise using “instead” rules here! My reading of it is that “Instead” works best when the entire action is a special case, as for the rule that keeps you from putting on jeans when you aren’t wearing underwear. The other rules are modifications to actions that apply more generally – we want the usual preconditions, behaviors, and reports for wearing and taking off the jeans to apply, but we also want the action to have an extra effect on the underwear. So that seems like a cause for a specific Carry Out rule. The point of the “instead” rulebook is that it stops the action (if we have got through the Before and accessibility rules, etc.), so having an “instead” rule that always continues the action seems like a bad idea.

There is that. On the other hand, one might well want to mess with the standard inventory rule for other reasons anyway, particularly if one is implementing special treatment for clothing as opposed to other inventory.

Fortunately, the Recipe Book has excellent examples on how to do it, because without them it would be damn near impossible without deep knowledge of Inform’s guts. But the examples (particularly the first one) show you exactly which magic phrases to incant to get the results you want.

Well, yes, the first section is true. And it’s also worth noting that an instead rule automatically marks the action as “failed” internally, which – especially if the instead-special-cased action is depicted as succeeding, in the fiction – can have unforeseen effects and cause obscure bugs in other parts of the code. But in fact, Felix is right that carry out rules are never supposed to be specific. Personally, I’d say that unless you’re writing a new verb or modifying the behavior of an old one in some way, it is best to avoid the Advanced Action rulebooks all together.

I think this is the kind of situation for which after rules are best suited. You can simply add “continue the action” to the end if you want to fall through to the default report rule.

Yes, but since, in this case, the action is continued, it will also run the standard carry out and report rules – which marks the action as success. Won’t it?