****updated with a new question****

example of some code.

after banging brown coconut on sharp rock:
say “You smash the brown coconut against the rock, it splits open spilling all the precious fluids on the ground. Annoyed you throw the empty coconut away, seems you will need to find another way to get at the water inside the brown coconut. Hopefully there is more coconuts on the island somewhere.”;
move brown coconut to out of world;
move green coconut to hbeach.

this is fine, what wanted to do was to move the green coconut to a random location in the region called shore which is comprised of rooms abeach - rbeach but I could not find the proper verbiage to make it work.

Thanks

[code]To fling (O - an object) to (R - a region):
let L be a random room in R;
if R is not nothing:
move O to L.

after banging brown coconut on sharp rock:
fling green coconut to shore;
remove brown coconut from play;
say “That long thing that you said.”
[/code]

Thank you

2 pronged question ahead after I let you know what I am trying to do. I have a bit of scenery called shrub. I hid some fruit under the shrub using the hiding under extension. In the rooms description it mentions the shrub. I want the fruit to not be mentioned in the room description so finding it is not just a a person walking into the room and being spoiled that it is there. The way it is now, in the room the player will x the shrub and see the message that it bears fruit. then when the x fruit I have it so (after reading a command:
if the player’s command includes “examine shrub” , replace matched text with “look under shrub”).

when the player examines the shrub this is the printout:

Under shrubs you find 12 fruits.

Here you see a shrub that has some strange looking orange fruit hanging from it.

Now the question/s:

  1. How do I suppress the “Under shrubs you find 12 fruits” message. and
  2. I know using the extension is a clunky way to do this, what is another suggestion? I will now cut and paste all applicable code.

Shrubs is scenery in pjungle. Understand “shrub” as shrubs.

melon is a kind of thing. melon is edible.

a fruit is a kind of melon.

12 Fruit is hidden under shrubs.

after looking under shrubs:
say “Here you see a shrub that has some strange looking orange fruit hanging from it.”;
display figure of shrub.

after reading a command:
if the player’s command includes “examine shrub” , replace matched text with “look under shrub”

after taking fruit when the location is pjungle:
say “You pick one of the fruits off the shrub.”;
now the player is carrying the noun.

This is a very very bad way of converting examining to looking under since “examine shrubs”, “examine the shrub”, “examine shrubs”, “look at shrub”, “look at shrubs”, “look at the shrub”, “look at shrubs”, “x the shrub”, “x shrubs”, “x shrub” and “x shrubs” (the most likely to be used) won’t convert from examining to looking under. You should ust this instead of the after reading a command rule.

Check examining the shrubs: try looking under the shrubs instead.

This will work regardless what the player types.

Why do you need to do all this just to get the message “Here you see a shrub that has some strange looking orange fruit hanging from it.” when the player examines the shrubs? Why don’t you just do this.

The description of the shrubs is "Here you see a shrub that has some strange looking orange fruit hanging from it.".

Also, you should say “The shrubs are scenery in pjungle.” rather than “Shrubs are scenery in pjungle.” otherwise Inform 7 thinks that it is a proper noun.

Saying “now the player is carrying the noun.” is unnecessary since the player is already carrying the noun at this stage.

After taking a fruit in pjungle: say "You pick one of the fruits off the shrub.".

Do you have other kinds of melons other than fruits? If not, it would be simpler to use this.

A fruit is a kind of thing. A fruit is always edible.

You can also say “A fruit is usually edible.” instead of “A fruit is always edible.” if you have inedible fruits.

Try this.

[code]“Test”

Include Hiding Under by Eric Eve.

The Pjungle is A Room.

The shrubs are scenery in pjungle. The description of the shrubs is “Here you see a shrub that has some strange looking orange fruit hanging from it.”. Understand “shrub” as the shrubs.

A fruit is a kind of thing. A fruit is edible.

12 Fruits are hidden under the shrubs.

[After examining the shrubs: display figure of shrub.]

After taking a fruit in pjungle: say “You pick one of the fruits off the shrub.”.

Test me with “x shrubs / examine shrubs / look under shrubs / take all fruits”.[/code]

