Combat System?

I’m trying to understand the basics of the language here and I’m guessing that I’m using the wrong punctuation for my If statement. I’m trying to learn how to construct a basic turn based combat system. I’m really not understanding how it is wrong at all because according to Inform7.com which I’m assuming is the official site, that should be correct. At least in terms of basic grammar.

[code]
A person has a number called max health.
A person has a number called present health.
A person can be hostile or docile.
A person is usually docile.
The max health of a person is usually 100.
The max health of the player is usually 100.
Definition: a person is dead if his present health is less than 1

Instead of attacking someone:
let the damage be a random number between 2 and 10;
say “You attack [the noun], causing [damage] points of damage!”;
decrease the present health of the noun by the damage;

If the present health of the noun is less then 0:
say “[the noun] is dead.”

The bedroom is a room

The Kitchen is west of the bedroom.

A Rat King is a man. The Rat King is in the Kitchen.[/code]

Don’t you want to decrease the present health, not the max health?

You also need to indent blocks of code to group them together, like in Python or Haskell.

And you will need a semicolon instead of a period at the end of this line:

decrease the max health of the noun by the damage

As things stand, the period ends the rule, so Inform thinks that the next bit is meant to start a new rule or phrase, and it doesn’t know what to do with a dangling if-phrase.

Also, “If the max health is less then 0” should be “if the max health of the noun is less than 0” (or present health).

Even with the modifications witch I will add to the main post, I still get the same error message with the if statement. Which doesn’t really tell me what the error actually is at all.

Problem. You wrote ‘If the present health of the noun is less then 0’ : but the punctuation here ‘:’ makes me think this should be a definition of a phrase and it doesn’t begin as it should, with either ‘To’ (e.g. ‘To flood the riverplain:’), ‘Definition:’, a name for a rule (e.g. ‘This is the devilishly cunning rule:’), ‘At’ plus a time (e.g. ‘At 11:12 PM:’ or ‘At the time when the clock chimes’) or the name of a rulebook, possibly followed by some description of the action or value to apply to (e.g. ‘Instead of taking something:’ or ‘Every turn:’).
See the manual: 19.3 > 19.3. New rules

Now you have an extra line break before the line, which works just like the period. So once again Inform thinks that “If the present health of the noun is less than 0” is starting a new rule, and it doesn’t understand it. (Also, it’s “than” not “then”; spelling is important here.)

You still may need to indent the code to make sure Inform knows where the if blocks begin an end, as well. So it should look like this:

Instead of attacking someone: let the damage be a random number between 2 and 10; say "You attack [the noun], causing [damage] points of damage!"; decrease the present health of the noun by the damage; If the present health of the noun is less than 0: say "[the noun] is dead."

(Sometimes, when things aren’t too complicated, Inform will understand what’s going on without indentation, but it’s still a good idea to do it–makes things easier to read and is good practice for when you need it.)

I think this should work, although I haven’t tested it–although you might want to make sure that you’re consistent about whether dead means health of less than 0 or health of less than 1.

(By the way, it would be better to post your new code in a new post rather than editing the original post–it makes the conversation easier to follow.)