A Tale of Two Languages
Listing 1. Describing a CD Tray in Inform 7
094 The CD Tray is part of the old server. 095 The description is "It's a CD tray."
The differences between the two languages are apparent from the first lines. When starting a story in Inform 6, there are some essential housekeeping duties that need to be done at the beginning (i6:001-007) and end (i6:172-193) in order for the story to compile (Listing 2).
Listing 2. Essential Code for Compiling Inform 6
001 !% -SD 002 003 !======================================================== 004 Constant Story "The Server Room"; 005 Constant Headline 006 "^An Interactive Fiction by Daniel Bartholomew.^"; 007 Release 1; Serial "080625"; !for keeping track of releases . . 172 !======================================================== 173 ! Entry point routines 174 175 [ Initialise; 176 location = break_room; 177 "^^^^It's Saturday, a nice one at that, and you've been 178 called to fix a server. Again.^^You've had it. This 179 server is going to run Linux starting today! The process 180 will be easy, just put the disc into the server go. 181 Now where is that Ubuntu CD?^"; 182 ]; 183 184 [ Deathmessage; 185 if (deadflag == 5) print "You have won"; 186 ]; 187 188 !======================================================== 189 ! Standard and Extended Grammar 190 191 Include "Grammar"; 192 193 !========================================================
In Inform 7, the only thing that is absolutely required is the first line (i7:001). To be fair, the initialization routine in Inform 6 also includes the message that is displayed at the beginning of the game. In Inform 7 this also is there (i7:007-011), but it's not required for successful compilation (Listing 3).
Listing 3. Initial Program Code for Inform 7
001 "The Server Room" by "Daniel Bartholomew" 002 003 Include GNU GPL v3 by Free Software Foundation. 004 005 The maximum score is 6. 006 007 When play begins, say "It's Saturday, a nice one at that, 008 and you've been called to fix a server. Again. 009 [paragraph break]You've had it. This server is going to 010 run Linux starting today! The process will be easy, just put 011 the disk in the server and go. Now where is that Ubuntu CD?"
The defining of variables is similar in both versions—for instance, the maximum score variable (i6:009, i7:005). The main difference is that the Inform 6 version uses C-like syntax:
Constant MAX_SCORE = 6;
And, Inform 7 uses a sentence that reads similarly to how one would read the Inform 6 version out loud:
The maximum score is 6.
Some of the differences between versions are similarly minor. One example is the method of inserting paragraph breaks into long sections of text, such as in the description of the Server Room (i6:114-118, i7:082-086, Listing 4). In Inform 6, two carat symbols (^^) are used, and in Inform 7, the statement paragraph break enclosed in square brackets () does the job.
Listing 4. Syntax for Describing a Room
Inform 6 Version: 114 description "The fans, the lights, the chill... yep, it's a 115 server room. Full of servers from a dozen vendors, 116 each with their own quirks.^^Your attention is 117 immediately drawn to a server 2/3 of the way up rack 7. 118 The indicator light is blinking red and beeping.", Inform 7 Version: 082 The Server Room is a room. "The fans, the lights, the chill... 083 yep it's a server room. Full of servers from a dozen 084 vendors, each with their own quirks.[paragraph break]Your 085 attention is immediately drawn to a server 2/3 of the way up 086 rack 7. The indicator light is blinking red and beeping."
One big mistake I made when I started was creating everything first in Inform 7, and then creating the equivalent Inform 6 code. This proved tricky on a couple occasions—most notably with the random beeping messages that appear at every turn while you are in the server room (until you fix the server and win the game). Programming such logic is very different in each version. In Inform 7, writing this took almost no thought at all (i7:097-103). Basically, I described what I wanted to happen every turn, and Inform 7 made it happen. The Inform 6 code to do the same thing is not as advanced (i6:120-134). It's basically a case statement, but it's significantly more difficult to write in comparison (Listing 5).
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
|Non-Linux FOSS: Seashore||May 10, 2013|
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- Dynamic DNS—an Object Lesson in Problem Solving
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Download the Free Red Hat White Paper "Using an Open Source Framework to Catch the Bad Guy"
- Tech Tip: Really Simple HTTP Server with Python
- Roll your own dynamic dns
3 hours 33 min ago
- Please correct the URL for Salt Stack's web site
6 hours 44 min ago
- Android is Linux -- why no better inter-operation
9 hours 2 sec ago
- Connecting Android device to desktop Linux via USB
9 hours 28 min ago
- Find new cell phone and tablet pc
10 hours 26 min ago
11 hours 55 min ago
- Automatically updating Guest Additions
13 hours 4 min ago
- I like your topic on android
13 hours 50 min ago
- This is the easiest tutorial
20 hours 26 min ago
- Ahh, the Koolaid.
1 day 2 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?