Help For A Lurker

Ok I have a two problems in two projects so thought I’d ask for help on both of them now.

Problem one I’m trying to stop a person from going to a room with a certain property.

Mineshaft is a kind of room. A mineshaft can be stable or unstable. A mineshaft can be collapased or uncollapsed. A mineshaft is usually unstable. A mineshaft is usually uncollapsed.

In this case if the room is collapsed. But I can’t seem to get a instead that covers this.

Second. I’m trying to cause an action by the player to result in the player getting a random amount of a certain item between two numbers. This is what I need it to do:

Harvest tomato plant

You pick 3 tomatoes

Ideas?

On the first question, I just tried this and it seemed to work in my very simple test app.

[code]Mineshaft is a kind of room. A mineshaft can be stable or unstable. A mineshaft can be collapsed or uncollapsed. A mineshaft is usually unstable. A mineshaft is usually uncollapsed.

The entrance is a room.
The mine is a mineshaft. The mine is east of the entrance. The mine is collapsed.

before of going east from the entrance:
if the mine is collapsed:
say “The mine is collapsed, you can’t go that way.” instead;[/code]

Unfortunately to simple the idea is that there are underground tunnels that randomly collapse. So limiting it to one location won’t work I need a way to do this to cover every direction from every tunnel. [Solved the problem with a long work around]

Doesn’t “Instead of going to a collapsed mineshaft:” work?

Yes it does, I figured out I had a typo. I really need to work on breaking my work into books ect I can never find anything. So one problem done one left, any ideas on that one?

The answer to that one partly depends on how you’re going to model tomatoes, which depends on what you intend to be doing with them. If tomatoes are always going to be held by the player until consumed or traded away, for instance, it makes most sense to have a single ‘tomatoes’ item and give it a number variable describing how many the player has got. If you need to place individual tomatoes on sacred posts at various points around the map in order to appease the Tomato God, then you probably need to implement each tomato as a separate thing, in which case you’d make a new kind (“A tomato is a kind of thing. There are 20 tomatoes.”)

Either way, you’d pick the random number like so:

Carry out harvesting: let N be a random number from 1 to 5;

Can tomatoes ever exist somewhere other than in the player’s inventory (or at least a sharply limited number of places)? If not, you might consider implementing them sort of like money: there’s just a single object called “the tomatoes” and it has a number representing how many tomatoes it’s supposed to be. But if the player is supposed to be allowed to treat them as individual objects and scatter them around, this won’t work and you need real, actual objects for each one. Unfortunately Inform is specifically designed not to have dynamic objects of this kind. You can either construct a large stash of identical tomatoes as maga suggests, or you can try using the Dynamic Objects extension. Both options may be fraught with peril; the parser tends to have trouble with mostly- or completely-identical objects, and Dynamic Objects is also kind of fragile.

Here’s my first cut, but I warn you that it is likely to be a disaster.

"Delicious Vegetables" by Paul Zagieboylo

The Warehouse is a room. North Field is north of the Warehouse. South Field is south of the Warehouse.

The Warehouse has a number called tomato-count. The tomato-count of the Warehouse is 0.
The description of the Warehouse is "You have stored [tomato-count of the Warehouse] tomato[es] here."

The warehouse-tomatoes are privately-named scenery in the Warehouse. Understand "tomatoes" as the warehouse-tomatoes. The description is "[Tomato-count of the Warehouse] delicious-looking tomato[es], stored carefully against the elements."

Farmer Brown is a man in the Warehouse. The player is Farmer Brown.
Farmer Brown has a number called tomato-count. The tomato-count of Farmer Brown is 0. 

The tomatoes are a thing. The printed name of the tomatoes is "[tomato-count of Farmer Brown] tomato[es]". Understand "tomato" as the tomatoes.

To gain (N - a number) tomatoes begin;
increase the tomato-count of Farmer Brown by N;
if the tomato-count of Farmer Brown is greater than 0, move the tomatoes to Farmer Brown;
end.

A tomato plant is a kind of thing. The plural of tomato plant is tomato plants. A tomato plant is usually fixed in place. A tomato plant has a number called growing-delay. The growing-delay of a tomato plant is usually 0.
A tomato plant is ripe rather than unripe if the growing-delay of it is 0.

A tomato plant is in North Field. Two tomato plants are in South Field.

Every turn begin;
repeat with P running through tomato plants begin;
if the growing-delay of P is greater than 0 begin;
decrement the growing-delay of P;
if the growing-delay of P is 0 and Farmer Brown can see P begin;
say "A tomato plant has become ripe!";
end if;
end if;
end repeat;
end.

Harvesting is an action applying to one thing. Understand "harvest [something]" as harvesting. The harvesting action has a number called the tomatoes-harvested.

Does the player mean harvesting a ripe tomato plant: it is very likely.
Does the player mean harvesting an unripe tomato plant: it is unlikely.

Setting action variables for harvesting: now the tomatoes-harvested is a random number between 3 and 8.

Check harvesting a tomato plant when the growing-delay of the noun is not 0: instead say "That plant isn't ripe yet."
Check harvesting something that is not a tomato plant: instead say "That doesn't produce fruit."

Carry out harvesting begin;
gain tomatoes-harvested tomatoes;
increase the growing-delay of the noun by a random number between 2 and 6;
end.

Report harvesting begin;
say "You harvest [tomatoes-harvested] tomato[s] from the plant."
end.

Check dropping the tomatoes when not in the Warehouse: instead say "Tomatoes would rot if you left them there."

Carry out dropping the tomatoes when in the Warehouse begin;
increase the tomato-count of the Warehouse by the tomato-count of Farmer Brown;
now the tomato-count of Farmer Brown is 0;
remove the tomatoes from play;
action succeeds; [I think this is needed to prevent the normal dropping behavior from happening]
end.

Report dropping the tomatoes when in the Warehouse begin;
say "You put all the tomatoes on the shelves in the warehouse. Now you have [tomato-count of the Warehouse] tomato[es] stored up.";
end.

Hopefully this will get you started. If you have questions, just ask and someone who knows what they’re doing (i.e. not me) will probably be able to help you!