Creating items for specific instances like keys


#1

I’m coding my first game using this format, so I’d really appreciate any help I could get from all of you! I’m looking to try and place in items like a key to open a specific door. What I’m wondering is how to set that you have the key after you get it, and how to set the door to open when you have the key, but deny access if you don’t.

Should I be using “if” to do this like if key=true or something? I’m totally lost but I want to do this with a lot of objects, such as a raft you can find to get across a river if you’ve found it, but if not you have to go around or something.

Any ideas? Thanks in advance!


#2

The easiest way to handle objects is with true/false booleans.

First, make a key (default set to false): *create key false

Then switch it to true when a player finds the key: *set key true

When you want to check for the key, you’ll just use an *if statement:

*if key
    You use the key to unlock the door.
*if key = false
   The door is locked.

#3

Create a variable called key1 (or be more imaginative: Crimson_key)
Set it to false.
When the player finds the key, set it to true. When the player reaches the door, use an if statement.

*create crimson_key false

You find a crimson key!
*set crimson_key true

You find a locked door. What will you do?
*choice
*if (crimson_key) #Use the crimson key.
It opens!
#Give up
You walk away disappointed.

Edit: ninja’d by CS_Closet!


#4

So for

*create key false

should that be at the beginning of startup? Or can I put those in the beginning of the scene they are used in. Also items are transferable from scene to scene, correct?

Sorry for the beginner questions ><"


#5

All of your *create stats should be at the beginning of startup.txt, right after your scenes. Anything made with the *create command will stick through the entire game so you don’t have to worry about that. It’s only the stats created with the *temp command that will disappear after you leave the scene.