Like the title says, players can pick up flowers from a field and I want them to stay where they drop but to wilt and then after 10 turns for them to disappear.
I’ve tried to figure it out but I have been defeated. I’m hoping someone can help.
Room 1 is a room. "The Sun Room. North is Room 2."
Room 2 is north of Room 1. "The Shadow Room. East is Room 3."
Room 3 is east of Room 2. "The Void Hall."
The fresh flowers are a thing in Room 1.
The description of the fresh flowers is "Vibrant and alive."
A wilted flower is a kind of thing.
A wilted flower has a number called time remaining.
The flower pool is a container. It is off-stage.
50 wilted flowers are in the flower pool.
Every turn (this is the flower wilting rule):
if the fresh flowers are in Room 2 or the fresh flowers are in Room 3:
if the player is not in the location of the fresh flowers:
let the target room be the location of the fresh flowers;
move the fresh flowers to Room 1;
say "The flowers you left behind wither instantly! (Fresh ones appear in Room 1).";
let new waste be a random wilted flower in the flower pool;
if new waste is a thing:
move new waste to the target room;
now the time remaining of new waste is 10.
Every turn (this is the decay rule):
repeat with item running through on-stage wilted flowers:
decrement the time remaining of the item;
if the time remaining of the item is at most 0:
say "A [item] crumbles into dust.";
move the item to the flower pool.
Every turn (this is the reset rule):
if the fresh flowers are not enclosed by the player:
if the fresh flowers are not in Room 1 and the fresh flowers are not in Room 2 and the fresh flowers are not in Room 3:
move the fresh flowers to Room 1;
say "The flowers return to Room 1.".
I’m not sure what all the details are of your desired behavior. Are picked flowers supposed to remain fresh for an arbitrary number of turns so long as the player remains in Room 1? Seems like it’d be easier to just decrement turns remaining for all picked flowers and not worry about location.
As a simplifying measure, I suggest making the fresh flowers scenery, which prevents the player from ever really taking them, thus you’ll never need to move them around. Then (hastily written untested example code):
A flower is a kind of thing.
A flower has a number called turns remaining.
The printed name of a flower is usually "wilted flowers".
Understand "wilted", "flower" as a flower.
There are 50 flowers.
Flower-picking is an action applying to nothing.
Flower-picking has a flower called the bouquet.
Instead of taking the fresh flowers: try flower-picking.
Check flower-picking:
now the bouquet is is a random off-stage flower;
if the bouquet is nothing, instead say "** oops, all out of flowers.";
Carry out flower-picking:
now the player carries the bouquet;
now the turns remaining of the bouquet is 10;
Report flower-picking: say "[We] [pick] some flowers."
Every turn:
repeat with f running through on-stage flowers begin;
decrement the turns remaining of f;
if the turns remaining of f < 1 begin;
now f is nowhere;
end if;
end repeat;
[ omitted: setting up some variables to track whether the player has *seen* flowers crumble and so there should be output about it and actually generating that output ]
Thank you for your replay, and sorry for not being more clear.
My puzzle required the player to deliver some flowers to a person to forward part of a puzzle. As a result the flowers needed to stay “fresh” indefinitely if the player enclosed them but I think I like your idea better of the player having to hustle with them as all flowers will start to wilt as soon as they are picked.
Another detail I could have included is that the flowers come from an area full of them so I wanted to make it possible to pick more than 1 set of flowers while also always having flowers available to pick. I also didn’t want picked flowers to remain in their original state indefinitely.
Anyway. I adjusted the code a little. Everything works okay but I know I must have an error because when I am in the garden I get different responses when I drop flower, drop flower_s_ if the player does or does not contain the flowers.
Section 1 - Setup
The Garden is a room. "A beautiful garden bursting with colourful blooms."
the hall is a room.
the hall is north of the garden.
The flowers are scenery in the Garden. The description is "A patch of vibrant, fresh flowers.".
understand "flower" as the flowers.
A pickedflower is a kind of thing.
A pickedflower has a number called turns remaining.
The printed name of a pickedflower is usually "purple flowers".
the indefinite article of pickedflower is "a beautiful bunch of".
Understand "wilted" or "flowers" as a pickedflower.
There are 50 pickedflowers.
Section 2 - The Actions
Flowerpicking is an action applying to nothing.
The current bouquet is a pickedflower that varies.
Instead of taking the flowers:
if the player encloses the current bouquet:
say "You already have a lovely bunch of flowers.";
else:
try flowerpicking.
Carry out flowerpicking:
move the current bouquet to the player;
now the turns remaining of the current bouquet is 10.
Check flowerpicking:
if there is no off-stage pickedflower:
end the story finally saying "You have picked all the flowers. It looks like you're as the kids say 'cooked'.";
now the current bouquet is a random off-stage pickedflower.
Report flowerpicking:
say "[We] [pick] a flower."
Section 3 - Time Passing
the wiltedflowers are an object.
the wiltedflowers are nowhere.
the printed name of wiltedflowers is "wilted flowers".
the indefinite article of wiltedflowers is "some".
Every turn:
repeat with f running through pickedflowers:
if f is not off-stage:
decrease the turns remaining of f by 1;
if the turns remaining of f < 1:
if the player encloses f:
say "(You have been carrying the [f] too long and they have wilted.)";
now f is off-stage;
move the wiltedflowers to the player;
else:
now f is off-stage.
understand "flower" as the flowers.
[...]
Understand "wilted" or "flowers" as a pickedflower.
“flowers” is a default understanding for flowers and anything beginning “pickedflo” (9-character default limit) is a default understanding for pickedflower. But as things stand “flower” can refer only to the fresh flowers.
Try this for disambiguating the flowers:
does the player mean dropping the flowers: it is unlikely.
Thank you. I’ve never seen syntax like this before. I replaced
Understand "wilted" or "flowers" as a pickedflower.
with
does the player mean dropping the flowers: it is unlikely.?
Which was probably not what you meant, but seemed like a disambiguation spot.
Something that may make a difference is that I called the fresh flowers just flowers, which was a bad idea, and have changed them again to freshflowers. I didn’t seem to make any progress with it there. I appreciate your help.
Section 1 - Setup
The Garden is a room. "A beautiful garden bursting with colourful blooms."
the hall is a room.
the hall is north of the garden.
The freshflowers are scenery in the Garden. The description is "A patch of vibrant, fresh flowers.".
understand "flower" as the freshflowers.
A pickedflower is a kind of thing.
A pickedflower has a number called turns remaining.
The printed name of a pickedflower is usually "purple flowers".
the indefinite article of pickedflower is "a beautiful bunch of".
Understand "wilted" or "flowers" as a pickedflower.
There are 50 pickedflowers.
Section 2 - The Actions
Flowerpicking is an action applying to nothing.
The current bouquet is a pickedflower that varies.
Instead of taking the freshflowers:
if the player encloses the current bouquet:
say "You already have a lovely bunch of flowers.";
else:
try flowerpicking.
Carry out flowerpicking:
move the current bouquet to the player;
now the turns remaining of the current bouquet is 10.
Check flowerpicking:
if there is no off-stage pickedflower:
end the story finally saying "You have picked all the flowers. It looks like you're as the kids say 'cooked'.";
now the current bouquet is a random off-stage pickedflower.
Report flowerpicking:
say "[We] [pick] a flower."
Section 3 - Time Passing
the wiltedflowers are an object.
the wiltedflowers are nowhere.
the printed name of wiltedflowers is "wilted flowers".
the indefinite article of wiltedflowers is "some".
Every turn:
repeat with f running through pickedflowers:
if f is not off-stage:
decrease the turns remaining of f by 1;
if the turns remaining of f < 1:
if the player encloses f:
say "(You have been carrying the [f] too long and they have wilted.)";
now f is off-stage;
move the wiltedflowers to the player;
else:
now f is off-stage.
It sounds like it would be simpler not to deal with multiple flower objects at all.
Some picked flowers are a portable thing.
The picked flowers have a number called countdown.
Some fresh flowers are fixed in place in the Garden. "There are fresh flowers here."
Instead of taking the fresh flowers:
say "You pluck some flowers. Better hurry!";
now the player carries the picked flowers;
now the countdown of the picked flowers is 5.
Instead of dropping the picked flowers:
say "The flowers scatter and are lost.";
now the picked flowers are nowhere.
Every turn when the picked flowers are on-stage:
decrement the countdown of the picked flowers;
if the countdown of the picked flowers is less than one:
say "The flowers wilt and are lost.";
now the picked flowers are nowhere.