This should pretty much do what you want. I’m assuming that “display figure of shrub.” displays an image of some sort. I’m not sure what extension/code your using to get this to work, but if it worked for you before then uncommenting the relevant line should allow it to work in a similar way as before.

Hope this helps.

Thanks for the response, all that still does not address the main point which is that I do not want “Under shrubs you find 12 fruits” to show up. If I did away with using the extension and just put the 12 fruits on the shrub instead of hiding them under it…how could I suppress them being named in the room description until the player examines the shrub? Thats is all I want basically, to have the fruit be there unknown to the player until they examine the shrub. If it was just a single fruit I could have it elsewhere then move it to the location when the player examines the shrub but I have a hard time figuring out how to do so with 12 fruits. That is why I turned to using the extension, it does what I want except for that undesirable “Under shrubs you find 12 fruits” message.

Do you mean something like this?

[code]“Test”

Include Hiding Under by Eric Eve.

The Pjungle is A Room.

The shrubs are scenery in pjungle. The description of the shrubs is “Here you see a shrub that has some strange looking orange fruit hanging from it.”. Understand “shrub” as the shrubs.

A thing is either examined or unexamined. A thing is always unexamined.

Carry out examining: if the noun is a thing, now the noun is examined.

Check looking under the unexamined shrubs: say “You see nothing under the shrubs.” instead.

A fruit is a kind of thing. A fruit is edible.

12 Fruits are hidden under the shrubs.

[After examining the shrubs: display figure of shrub.]

After taking a fruit in pjungle: say “You pick one of the fruits off the shrub.”.

Test me with “look under shrubs / x shrubs / examine shrubs / look under shrubs / take all fruits”.[/code]

Here, the player has to examine the shrubs first in order to see the fruits.

Hope this helps.

On second thoughts, I think this is what you are looking for.

[code]“Test”

Include Hiding Under by Eric Eve.

The Pjungle is A Room.

The shrubs are scenery in pjungle. The description of the shrubs is “Here you see a shrub that has some strange looking orange fruit hanging from it.”. Understand “shrub” as the shrubs.

This is the stealthy looking under rule:
if something is hidden under the noun begin;
now everything hidden under the noun is in the holder of the noun;
say “[the description of the noun][line break]”;
now nothing is hidden under the noun;
otherwise;
consider the standard looking under rule;
end if.

The stealthy looking under rule is listed instead of the revised looking under rule in the carry out looking under rules.

Check examining the shrubs: try looking under the shrubs instead.

A fruit is a kind of thing. A fruit is edible.

12 Fruits are hidden under the shrubs.

[After looking under the shrubs: display figure of shrub.]

After taking a fruit in pjungle: say “You pick one of the fruits off the shrub.”.

Test me with “x shrubs / look under shrubs / take all fruits”.[/code]

Here, examining and looking under the shrubs do exactly the same thing. They give the description of the shrubs and then stealthily move the fruits ito play.

Hope this helps.

DUDE!!! That is it! If I could I would totally buy you a beer right now. Thanks so much.

No problem! Just two quick points.

It should be

say "[the description of the noun][line break]";

rather than

consider the carry out examining rules;

because the latter (as it was before) will give an error message when looking under because it refers to a variable that’s not there.

Also, it should be

After looking under the shrubs: display figure of shrub.

rather than

After examining the shrubs: display figure of shrub.

because the examining version will never fire since the action is converted to looking under.

Hope this helps.

PS. Thanks for the virtual beer! :slight_smile:

Yeah I already fixed that second one :wink: Will change the first.

I’m trying to learn how to write IF games using examples in the documentation and here in the forums. I have a variation of the topic submitted here except I’m not using the Under extension mentioned. This is my code.

[code]“Test” by Eli Badcock

A fruitobject is a kind of thing. A fruitobject is edible. Fruitobject has some text called flavor. The flavor of fruitobject is usually “Tart.” Fruitobject can be ripe or unripe. Fruitobject is usually ripe.

The Garden is a room.

The shrubs are scenery in the Garden. The shrubs is an open container.The description of the shrubs is “Here you see a shrub that has some strange looking orange fruit hanging from it.”. Understand “shrub” as the shrubs.

