Newbie to Inform not to If.

This is my sample If creation so far, I have far more in another program but really would like to get it all ported over to inform. Problem is I cannot seem to get my rule right so it understands what I am trying to do.

I want to be able to move down from the clearing to insie the hole
but the player must have the flashlight and it must be lit otherwise that direction is not allowed in that room.

[spoiler]“Clearing”

“You are in a small clearing beside a fairly large hole in the ground. The forrest extends ito the north, south, east and west. A flashlight is on the ground beside the hole.”

North from the Clearing there is a forrest. South from the Clearing there is a forrest. East from the Clearing there is a forrest.
West from the Clearing there is a forrest.

The hole is down from Clearing.
There is a flashlight on the ground . It is unlit

This is the enter the hole with an unlit flashlight rule:
before going down.
if the player carries the flashlight.
if the flashlight is unlit say “it’s too dark in there. Shouldn’t you turn on the flashlight”

“Inside the hole”

“This is the inside of the hole you just entered. It slopes downward, and is large enough you can stand up comfortably and walk in.”[/spoiler]

Thanks in advance Larry

I don’t think you need to create a new rule here at all. You could use either a BEFORE or INSTEAD rule. (see section 7.2 & 7.3 of “Writing with Inform”)
Also ‘forrest’ is spelt with only 1 “r” - forest.

R2T1 is correct, but you are creating a new rule. You don’t need to write it out so formally.

Before going down in clearing (this is the need a lit flashlight to go in the hole rule): if the player does not carry flashlight: say "That hole looks dark. I'm not going down there without some kind of light." instead; if the player carries flashlight: if flashlight is not switched on: say "It's pretty dark down there. Good thing I have this flashlight!"; try switching on flashlight.

What this will do is prevent the player from going down when they are in clearing without the flashlight (note the “instead” will stop the action), or if they are carrying the flashlight, will turn it on automatically for them and continue since there is no “instead” interrupting that section of the if-statement.

Thanks to both of you for your help.

So how do I know if I’m using the built in rules, or if I’m trying to make my own rule without knowing it?

Larry

You can use the built in rules whenever you want to stop a specific action or have something special occur after a specific action, with whatever conditions you want.

Before rules are good for stopping actions you don’t want to have happen.

Instead of rules are good for special cases of actions that usually do nothing (if nothing in your game is pushable but a maroon button, you do ‘instead of pushing the maroon button’)

After and report rules are good for attaching consequences to actions that you still want to process normally (like if you want a bucket of ice to dump on someone after moving into a new room, but you still want them to end up in that room). Moving, taking, and dropping have ‘built-in’ after rules that won’t fire if you have an after rule, so it’s often better to use a report rule in those cases.

I’ve never had to name a rule; I think that’s most useful if you have several rules and care about the order they fire in.

Even if you don’t use the rule names to reorder them (which is the case you’re thinking about), they can be useful in keeping track of your code. For instance, the rules will show under their names in the Index. Also, when you run your program, you can type “RULES” in and it’ll give a list of every rule that runs, which can be useful for debugging; it’s easier to figure out what’s happening if you’ve named your own rules. (I’m sure you know this–this is just an explanation for the original poster.)

Actually, I didn’t know that. That’s really helpful!

Naming your new rules is good when building a system with a lot of complicated parts, especially when you encounter an error where something in the game goes wrong that isn’t a parser error and you can’t figure out why or where it’s happening. You use the RULES debug command which will list every rule Inform considers as it processes. Often the last one that fires is your problem, or you can see where rules are happening in the wrong order. Or just “oops, that one vague rule I wrote and forgot about that prevents blue things from being thrown down the well is keeping me from dropping this sapphire…”

This works without naming rules, but without a name, the huge rule list will display default identical names. “Check taking the ember… Check taking the ember…” If you name them it uses the names “The can’t take the ember cause it’s hot rule… The can’t take the ember without gloves rule…”

And I just remembered - if you want to temporarily or selectively disable a rule, it’s a lot easier when it’s named.

The can't take things that are blue rule does nothing when the noun is the sapphire.

It’s not really an issue. You’re making a new rule every time you say “Before/Check/Carry Out/Report/After/Instead”. These are becoming new rules going into “rulebooks” which are automatically maintained by Inform. These rulebooks have a lot of built-in rules that handle a lot of standard stuff like “you can’t pick up a container that you’re inside of.”

For all practical purposes, these become “built-in” rules for your specific world in your specific game. All the built-in rules can be overridden or modified, you just need to find out what the name of the rule is, and this is most easily done via the Index in the IDE.