If Statements (Starting a Scene)

Before opening the front door:
	if the player is clean AND the player is fullup:
		say "Something.";
	else if the player is clean OR the player is fullup:
		say "A second something.";
	else if the player is dirty AND the player is hungry:
		say "There is a question here? [line break]";
		if the player consents: 
			move the player to Kitchen;
		otherwise:
			move the player to Living Room.

Instead of saying, what would I have to type for a certain Scene to start if, for example, the player is clean AND the player is fullup? I’ve tried a few phrasings but none of them seem to work.

1 Like

First you would have to define when a scene is to begin–

CleanFull is a scene.  CleanFull begins when the player is clean and the player is fullup and cleanandfull is 1.

Just an example. You can have a binary number which is toggled by the ‘if the player consents’ clause, defined thus–

Cleanandfull is a number that varies.  Cleanandfull is 0.

Then, in your code above, say–

…
    if the player consents:
        now cleanandfull is 1;
        move the player to the Kitchen;
….

Then you can write a rule defining what is to happen when the scene begins–

When Cleanfull begins:
    say "....
…

I hope that this helps.

2 Likes

The recommended way to start a scene is to figure out what is the unique circumstance that should start it and write the condition to match.

My Scene starts when the player is clean and the player is fullup
and the player is in the kitchen.

Using separate variables only for the purpose of triggering scenes should be avoided unless there’s no clean way to write the condition otherwise.

(Speaking of clean, if you need to use a separate variable, a truth state (true/false) or a property would be a better choice than a number that only flips from 0 to 1 once.)

4 Likes

Fully agreed. I only suggested what has always worked for me, and I wasn’t aware of any other condition. I’ve never had trouble with it.

Since your scene transition is connected to an action (leaving the house) – do you want to have the front door and the outside of the house be a persistent part of the environment with a temporal scene, or is the act of asking to open the door (under correct conditions) supposed to whisk the player away to another environment without any of those action effects appearing?

Supposing a base game like this:

The Kitchen is a room.
The Entryway is north of the Kitchen.
A toast is in the Kitchen. Toast is edible.
The Porch is a room.
The front door is north of the Entryway and south of the Porch.
The front door is a door.

A person is either clean or dirty.
A person is either hungry or full.
The player is clean and hungry.

After eating a thing that is edible:
	say "Yum!";
	now the player is full.

Part of the condition could be the door being open, or it could be standing outside, or it could be passing the checks with a flag.

This is one method. It continues the action and the scene begins due to the action being complete.

Before opening the front door:
	if the player is dirty:
		say "Too dirty." instead;
	else if the player is hungry:
		say "Too hungry." instead.

Commute is a scene.
Commute begins when the player is clean and the player is full and the front door is open.
When Commute begins:
	say "Time to hit the road.".

>[8] n
(first opening the front door)

Porch
You can see a front door here.
Time to hit the road.

And this is another method. It interrupts the action and triggers the scene, which relocates the player.

A person is either staying or leaving.
The player is staying.
Before opening the front door:
	if the player is dirty:
		say "Too dirty." instead;
	else if the player is hungry:
		say "Too hungry." instead;
	else if the player is clean and the player is full:
		now the player is leaving instead.

Commute is a scene.
Commute begins when the player is leaving.
Your Car is a room.
When Commute begins:
	say "Time to hit the road.";
	now the player is in Your Car.

>[8] n
(first opening the front door)
Time to hit the road.

Your Car
>

3 Likes