dropping something into an enterable (while being in it)

Probably a silly question. Go easy on me. I confess to being an Inform7 noob.

How do I trigger on the player dropping things into an enterable container regardless of whether or not the player is in it? In this case the ball only splashes when the player character is outside the pool. Is the reason that it doesn’t work that the ball is already inside the pool when the character first enters the pool? And how do I fix it?

[code]The garden is a room. The pool is an enterable container in the garden. The ball is a thing in the garden.

After inserting something into the pool:
say “Splash!”.

Test me with “take ball / drop ball in the pool / enter pool / take ball / drop ball in the pool”[/code]

Not a silly question at all. You’re right that the issue is that the player is already in the pool. In particular, if you type “rules” and “actions” into your game before you run the test script, you’ll see that what happens is that the “convert insert to drop where possible” rule is running and, well, converting the “inserting the ball into the pool” action into a “dropping the ball” action. So your “after inserting something into the pool” rule doesn’t run, since you’re not actually carrying out that action.

So the simplest fix is probably to add:

After dropping something when the player is in the pool: say "Splash!"

(This will also cause “drop ball” to print “Splash!” when the player is in the pool, but that’s probably a good thing.)

Right… but then the ball won’t splash when the player is outside of the pool! Is there no way of catching them both, short of creatingamy own “pooldroppping” action?

Anyway, thanks, this is like StackOverflow.com but for IF geeks! Hooray! And thanks for the “rules” trick, I only saw the “actions” before.

You don’t need to create a new action. If you want to avoid duplicating code, you can generally just set up your own routine with a “To …” phrase. Untested code:

[code]After dropping the ball when the player is in the pool:
do the splash.

After inserting the ball into the pool:
do the splash.

To do the splash:
say “Splash!”.[/code]

Sorry if I wasn’t clear – you should have both rules. One for inserting something into the pool, one for dropping when the player is in the pool. That’ll catch both cases.

My method involves typing “say ‘Splash!’” twice. This would get more annoying if you want to do something more complicated than say “Splash!” – if, for instance, you want to check whether the noun is buoyant. In that case I probably would [UPDATING BEFORE POSTING] do what Victor says, so there’s no danger of accidentally forgetting to update one part of the code when you update the other. But that depends on what you want to do.

(Funny you mention Stack Overflow – there’s a proposal for an IF site there. More discussion here.)

Could something like the OP wants be handled by an INSTEAD OF rule? Guessing at the approximate syntax off the top of my (admittedly imperfect) memory, something like

instead of dropping something when [the player's location] encloses the pool: now [the noun] is in the pool print 'Splash!'
N.B. The above should be considered to be more of an I7-esque pseudocode than actual I7 code. I’ve almost certainly missed some punctuation or nuances of syntax.

Well, yes, but if you only want to change the message generated by the action (which I assumed to be what the OP wanted), why would you go through the trouble of having to implement all the rest of the action (like moving the object and making sure that the appropriate checks are run)? Note that your code would allow us to drop scenery objects, people, and so on, because an “instead” rule bypasses all “check” rules.

OK, I see. I infer from that that an AFTER rule allows all of the normal check rules, so unless the OP doesn’t want ALL dropped objects to end up in the pool, I should think that

after dropping something when [the player's location] encloses the pool: now [the noun] is in the pool print 'Splash!'
would work instead, possibly eliminating the need to convert a drop action into an insert action when the player is NOT in the pool (or is that done automatically, without the author needing to write additional rules?).

The dropping action isn’t converted into inserting it into, it’s the other way around (but only when players try to insert something into something that they themselves are in as well).

It looks like you’re interpreting the OP’s desired behavior differently than the other posters. Based on my reading of the post as well as the included example, the OP wants to control the reporting of the ball being specifically dropped into the pool using “drop ball into pool” (just another syntax for the inserting it into action) or when the player drops the ball (using the dropping action) while in the pool.

I can see how the post could be interpreted as “How do I make it so when the player drops the ball (using “drop ball”) in the same location as the pool, it lands in the pool with a special message?” which is what it seems you’re trying to do. The solutions are different – maybe frudster could clarify.

Hi, wow, thanks for digging in everybody.

and yes, my idea was indeed that dropping something in the water would do the same thing regardless of whether or not the PC was in the water.

I came up with this, take it for a spin and let me know if I’m doing things extremely backwards - as I said, I’m new here. Also this is just a test so lots of nice stuff is missing. What I’m actually planning to do with this is a pool of muddy water where things you drop disappear into the mud until you figure out how to get them back – you’re not supposed to be able to go and look at the bottom like in this example.

The “if the bottom of the pool is something” bit is there so you can create a pool that doesn’t “sink to” a special bottom; in that case everything just stays in the pool, floating or not.

Also, a question: is there a way to specify a directional one-to-one relationship and name both sides, like surface / bottom?

[code]“Sinking pool and buoyancy” by frudster

section buoyancy

A weight is a kind of value. 1kg specifies a weight. 1g specifies a weight scaled down by 1000.
Everything has a weight. A thing usually has weight 100g.
A thing has a weight called buoyancy. The buoyancy of a thing is usually 0kg.

Definition: A thing is buoyant if its weight is less than its buoyancy.

section pool with a hidden bottom

[A pool where you can drop things. If they sink they sink out of sight, actually into
another coontainer called the bottom of the pool]

A pool is a kind of container. A pool is usually enterable and fixed in place.

Sinking down relates one container to another (called the bottom). The verb to sink to (he sinks to, they sink to) implies the sinking down relation.

After inserting something into a pool, carry out the sinking activity with the noun.

After dropping something when the player is in a pool, carry out the sinking activity with the noun.

Sinking something is an activity on things.

Rule for sinking a thing which is in a pool:
Let a pool be the holder of the noun;
say “You drop the [noun] into the [pool].”;
if the noun is buoyant:
say “It floats!”;
stop the action;
if the bottom of the pool is something:
say “It sinks out of sight.”;
move the noun to the bottom of the pool;
say “It sinks.”.

section scenario

The garden is a room. "A cute little garden with a fairly unpleasant pond. A ladder goes down a hole in ground. "

The cellar is a room. It is down from the garden. "A damp little space. A ladder goes up into the garden. "

The pond is a pool in the garden. Understand “water” as the pond.

The water wall is an fixed in place enterable container in the cellar. “There’s a shimmering vertical surface of water here, like in Stargate. How tacky!” The pond sinks to the water wall.

A rusty bolt is a thing in the garden.

A cork is a thing in the garden. The weight of the cork is 10g. The buoyancy of the cork is 20g.

test pool with "take bolt / drop bolt in pond / take cork / drop cork in water / enter pond / take cork / drop cork / x pond / out / take cork / drop cork / down / x water / take bolt / up / drop bolt " in the garden