Multiple future timed events?

OK. I know this is probably really unnecessarily long, but I just CAN’T figure this out! I’m running into a problem with " at the time when the tomato sprouts" when I plant more than one tomato. I end up with 1 fruit and 1 sapling instead of 2 fruits. Is there anything I can do? Here’s what I have

Planting is an action applying to one visible thing.

Understand "plant [things]" as planting.

report planting: say "[noun] has been planted successfuly"

carry out planting:
	if player has tomato seed:
		move the noun to storage;
		Now a random tomato sapling in storage is in nursery;
		The tomato sprouts in five turns from now;

At the time when the tomato sprouts:
	move a random tomato fruit to nursery;
	move a random tomato sapling in nursery to storage;
	say " Wow! One of your tomato fruits has grown into a ripe juicy tomato fruit! Go to the nursery to harvest your crop!"

a tomato sapling is a kind of thing.

39 tomato saplings are in storage.

nursery is a room.

a tomato fruit is a kind of thing. 

10 tomato fruits are in storage.

a tomato seed is a kind of thing.

25 tomato seeds are in storage.

P.S. sorry for the unorganized coding! :blush:

PLANT 2 SEEDS will trigger two planting actions in a row during the same turn (I think).
And the “tomato sprouts” timer is reset every time the planting action is carried out. So, it only ever keeps track of the last time you plant anything.

I’m not sure how to do this. Perhaps give seeds a planted property to set in the course of planting, and looping through all seeds every turn to see for how long they have been planted?

The Scheduled Activities extension might come in handy here. It allows syntax of the form “schedule (an activity) for (an object) in (a number) minutes”.

I’ve come across this problem before. It seems that the “at the time” rules/phrases can only be triggered one at a time. Try this (the capitalised words bit is courtesy of zarf).

[code]“Test”

To say (N - number) in capitalised words:
let result be an indexed text;
now result is “[N in words]”;
say result in sentence case.

Plant count is a number that varies. Plant count is zero.

Planting is an action applying to one visible thing. Understand “Plant [things]” as planting.

Check planting:
unless the noun is a tomato seed, say “You can only plant a tomato seed.” instead.

Carry out planting:
move the noun to storage;
now a random tomato sapling in storage is in nursery;
increment plant count;
the tomato sprouts in five turns from now.

Report planting:
say “[The noun] has been planted successfully.”.

At the time when the tomato sprouts:
say “Wow! [plant count in capitalised words] of your tomato saplings [if plant count is greater than one]have[otherwise]has[end if] grown into [if plant count is less than two]a [end if]ripe juicy tomato fruit[s]! Go to the nursery to harvest your crop!”;
while plant count is greater than zero begin;
move a random tomato fruit in storage to the nursery;
move a random tomato sapling in the nursery to storage;
decrement plant count;
end while.

Storage is a container. A tomato sapling is a kind of thing. 10 tomato saplings are in storage. A tomato fruit is a kind of thing. 10 tomato fruits are in storage. A tomato seed is a kind of thing. The player carries 10 tomato seeds.

The Nursery is A Room.

Test me with “i / plant all seeds / l / l / l / l / l / l”.[/code]

This should allow the right number of seeds to sprout. However, when the “at the time” rules/phrase fires, all the saplings will sprout at once, regardless of when you plant them.

Hope this helps.

Giving every seed its own “age” number, incremented every turn it’s planted, seems to be the easiest way.

climbingstars’ solution allows you to plant a dozen tomatoes in a row, and none of them will flower until 5 turns after your last planting, at which time all of them will. That’s probably not your intended behavior!

There might be a few flaws with that solution, but at least it works and I think it’ll be fine for what I’m doing. THANKS! :mrgreen:

OK now I’m getting a run time error saying I can’t move nothing. I’m pretty sure I had it working for a while, but now it wont work. I added some new, unrelated code and it’s not working. WHAT DO I DO?!

You’ll probably need to post the new code in order to gain assistance.

here is the ENTIRE code for my system

[code]A thing is either exchangeable or unexchangeable. A thing is either usually unexchangeable.

Everything has a number called price. The price of a thing is usually 0.

To say (N - number) in capitalised words:
let result be an indexed text;
now result is “[N in words]”;
say result in sentence case.

Plant count is a number that varies. Plant count is usually zero.

Planting is an action applying to one visible thing. Understand “Plant [things]” as planting.

Check planting:
unless the noun is a tomato seed, say “You can only plant a tomato seed.” instead.

Carry out planting:
move the noun to storage;
now a random tomato sapling in storage is in nursery;
increment plant count;
the tomato sprouts in five turns from now.

Report planting:
say “[The noun] has been planted successfully.”.

At the time when the tomato sprouts:
say “Wow! [plant count in capitalised words] of your tomato saplings [if plant count is greater than one]have[otherwise]has[end if] grown into [if plant count is less than two]a [end if]ripe, juicy, tomato fruit[s]! Go to the nursery to harvest your crop!”;
while plant count is greater than zero begin;
move a random tomato fruit in storage to the nursery;
move a random tomato sapling in the nursery to storage;
decrement plant count;
end while.

a tomato sapling is a kind of thing.

39 tomato saplings are in storage.

nursery is east of land.
“Welcome to your nursery! To get started planting your tomatoes, first, pick up your free seeds. Next say PLANT ‘number’ TOMATOES. Tomatoes take 20 minutes (20 turns) to grow, while you wait, you can check out some of our other wonderful attractions! When your’e done, you can go to the shop to the east, exchange your tomatoes for points and purchess some souveniers! Happy planting!”

Shop is east of Nursery.
“Welcome to ‘THE LAND’ store! If you have any tomato fruits you can exchange them for points! If you’d like to exchange your fruits for points, say, EXCHANGE ‘number’ TOMATO FRUITS. If you’d like to buy something, say BUY item.”

Check tomato exchange:
if the noun is unexchangeable, say “You can’t exchange [the noun]!” instead.

Carry out tomato exchange:
increase the score by the price of the noun;
move the noun to storage;
say “You have [score] points.”.

tomato exchange is an action applying to one visible thing.

Understand “exchange [things]” as tomato exchange.

A tomato fruit is a kind of thing.

A tomato fruit is exchangeable.

The price of a tomato fruit is 5.

a tomato seed is a kind of thing.

25 tomato seeds are in storage.

3 tomato seeds are in nursery.

a room can be suitable for planting. a room is usually not suitable for planting.

check planting (this is the can’t plant outside the nursery rule):
if the location of the player is not suitable for planting:
say “There’s no suitable soil in which to plant anything here.”;
stop the action;

the nursery is suitable for planting.

check planting (this is the can’t plant non-seeds rule):
if the noun is not a tomato seed:
say “You can’t plant that.”;
stop the action;

purchasing is an action applying to one visible thing.

Understand “Buy [things]” as Purchasing.

carry out purchasing:
decrease the score by the price of the noun;
now the player has the noun;
say “You have [score] points.”.

storage is a room.
[/code]

You have no tomato fruits in storage, so the “at the time when the tomato sprouts” rule/phrase can’t find any to move to the nursery.

Hope this helps.

OF COURSE!!! I knew it was something like that. Thanks for all your help everyone. I think this is all I need for this section. THANKS! :slight_smile: