Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Monday, March 11, 2019

Why continue?

Why continue?

So going back to my previous post, we see that the rule processing is as follows:

Rule processing diagram

Rule processing diagram

Now let's look at the after rule from my example story.

After going to The Employee Break Area:
    Now concealment of the player is none;
    Continue the action.

Here we are adding an additional rule to the built in action of going to. The going to action is a built in action that changes the room that the player is currently in.

Once the player successfully moves into a new room, the carry out rules in going to actually update the internal value that represents the players location and other variables. In addition any kind of "Actions" that happen when entering the room are triggered.

Once that's all completed any after rules are check to see if there is a match. IF there is, the after rule runs and the action is stopped. But we're already in the room, what possible action could be stopped? What is stopped is the report rule for the going to action which is where all of the say actions are located when moving into a new room. So basically you get no room description, your player has indeed moved into the room, but since we are stopping before the report rules, we'll get no room description.

Hence the reason we have Continue the action. within the after rule here. The instead and after stop the action should anything match, thus it is here we will use the Continue the action. commands the most. However, there might be times when we are in a rule that would continue but wish to stop the action from additional processing. For that we can use Stop the action. which will stop the action. Depending on how far we are in the processing, this might trigger an action to be marked as failing.

Saturday, March 9, 2019

Rule Processing

Rule Processing

In the last post I used an after rule and I wanted to spend the next few posts talking about rules since I've spent a bit of time on the subject.

Here's an example of using an after rule from the last post.

After going to The Employee Break Area:
    Now concealment of the player is none;
    Continue the action.

Rule processing follows a specific order for processing. The below graph shows the path that rule processing follows for each action.

Rule processing diagram

Rule processing diagram

From this you can see six main processing stages for each action.

  • Before - These are the rules processed before the action actually takes place. This would include things like setting up variables, checking if certain conditions exist, and so on.
  • Instead - These rules are exceptions to the case. Here you would enumerate one offs that would block the rule from succeeding. If an action matches an instead rule, the action stops being processed.
  • Check - These are the basic premise rules that constituent the actual action. In other words, the before rules sets things up, but should something in the before rules stop the action, then the action isn't ever really carried out. However the checking rules, you've committed to the action whether it succeeds or not.

Quick Example: Like let's say your action is rob a bank. If you aren't near a bank then you really can't commit to the action so there is no success or failure, but if you are near a bank but forgot your disguise, you can still commit to robbing the bank just with an unsuccessful outcome. So before rules might be are you near a bank? vs a check rule being did you bring a disguise?.

Also Note: During the check rules, it might be tempting to use something like say "Something, Something, Something". However, you must not say anything or change any values in the story during a check action. Doing so signals to Inform that the action has failed. So in order to indicate success, you must not say or change any values in a check rule.

  • Carry out - These are the rules that change all of the values within your game based on a success. Again if it was robbing a bank, then you'd want to give the bags of money to the player and setup an event that will happen in X turns when the police show up if they are still in the bank. However, you must not say anything during this phase, that is what the report rules will do.

Note: If you do use say actions within a carry out rule, you will break the try silently action. Which if you don't use try silently in your story, then well it honestly doesn't matter then.

  • After - These are actions that happen after the action has definitely happened. As you can see in my example, I update the concealment of the player after the going to another room action has already taken place. Do note that the after rules stop the action from reaching the report rules, just like the instead rules.

  • Report - This is the last phase of rule processing. Basically this is everything that will be said as the outcome of the action, UNLESS we are try silently the action. In that case, report rules will not be ran.

I will note one more thing before ending here for now. NPCs in your story have two additional phases in the rule processing that apply to them only. I'll cover that later.

See Also

For additional information about rules see Chapter 7 and Chapter 12 from the Writing Inform book.

Saturday, February 2, 2019

Data Types in Inform 7

Inform 7 stories are a collection of things. Your story is basically a telling of how those things interact with the player, what the outcome of certain actions on those things are, and so on. So starting from square one it's important to understand one of the early questions that gets asked when using Inform 7 for the first time. "What kinds of things can I put in my story?"

The kinds of things that you cna put into your story are "types". I'm going to run through the list of types in Inform 7, give a very brief description of what they're there for, and an example of it. Now you can find this same information at ifwiki.

Type Description Example
number Used for a number. X is a number that varies.
time Used for a time which is based in Inform time system.1 Deadline is a time that varies.
text Used for some text. An excuse is a time that varies.
thing Used for an object. 2 My favorite toy is a thing that varies.
person Used for a person. The current manager is a person that varies.
direction Used for a direction. The ocean currents are a direciton that varies.
room Used for a room. The best spot is a room that varies.
truth state Used for a boolean value. The light switch's boolean is a truth state that varies.
table-name Used for named tables. 3 The guru's answers are a table-name that varies.

There's also four other types that are worth mentioning, but you'll uses these type a lot less than the previously mentioned types.

Type Description Example
rulebook Used for rulebooks. 4 My secret plans are a rulebook that varies.
rule Used for rules. What works last time is a rule that varies.
text Used for text parsing. 5 My regex target is some text that varies.
stored action Used for actions. 6 An abetance is a stored action that varies.

If you've ever written, even a basic story, in Inform 7, most of the ones from the first table should seem familiar. Variables in Inform 7 can also be references to other objects within your story. Take for example the room type.

The storage shed is a room.  "Just a simple wooden shed.  It looks like whatever was once here has long since been taken."
The attached garage is room.  "An empty garage barren of anything interesting."

The attached garage is west of the storage shed.

The magic spot is a room that varies.  Now the magic spot is initially the attached garage.

In this pretty short and pointless story, we created two rooms and a reference to one of them called The magic spot. At the start The magic spot refers to The attached garage. However we can change that should something happen. Additionally, since it is magic, we could just pick up the player and plop them back to wherever The magic spot refers to, which also means that we could add rules to allow some magic incatation that moves The magic spot to whatever room the player is currently in. The that varies text is what makes the variable become a reference versus an actual instance. Note how the two rooms The storage shed and The attached garage lack the varies text and thus causes them to be actual instances of rooms that you can travel to.


  1. This is opposed to something like 7:30am we'd be used to, though 7:30am is valid but has no bearing on the real world's time, but whatever the time currently is in your story. Explaining the Inform time system will just have to be a post all of its own.

  2. An object in this sense is a subset of things that are considered "objects" in the Inform sense. A thing can be a door, container, device, or supporter. But not a backdrop or person.

  3. Named tables are great tools but can sometimes be difficult to properly add to your story. I'll need to do a post that gives them some limelight.

  4. Rules and rulebooks are all covered in Chapter 19 of the the Inform book. I'll refer most people there as diving into that topic is absolutely something I'd have to commit some time to write a post or several posts, just to give it the proper treatment it deserves.

  5. This used to be two different things. Text and Indexed Text, however in 2012 it was decided to merge the two into just text and the 6L02 release of Inform 7 in 2014 gave us our first release that used this new merged text. I recommened to everyone that they go ahead and drop Indexed Text if they haven't already been using it. However, I've placed it on this table as well as from the first to stay in line with the information from IF wiki.

  6. Stored actions are pretty much taking an action that the player does and remembering it for later. So if say the play knocks out a person in your story and then later on your player runs back into that person. If they did commit the hitting action and you stored that, then you'll be able to test that using this. However, you'll find that stored actions are more useful in temporary variables that are used in carrying out an action.

Implementing Help in a Story