[I7] combinung multiple if-clauses

Hello!

I have a problem implementing multiple if-clauses in one big condition.

The passage in pseudo-code that I want to get to work:

when scene “battle” begins {
say “The bandit attacks you.”
if player carries armor {
say “Your armor protects you.”
if player carries sword {
say “You kill the bandit.”
}
else {
say “You can’t defend yourself without a weapon and get killed.”
end game in death
}
}
else {
say "Without armor the bandit easily kills you.
end game in death
}
}
Since Inform 7 doesn’t have “brackets”, I quite don’t know how to implement that. I tried scenes (battle scene, deathbyarmor scene and deathbysword scene) but it didn’t work. Maybe it COULD work, but it would be inconvenient, if there would be an easier way to do it.

Thank you in advance and I’m happy to be a part of this forum now!

Best regards,
josaaku

You can do this with careful indentation.

When battle begins:
	say "The bandit attacks you.";
	if the player carries the armor:
		say "Your armor protects you.";
		if the player carries the sword:
			say "You kill the bandit.";
		else:
			end the story saying "But you can't defend yourself without a weapon and get killed.";			
	else :
		end the story saying "Without armor the bandit easily kills you."		

Thank you, it works perfectly!

I thought indentations and line breaks were just for visibility in the code, guess I was wrong.

Kind regards,
josaaku

There is another format, but I find it confusing. In chapter 11:7:

But be aware that the begin/end format doesn’t work with “else” clauses.