Needing help in coding a dream (and some other minor stuff)

Hey, I’d like to know how to get the player to be able to sleep (and dream). Here is what I’d like to happen.

The player is in a room which is currently locked. The key to unlock the door is in his dreams (Which I have made separate rooms for). The player can only sleep when he:

a) is lying on a bed
b) has taken at least 1 sleeping pill

For the sleeping pills, there will be 2 hidden in the room. When the player finds and eats one, his dream will last for 10 turns and he will then wake up on the bed again. When he eats the second pill, he sleeps for <an undecided amount that is more than 10> turns. When he goes to sleep, he will loose everything in his inventory and retain it when he wakes up. In his dreams, he can only retain the key. Everything has to be reset (except the key) when he wakes up. Seeing I have had no experience in this whatsoever, I also need to accomplish these:

  1. A prologue (Doing a few actions will trigger the title to appear (Something like the begining of Child’s Play))

  2. Transition text (When moving to another room, it reads “You wade through the water” before moving to the next room (Only applicable to certain rooms))

  3. Having rooms adjacent to the one you were locked in. (Enterable containers)

  4. Possibly the talk engine in Photopia

  5. Being able to turn something upside down

That’s a pretty complex problem, but there are a couple of good examples in the documentation. “Space Patrol” (example 158 in my edition) is a simpler one, which uses scenes to create a commercial break. There’s also a more detailed one called “Pine” that contains a flashback. I think “Pine 3” is the best one to look at - example number 165. The key is to use a location variable and a possessions container to preserve the player’s previous state, then move the player to the dream location and start the dream scene.

Some relevant bits of the code:

Poverty flashback is a recurring scene. Poverty flashback begins when family circumstances is current. When poverty flashback begins: strip the player; move the player to the Woodcutter's Shack.

Saved location is a room that varies. Locker is a container. Wardrobe is a container. To strip the player: now every thing carried by the player is in the locker; now every thing worn by the player is in the wardrobe; now saved location is location. To restore the player: now every thing carried by the player is in the location; now every thing in the locker is carried by the player; now every thing in the wardrobe is worn by the player; move the player to saved location.

Something like this?

[code]The Living Room is a room.

The Dining Room is north of the Living Room.

Before going north in the Living room, say “You stride ceremoniously through the archway.”
[/code]

But you need to watch out if there are possible obstacles - you don’t want that message to appear if something else (like a locked door) is going to prevent going.

I’m not sure what you mean by this. Like a cage?

How about this?

[code]An inversion is a kind of value. The inversions are right-side-up and upside-down.
The hourglass has an inversion.

Understand “invert [something touchable]” as turning.
Understand “turn [something touchable] over” as turning.

Instead of turning the hourglass:
If the inversion of the hourglass is right-side-up:
Now the inversion of the hourglass is upside-down;
Otherwise:
Now the inversion of the hourglass is right-side-up;
Say “You turn the hourglass over. Now it is [the inversion of the hourglass].”[/code]

I usually find this sort of thing is done better by making the actual message attach itself to a ‘kind of door’ that is suitable for that purpose.

[code]A water-path is a kind of door. A water-path is usually open, not openable, unlocked, not lockable, privately-named, scenery.

Before going through a water-path:
say “you wade through the water.”

One Side Of The Puddle is a room. A water-path called water1 is east of One Side Of The Puddle. Other Side Of The Puddle is east of water1.[/code]

Granted, there are probably better ways to do this, especially if you need to actually go through a real door and still get the message ( a quick thought would be ‘before going to a room while in a region’, or something similar ), but this seems to be the simplest, and a variant on a method I’m using for a similar effect.

Edit: Modified a statement to read how I initially meant it to appear.

Edit, part 2: here’s an example of using a by-region method:

[code]Water-filled Locations is a region.

Basement is a room. Cellar is north of Basement. Foreboding Stairs is west of Basement. Basement and Cellar are in Water-filled Locations.

Before going a direction while in Water-filled Locations:
if going to a room in Water-filled Locations:
say “You wade through the water.”[/code]

One advantage of this method is that it only works if both the room you’re in now and the destination are within the region-in-question, and you could easily use a similar ‘before’ statement to make a slightly different message appear when the current location is water-filled, but the destination is dry land ( and vice versa ).

Thanks for the help. The adjacent rooms would usually take the syntax

enter roomA3

I doubt Inform 7 has the verb enter.

It does, but it’s generally used for going into containers or doors. You can fiddle with it so that it allows you to go to adjacent rooms, though:

[code]After deciding the scope of the player while entering:
repeat with dummyroom running through all rooms:
place dummyroom in scope.
[This means that it’ll accept “Enter kitchen” if kitchen is the name of a room; otherwise it’d tell you that you can’t see the kitchen.]

Instead of entering a room (called destination):
if the destination is adjacent to the location: [the location is the room where the player is; destination is a dummy variable]
let passway be the best route from the location to the destination; [this just tells you which direction the destination is]
if passway is a direction:
try going passway; [if you can’t go into the next room, this’ll give you the usual errors]
otherwise:
say “You can’t get there from here.”; [You may not even need this, since if the rooms are adjacent, the best route should be a direction, but better safe than sorry]
otherwise:
say “That’s not close enough to go to from here.” [if you tried entering a nonadjacent room]
[/code]

Note that (experienced) IF players usually navigate by compass directions, though allowing “enter [roomname]” is nice. Note also that this doesn’t allow “go to [roomname],” which you probably want to allow if you’re allowing “enter [roomname].” There are some extensions that implement “go to [roomname]” one way or another.

