Taking and description

Hi

never mind the nonsense text, this is just for testing.


Bedroom is a room. "Very nice bedroom, lots of sleeping in here, occasionally."

A pillow is in the bedroom. Description of pillow is "Love it, yeah."
A mat is in the bedroom. Description of Mat is "This is too much for a classy room like this."
A CD is in the bedroom. Description of CD is "High-culture music." 
A book is in the bedroom. Description of book is "Not Kama Sutra, it's just the latest novel by Danielle Steel."

Instead of taking:
	if the noun is pillow:
		say "yeah. [line break]";
	otherwise:
		if the noun is CD:
			say "cool thing. [line break]";
		otherwise:
			say "You're right. You can take that too (and so you did) [line break]".

Can a description of a thing when taken/dropped be added to the lines that are putting the stuff into the game?
something like


The thingy is in the bedroom. Description of thingy is "a thingy thing, this thing." When thingy is taken "you took it.". When thingy is dropped "and now you dropped it, this thingy."

If you check out this transcript of “playing the game” you’ll see that the book can be taken several times and that, if dropped, already is in the room. But I thought a thing would automatically move to the player when taken?

[rant]

[/rant]

M:)rten

The Instead rule has a default result of “failure.” That means the action stops at the end of the rule. In the case of your example, this happens after printing the message about taking the thing, so taking never actually happens. One thing you could do is use an After rule:

After taking the pillow: say "You snag the thing. O the pillowy goodness!"

After rules, as the name implies, fire after the action has already made changes in the world model (the Carry Out phase). That means you can use them to print messages about what happened, or create secondary effects that spring from the action. Reporting what happened could also be done with the Report rules, but in this case After rules should be more straightforward.

A word about rules may be in order. The nested construction you’re using,

Instead of taking: if the noun is pillow: say "yeah. [line break]"; otherwise: if the noun is CD: say "cool thing. [line break]"; otherwise: say "You're right. You can take that too (and so you did) [line break]".

works, but the way rules are intended to work provides an easier, more I7 method of doing it.

[code]After taking something: say “You’re right. You can take that too (and so you did).”

After taking the pillow: say “Nice. Also, fluffy.”
After taking the CD: say “Cool thing!”[/code]

Now the general statement (“taking something”) will be overridden by the more specific ones, in a way that can be extended as needed.

Thank you!

Interesting and informative.

I see the logic in Instead-failure. Thx

(I love the humour you guys comes up with all the time. Nice pillow-statements Eleas! )

M:)rten

This way is slightly more extensible if you are going to have a lot of items with custom messages for taking or dropping.

[code]Bedroom is a room. “Very nice bedroom, lots of sleeping in here, occasionally.”

A thing has a text called drop-message. The drop-message is usually “And now you are having dropped this thing you were having had.”
A thing has a text called take-message. The take-message is usually “You’re right. You can take that too (and so you did).”

A pillow is in the bedroom. Description of pillow is “Love it, yeah.” The take-message is “Nice. Also, fluffy.” The drop-message is “You will miss its fluffiness greatly.”
A mat is in the bedroom. Description of Mat is “This is too much for a classy room like this.” The take-message is “You take this cool thing.”
A CD is in the bedroom. Description of CD is “High-culture music.” The drop-message is “You’d really rather not… but okay.”
A book is in the bedroom. Description of book is “Not Kama Sutra, it’s just the latest novel by Danielle Steel.” The take-message is “Really? You took that? Seriously?”. The drop-message is “Good call.”

After dropping something (called Larry):
say the drop-message of Larry;
say “[paragraph break]”.

After taking something (called Ralph):
say the take-message of Ralph;
say “[paragraph break]”.

test me with “get pillow / get all / drop pillow / drop all”.[/code]

You can certainly do it that way, but I’m not sure it’s actually more extensible. As I get more familiar with I7, I find rules often work better and more flexibly than properties. You might experience a slight memory-for-speed tradeoff, but in this particular case, I think the difference would be tiny.

When I say extensible, I mean for example, let’s say after you have already coded 200 take-able items in the game you decide you want the drop-message to also show up when the player inserts an item into a container that the player isn’t holding (which, from a real-world logical standpoint, amounts to the same thing as dropping it in many ways, but it is not actually handled by the dropping action in Inform, of course). This would be a lot of work to go back and change if there are individual rules for each item, but with properties, you can just say this:

After inserting something (called Larry) into something not enclosed by the player: say the drop-message of Larry; say "[paragraph break]".

And also you can change the take-messages and such during the course of play, e.g…

Instead of thinking: say "Upon further reflection, you decide you kind of like Danielle Steele's work after all."; now the take-message of the book is "You eagerly snatch up the novel."; now the drop-message of the book is "You reluctantly part with your new favorite book."

Those are two great reasons to use properties.