Melon is a fruitobject. Understand “fruit” as melon. Understand “melons” as melon. There are 13 melons in the shrubs.

[Instead of examining the shrubs:
say “Here you see a shrub that has some strange looking orange fruit hanging from it.”.]

After taking a melon in Garden: say “You pick one of the fruits off the shrub.”.

Test me with “x shrubs / take fruit / take melon / take 3 melons”.[/code]

The output is:

[code]Test
An Interactive Fiction by Eli Badcock
Release 1 / Serial number 130829 / Inform 7 build 6G60 (I6/v6.32 lib 6/12N) SD

Garden

test me
(Testing.)

[1] x shrubs
Here you see a shrub that has some strange looking orange fruit hanging from it.

In the shrubs is 13 melons.

[2] take fruit
You can’t see any such thing.

[3] take melon
You can’t see any such thing.

[4] take 3 melons
You can’t see any such thing.

i
You are carrying nothing.[/code]

I have a number of questions. Hopefully someone with more knowledge can point me in the right direction.

  1. Chapter 3.8 Scenery, contains this statement “Scenery containers do not behave in this way: their contents are assumed to be less immediately visible, and will be mentioned only if the player looks inside them.”. So why are the contents of the scenery container listed without examining the shrubs?

  2. Why isn’t fruit understood as melon? I’ve looked at many other examples and I’ve tried multiple variations of the using statement and I still get the same results.

  3. Why does the shrub contain one object of “13 melons” instead of 13 single “melon” objects?

  4. If the shrubs contain 13 single “melon” objects, would “Take 3 melons” actually put 3 melons in the player’s inventory?

Thanks

This particular distinction applies to the room description, not to the description of the object itself. Try making the shrubs a supporter and the game’s initial output (before you even type anything) will look like this:

The game automatically generates the text telling you what’s on the supporter in the room description. But by default, whenever you examine a supporter or a container, after printing the description you’ve given to the object, the game will tell you what’s in/on it. (The documentation is somewhat misleading here, as it seems to suggest you’ll only see this text when looking inside a scenery container, when examining does it as well.)

My recommended solution here is moving the text you have as the description of the shrubs into the room description. Even if you don’t give the shrubs a description, the game will tell you that the shrubs contain melons when you examine it (or that they’re empty, if they are). And you should make this text conditional on whether the shrubs contain any melons; you don’t want the game to print “Here you see a shrub that has some strange orange looking fruit hanging from it.” when there aren’t any melons.

You need to say “A melon is a kind of fruitobject.” If you just say “A melon is a fruitobject” the game generates a fruitobject called a “melon” offstage, and when you declare “13 melons” it generates a completely unrelated object called “13 melons,” which isn’t a fruitobject. So, “fruit” really is being understood as the melon, it’s just that the melon isn’t where you think it is.

Yes!

A couple other things:

It’s probably good to declare “The shrubs are plural-named” so, if the player takes all the melons, the game prints “The shrubs are empty” rather than “The shrubs is empty.”

You should also say “A melon is a kind of fruitobject” so the game doesn’t think “melon” should be capitalized. (Writing “melon is a kind of fruitobject” would work just as well, but it looks kind of yucky.)

You also probably want to write code that prevents the player from putting stuff back in the shrubs. That’s a bit of work so I won’t try to write any code for it now, but if you want help come back!

You may also want to run your game after typing “rules” and “actions” so you can see what rules are doing what; in particular the “Examine containers rule” is the rule that prints “In the shrubs are thirteen melons.”

If you want to customize the description of the shrubs a bit you could use an “Instead of examining the shrubs” rule; this might let you say something more enlightening than “The shrubs are empty” when they’re empty. If you want to do this you might want to look up the “Examine containers rule” in the Standard Rules and take some of that behavoir!

Anyway, here’s the code with some of the modifications I’ve talked about:

[code]“Test” by Eli Badcock

A fruitobject is a kind of thing. A fruitobject is edible. Fruitobject has some text called flavor. The flavor of fruitobject is usually “Tart.” Fruitobject can be ripe or unripe. Fruitobject is usually ripe.

