I'm having some trouble with my first choice tale

I'm not new to writing, but I'm a newcomer to anything remotely related to coding. As such, and after writing half of my text game in the common way, I find myself getting into some technical difficulties trying to transcrypt it into the real thing. I'll explain myself with the following example:

You find yourself lying on the stone floor of what appears to be a cell. You can't identify the source of the dim, red light that makes your shadow flicker and your spine chill. It's nevertheless better than absolute darkness. The air is stagnant and cold. At first glance, there's nothing here besides the door in front of you, and an small hole on its lower part. Just enough to squeeze through.
What do you do?

[[Search the room]](d agger)
[[Get through the hole]](l eavefirst)

There is a dagger sticking from a crack in the wall just behind you. You can't find anything else, so you decide to get through the hole.
Something is not right here. You decide that you will not stay here any longer.

Now, there would be some common text ahead from here, but we would get to a point where the game should know whether you possess the item or not. From what I've read in the documentation I think I should use that value known as "boolean", but I have no idea about how to implement it.
Should the "[[dagger]]" part start its text with the line "@set dagger? If this is the case, then the "[[leavefirst]]" would need a "@unset dagger"?

But that is not all. How do I make this follow the subsequent options? Should I start the related sections with something like "if @dagger = true then show this text. If dagger = false show another".

I know this is pretty basic, but I'm extremely noob. Also, english is not my first language, so forgive any confusions this fact may lead to.

Okay, a little lecture here - booleans are variables that are either true or false. You set them and unset them like this.

@set myFlag
@set not myFlag

To use them in some sort of code (where things come up if they are true or false) it works like this.

The wizard looks at you, judging it you are worthy.
{if worthyFlg: Yes, you are worthy.}
{else: Get out of here, you poser!}

Hope that helps!

Just to give you another, quite possibly worse, option than the excellent answer given by Bluevoss.

Given the bit of logic you have here you might be able to use @seen to know if the player has the dagger or not and avoid the use of booleans altogether.

If they choose to search the room they have seen the dagger. Either you will give the player the dagger automatically or they will take dagger and see a section/passage that reacts to that action.

Now you can test whether they saw the appropriate section/passage and know they have the dagger when the story plot needs to know if they have it or not.

The above assumes you don't allow them to drop dagger, or similar. Blocking the player from making bad decisions like that is usually a good idea unless you want to make things super hard for advanced players.

I agree with Jfox - "seen" is a much more elegant way to do this. I use it myself when I want to make sure I don't show the same room twice. On the other hand, Booleans can give the player a little more control. It all comes down the circumstances.

For example, I wrote a game that involved getting randomly placed into six situations from a specific point. One you finished that one path, you'd go back and reroll another. If you duplicated the random choice (ie you'd done it already) you would go to an end path to exit you from this circumstance. However, it was possible to "reenter" this code if you came this way again. In that case, booleans worked better (because I could control them).

I've never been sure how to "unseen" something.

Log in to post a reply.