Thanks for the help. Now I need to get the sleeping pills working. My thought is that the 1st sleeping pill is easier to find than the second one.

EDIT: I also need help for the prologue and also does this work?

Instead of going south of CrowdedArea say "You wouldn't want to go back there"

You want to say “going south in” or perhaps “going south from” – see section 7.13 of the documentation for the difference. Basically, “from” only works if there is actually a room south of CrowdedArea.

I can’t really start until I get a prologue starting with intro-text. Then some actions and the title shows up.

I started to code this, but then I had to do something else. Here are some notes:

State, chapter 4.6:
A player can be either asleep or awake. A player is usually awake.

Scene, chapter 10:
The Dream is a scene. The Dream begins when the player is asleep. The Dream ends when the player has been asleep for ten turns.

Stuff to do:
Check for both conditions and if they’re true, the player is asleep.
Convert the player to awake again on the 10th turn of the dream.
Create the series of rooms belonging to the dream and just move the player to them and back out of them as the dream begins and ends.

It’s a start. Sorry I’ve gotta go…

Thanks. Gonna start when I find out how to do a prologue and also make a raffle item (only obtainable when the player wins the raffle).

Hi,

take a look at example 367 “Bikini Atoll” (Chapter 17.35 in the documentation) to see how to do such a prologue.

– Michael

For the raffle, are you trying to do randomness?

Of course for realism, you could make the raffler a person, assign a number to the player’s ticket and a number to the raffler’s ticket, and then check if they match, and so forth – though you’d probably want to make the span small to make winning practical.

Hmm, Raffler is planned to be a person. The number you take will be 696 and the number the raffler takes out is 969. The player just turns it upside down to claim the item. If the player didn’t, some other guy gets it and the crowd clears… Getting the robbers to kill you.

I still have to know how to make sand dispensers (to power the raffled device to teleport the player) and a beach (as a puzzle to collect sand). How do I only enable the undo function if the player is holding the prize?

EDIT:

Thanks, that works. But how would I go about making some introductary text BEFORE starting at the room?

EDIT2: Tried this:

[code]An inversion is a kind of value. The inversions are right-side-up and upside-down. Inversion is usually right-side-up.
The hourglass has an inversion.

Understand “invert [something touchable]” as turning.
Understand “turn [something touchable] upside-down” as turning.

Instead of turning the hourglass:
If the inversion of the hourglass is right-side-up:
Now the inversion of the hourglass is upside-down;
Otherwise:
Now the inversion of the hourglass is right-side-up;
Say “You turn the hourglass over. Now it is [the inversion of the hourglass].”

After turning the hourglass for the first time: say “As you turn the hourglass around, the sand inside it slowly disappears and Everything flashes white before your eyes [banner text]”; move the player to the Cell

Rule for printing the banner text when the hourglass is not upside-down : do nothing. [/code]

I coded in the rooms already, but when I turned the hourglass upside down the banner text did not show up. I tried replacing Rule for printing the banner text when the hourglass is not upside-down : do nothing.
with Rule for printing the banner text when the hourglass is right-side-up : do nothing. \

But to no avail… (It didn’t work)

When play begins: … (chapter 9.1 in the manual)

You have turning the hourglass in an instead rule, which stops the action and the game never gets to the after rule. You could add the after rule inside the instead rule:

Instead of turning the hourglass: If the inversion of the hourglass is right-side-up: Now the inversion of the hourglass is upside-down; Otherwise: Now the inversion of the hourglass is right-side-up; Say "You turn the hourglass over. Now it is [the inversion of the hourglass]."; if the cell is unvisited: say "As you turn the hourglass around, the sand inside it slowly disappears and Everything flashes white before your eyes [banner text]"; move the player to the Cell.

Now to have a machine that put sand it the hourglass. When there is sand in the hourglass, it will teleport you. if not, It doesn’t do anything. Also you use it multiple times.

And uh, can anyone proof-read this?
[rant]After picking on a group of what looks like gangsters, they start chasing you. You notice a tattoo on one of their forearms as the unmistakeable logo of the Rediar Thieves, known for the recent raiding of Area 51 and their aquiration of a teleportation device. Since you got a headstart when you ran, they simply teleported in front of you. You dodge and run towards a crowd in the alley. Even though the teleporter takes time to recharge, you are no longer safe. It will only be a matter if time until they get you for good.[/rant]

EDIT: Trying to turn the raffle ticket over.

Instead of turning the Raffle Ticket: If the inversion of the Raffle Ticket is right-side-up. Now the inversion of the Raffle Ticket is upside-down; Say "You turn the Raffle Ticket around. It now reads 696."; Otherwise: Now the inversion of the Raffle Ticket is right-side-up; Say "You turn the Raffle Ticket around. It now reads 969.";

Gives the error

I probably made a dumb mistake there, I can’t seem to find it even.

The second line should end in a colon, not in a period.

I can fix a couple minor errors:

After picking on a group of what looks like gangsters, they start chasing you. You notice a tattoo on one of their forearms as the unmistakable logo of the Rediar Thieves, known for the recent raiding of Area 51 and their acquisition of a teleportation device. Since you got a head start when you ran, they simply teleported in front of you. You dodge and run towards a crowd in the alley. Even though the teleporter takes time to recharge, you are no longer safe. It will only be a matter if time until they get you for good.

Another change to consider:

“After picking on…” Grammatically, the subject “picking on” is “they,” so if “they” is supposed to refer to the gangsters, you are saying they were picking on themselves. “After you pick on…” might be what you’re trying to say, but I’m not sure.