The Garden is a room. “Here you see a shrub[if a melon is in the shrubs] that has some strange orange looking fruit hanging from it[end if].”

The shrubs are scenery in the Garden. The shrubs are an open container. The shrubs are plural-named. [The description of the shrubs is “Here you see a shrub that has some strange looking orange fruit hanging from it.”]. Understand “shrub” as the shrubs.

A melon is a kind of fruitobject. Understand “fruit” as melon. Understand “melons” as melon. There are 13 melons in the shrubs.

[Instead of examining the shrubs:
say “Here you see a shrub that has some strange looking orange fruit hanging from it.”.]

After taking a melon in Garden: say “You pick one of the fruits off the shrub.”.

Test me with “x shrubs / take fruit / take melon / take 3 melons”.[/code]

matt, thanks for the help. It looks like the “kind of” phrase was the key.

Yes, code to prevent putting the fruit back on the shrub would be helpful. My thoughts would be that I would define a new kind of thing (fruit tree or similar). Then define an “instead of rule” for the new thing so it only allows taking objects and not placing (putting?) objects.

Ok, how does this look? Any suggestions you can make? I took two approaches. Either should work just fine (at least in my tests). The tree object is a supporter and will have fruit on it. The bush object is an open container and will have fruit in it.

"Test" by Eli Badcock

A room can be indoors or outdoors. A room is usually indoors.

The Garden is an outdoors room. "Here you see a shrub[if a melon is in the shrubs] that has some strange orange looking fruit hanging from it[end if]. You can also see a tree[if a cherry is on the tree] bearing some bright red cherries[end if].". 

A fruitobject is a kind of thing. A fruitobject is edible. Fruitobject has some text called flavor. The flavor of fruitobject is usually "Tart." Fruitobject can be ripe or unripe. Fruitobject is usually ripe.

A fruit_tree_object is a kind of supporter.

Before putting something on a fruit_tree_object: 
	say "The [the noun] falls to the [if outdoors]ground[otherwise]floor[end if].";
	try silently dropping the noun instead. 
	
A fruit_bush_object is a kind  of container. It is open.

Before inserting something into the fruit_bush_object: 
	say "The [the noun] falls to the [if outdoors]ground[otherwise]floor[end if].";
	try silently dropping the noun instead. 

The shrubs are scenery in the Garden. The shrubs are a fruit_bush_object[an open container]. The shrubs are plural-named. [The description of the shrubs is "Here you see a shrub that has some strange looking orange fruit hanging from it."]. Understand "shrub" as the shrubs.

Melon is a kind of fruitobject. Understand "fruit" as melon. Understand "melons" as melon. There are 13 melons in the shrubs.

The tree is scenery in the Garden. The tree is a fruit_tree_object[an open container]. [The description of the shrubs is "Here you see a shrub that has some strange looking orange fruit hanging from it.".] 

Cherry is a kind of fruitobject. Understand "fruit" as cherry. Understand "cherries" as cherry. There are 24 cherries on the tree.

After taking a melon in Garden: say "You pick one of the fruits off the shrub.".

After taking a cherry in Garden: say "You pick one of the cherries from the tree.".

Test me with "x shrubs / take fruit / take cherry / take melon / take 3 melons / take 5 cherries / i / put cherry on tree / l".

I would like generalize the take command. [the second noun] is correct. So I am looking for the proper term so it says “You pick the cherries off the tree.”

Instead taking something on a fruit_tree_object: say “You pick one of the [the noun] off the [the second noun].”.

I don’t know how helpful this will be to anyone, but when dealing with hidden items, this is usually how I do things:

The island is a room.
The bush is scenery in the island.
The melon is a thing.

instead of searching the bush:
   move the melon to the island;
   say "Oh! There's a melon under this bush.".
before looking under the bush, try searching the bush.

The idea is to leave the hidden object completely offstage until the player discovers it. This ensures that the player won’t interact with it in some unpredictable way. The other upside is that the bush doesn’t even have to be a container. You can simply move the item to the same room as the bush, and let the player assume its location.

Outcast,
That’s very helpful. Since I am very new at this, lots of examples are helpful.

