Value doesn't default as "True"

This started after adding in the “Modified Exit” extension and adding a bit to the source, but here’s the gist of it:

[rant][code]truthiness is a truth state that varies [default is “false”]

bloodiness is a truth state that varies [default is “true”]

[—]

There is a room called Messy Bedroom. “You’re in a messy bedroom. There is a large window, leading out to a parking lot a floor below, with a bed under it that isn’t made. Next to the bed is a dresser covered with makeup supplies on one side, and a row of books and papers on the other. Adjacent to the window is a wall with frameless paintings and a door. Across from the window is a closet with sliding mirror-doors. Next to the closet, across from the door, is a computer desk, which blocks part of the closet. There is a desktop on it, and an extra keyboard. The cord of the extra keyboard is sticking out of the mirror.”

The blood stain is an object in the Messy Bedroom. The blood stain is fixed in place. Understand “bloodstain” as blood stain. “[if bloodiness is true]The blood stain stares at you, accusingly, from across the glass.[otherwise if bloodiness is false]The sliding doors are tucked behind the desk, hiding the blood stain and your missing figure completely.[end if]”. The description of the blood stain is “[if bloodiness is false]The sliding doors are tucked behind the desk, hiding the blood stain and your missing figure completely.[otherwise If we have examined blood stain and truthiness is false]The stain is a deep red color, having sunk into the carpet. There is no way to reach it.[otherwise if we have examined blood stain and truthiness is true]The stain is a deep red color, having sunk into the carpet. There is no way you can reach it on this side of the glass.[otherwise]You move your head around, trying to reveal the illusion – the paint on the glass, or whatever trick it is – but it doesn’t work. You stop and stare at the blood stain, and an overwhelming sense of waryness and wrongness seeps into you. Man, reflections just should not do that on their own.[end if]”

[----]

The Closet is an enterable, openable, closed container in the Messy Bedroom. It is scenery. It is lit. Understand “door” and “sliding door” and “closet door” and “sliding closet door” as the Closet. The description is “[if the Closet is open]The sliding doors are tucked behind the desk, hiding the blood stain and your missing figure completely.[otherwise]Across from the window is a closet with sliding mirror-doors. You step forward and stare into the mirror on your closet, and see nothing but the cloudy sky through your window where your head should be.[end if]”

After opening The Closet, now bloodiness is false.

After closing The Closet, now bloodiness is true.
[/code]

[/rant]

So, any suggestions on how to fix this? Should I just, as illogical as this is, switch the truth states? What’s the likelihood this is affecting “truthiness”, too?

EDIT: Whoops – forgot to put in the closet and its rules!

You can just declare the initial value of your variables:

[code]truthiness is a truth state that varies. truthiness is false.

bloodiness is a truth state that varies. bloodiness is true.[/code]

In fact, you can just declare them as initial values, and Inform will figure out that they must be truth states:

truthiness is initially false. bloodiness is initially true.

For what it’s worth, if you go to the Index in the IDE and look at the Kinds tab, it will list the default value for every kind–you will see there that the default value for truth state is false, so if you don’t initially declare the value of a truth state variable, it will be set to false.

Okay, that first wording seems to have worked. I’ll fiddle with it some more if it pops up again. Thanks!

Hi All,

Also new to Inform and this way of programming. Below is a snippet of code that I’m having some trouble with:

I’ve taken a quick look around and I think it may not be possible to switch boolean/truth state variables inside a conditional statement (and inform considers “after” as a conditional). Is that true? If so, how do you deal with a situation like this?

If that’s not true, am I writing something wrong? Below is the error I’m getting from Inform 7 (mac):

[rant]Problem. I am reading the sentence ‘now ExampleVariable is false’ as saying that a thing called ‘now ExampleVariable’ is a value, but this makes no sense to me - it would be like saying ‘the chair is 10’.
Because of this problem, the source could not be translated into a working game. (Correct the source text to remove the difficulty and click on Go once again.)[/rant]

Any help would be really appreciated!
Chris

Give this a try:

[code]Test Room is a room. “This is the test room. ExampleVariable is [examplevariable].”

ExampleVariable is a truth state that varies. [truth states default to “false” unless you initially set them true.]

after looking when examplevariable is false:
say “ExampleVariable is false.”; [you need a semicolon here, you had a period]
now ExampleVariable is true;

after looking when examplevariable is true:
say “ExampleVariable is true.”;
now ExampleVariable is false.

Test me with “look/look”.[/code]

Hi Hanon,

That’s brilliant, thanks for your help! I’ve also figured out another problem in my code that wasn’t in this simple example - the semi-colon issue you raised. Thanks again!

Chris

My tip is to always use semicolons in rules, and to separate all rules by blank lines. Only use periods for declarations.