Syntax for interacting with properties


I’m completely new to I7 and am having a heck of a time figuring out what the right syntax is to interact with properties on a thing.

The mechanic I’m trying to implement is a “danger factor” for a room. What I can’t seem to get, is the right wording for querying and interacting with that number.

My story looks like this so far:

A dangometer is a kind of device. The description of the dangometer is "A thin strip of plastic containing an antenna and a small digital display. The display, so you're told, indicates how dangerous your surroundings are. 0 is 'completely safe' and 10 is 'imminent death'." The dangometer is always switched on.

A room has a number called danger level. The danger level of a room is usually 0.

Definition: A room is safe if its danger level is 0.
Definition: A room is dangerous if its danger level is 1 or more.
Definition: A room is deadly if its danger level is 9 or more.
Every turn while the player is in a dangerous room:
		Increase danger level by 1.
Every turn (this is the dangometer rule):
	If player carries a dangometer, and the dangometer is switched on:
		say "The dangometer in your pocket beeps - the danger level of this room is now [danger level of this room]"

The dungeon is a room. The dungeon has danger level 0.

The feeding chamber is south of the dungeon. The dungeon has danger level 1.

As written above, entering second room results in a runtime error:

*** Run-time problem P31: Attempt to use a property of the 'nothing' non-object: property danger level

I’ve tried a couple of different ways of rewriting the rules, but none of them lead to the desired behavior. It looks like I haven’t quite mumbled the right incantation to refer to the danger level of the room the player is currently in.

What is the “right” way to access this danger level property from within rules and Say blocks?

I think where you have “[danger level of this room]” it should be “[danger level of the location]”; “the location” is the room that the player is in. I’m a bit surprised that “this room” compiled. (You should also have a period at the end of the sentence to make sure that the line breaks print properly.)

And it looks to me as though this:

Every turn while the player is in a dangerous room: Increase danger level by 1.

should be

Every turn while the location is a dangerous room: Increase danger level of the location by 1.

The first change is a bit subtle; if the player is in a container or on a supporter in a room, they don’t count as “in” the room. But for the second, in most contexts you need to specify the danger level of something. This is a general thing to remember–if danger level is a property of rooms, when you refer to it you probably want to be referring to the danger level of a specific room.

Also “the dangometer is switched on” generally has the same result as “a dangometer is switched on” (I think in the most recent version of Inform it might not even compile). In this case you want “If the player carries a switched on dangometer.”

Also also I noticed that you declare the danger level of the dungeon two different places. I guess Inform treats the second one as overriding the first? I haven’t tested this code for myself so I don’t know how it’s working.

Couple of horrible typos in there :slight_smile:

But in any case, thank you! The words “the location” were the ones I couldn’t figure out.