Sorry for not posting earlier. I didn’t realize for a while that this was hard, and then this turned out to be very hard!

A couple of notes about your earlier code first:

In some places you write "“The [the noun].” This will cause “the” to be printed twice. “[The noun]” is fine; this prints the definite article for the noun, whatever it may be (and is good about capitalization and stuff). Also, you have “Melon is a fruitobject” which will lead to “Melon” being capitalized everywhere you use it.

For your rule preventing people from putting things back on the tree/shrub; that could possibly cause trouble. For instance, if the player is trying it with something they can’t drop for whatever reason, then the game will print a message saying that the noun has fallen to the ground, but it won’t be on the ground. My advice – and this is more user-friendly anyway – is just to print a message saying something like “You can’t put stuff back on the tree” and stop the action right there. Don’t let them try it, since it won’t do them any good.

Now as for the fruit_tree_object: The problem is that the taking action doesn’t have a second noun. The action is just “taking the cherry”; if the cherry is on a tree, the tree doesn’t become the second noun. Sometimes you can work through this by rules like “Instead of taking something when the noun is on a fruit_tree_object”; but here we want to print a message once the taking action has succeeded, and then the noun won’t be on a fruit_tree_object anymore!

Sometimes we can use the past tense to take care of this: I can say “After taking the golden idol when the golden idol was on the altar:” to capture the case where the player takes the idol off the altar. But this won’t generalize; you can’t use “the noun” in rules like this.

I wound up going with action variables (discussed in section 12.10 of the documentation). This lets us figure out whether the noun is in a container or on a supporter when we start processing the taking action, and preserve the container or supporter throughout the action. It looks like this:

[code]“Test” by Eli Badcock

A room can be indoors or outdoors. A room is usually indoors.

The Garden is an outdoors room. “Here you see a shrub[if a melon is in the shrubs] that has some strange orange looking fruit hanging from it[end if]. You can also see a tree[if a cherry is on the tree] bearing some bright red cherries[end if].”.

A fruitobject is a kind of thing. A fruitobject is edible. Fruitobject has some text called flavor. The flavor of fruitobject is usually “Tart.” Fruitobject can be ripe or unripe. Fruitobject is usually ripe.

A fruit_tree_object is a kind of supporter.

Before putting something on a fruit_tree_object:
say “[The noun] falls to the [if outdoors]ground[otherwise]floor[end if].”;
try silently dropping the noun instead.

A fruit_bush_object is a kind of container. It is open.

Before inserting something into the fruit_bush_object:
say “[The noun] falls to the [if outdoors]ground[otherwise]floor[end if].”;
try silently dropping the noun instead.

The shrubs are scenery in the Garden. The shrubs are a fruit_bush_object[an open container]. The shrubs are plural-named. [The description of the shrubs is “Here you see a shrub that has some strange looking orange fruit hanging from it.”]. Understand “shrub” as the shrubs.

A melon is a kind of fruitobject. Understand “fruit” as melon. Understand “melons” as melon. There are 13 melons in the shrubs.

The tree is scenery in the Garden. The tree is a fruit_tree_object[an open container]. [The description of the shrubs is “Here you see a shrub that has some strange looking orange fruit hanging from it.”.]

A cherry is a kind of fruitobject. Understand “fruit” as cherry. Understand “cherries” as cherry. There are 24 cherries on the tree.

The taking action has an object called the container taken from (matched as “out-of”). The taking action has an object called the supporter taken from (matched as “down-from”).

First setting action variables for taking:
now the container taken from is nothing;
now the supporter taken from is nothing.

Setting action variables for taking when the noun is in a container: now the container taken from is the holder of the noun.
Setting action variables for taking when the noun is on a supporter: now the supporter taken from is the holder of the noun.

After taking something down-from a fruit_tree_object: say “You pluck [the noun] from [the supporter taken from].”
After taking something out-of a fruit_bush_object: say “You pluck [the noun] from [the container taken from].”

Test me with “x shrubs / take fruit / take cherry / take melon / take 3 melons / take 5 cherries / i / put cherry on tree / l”.[/code]

It seems to me that there should be a simpler way to do this but I’m not sure what.