Introduction to Inform Game Engine and PunyInform Library
1. 10/10/2021 1
Inform Game Engine
and the PunyInform Library
Wilfried Elmenreich
Many thanks to Gareth Rees for the slides
about the Inform engine mechanisms
2. 10/10/2021 2
Need at Least One Object
Object BroomCloset "Broom Closet"
with
description "You're in the rather dirty broom
closet of The Red Anchor.
Various cleaning appliances line the
walls. There's a pile of fabric
in a corner.",
e_to BroomClosetDoor,
has light;
3. 10/10/2021 3
Initialise Function
[Initialise;
print "^^You wake up with a headache. Yesterday's
events are only a blur. So just another normal day
for you...^^";
thedark.short_name = "Your view is very
blurry.";
thedark.description = "You cannot see much
because of the rag over your eyes. You should
eventually disrobe it.";
player.add_to_scope = PlayerAddToScope;
];
4. 10/10/2021 4
Return Codes
• A routine inside an object returns 0 (false) by
default
• A routine outside of an object returns 1 (true)
by default.
• You can override this default using the
`return', `rtrue' and `rfalse' statements, or by
omitting the `print' instruction from a print
statement.
5. 10/10/2021 5
Meaning of Return Codes
`before‘
`life'
– True (1) means that the routine has successfully
and completely dealt with the player's input, and
the library shouldn't do anything more.
– False (0) means that the usual library rules should
now apply to the player's input (note that this
doesn't necessarily mean that the routine has
done nothing).
6. 10/10/2021 6
Meaning of Return Codes
`after'
– True (1) means that the `after' routine has printed
a suitable response to the player's input, and the
library shouldn't do anything more.
– False (0) means that the usual library message
should now be printed (again, this doesn't
necessarily mean that the routine has done
nothing).
7. 10/10/2021 7
Before and After
• ‘before’
– Should be used to change completely the effect of
a particular action
• ‘after’
– Should be used to change the message
associated with a particular action
8. 10/10/2021 8
Meaning of Return Codes
`describe'
– True (1) means that the `describe' routine has
printed a suitable description. The library shouldn't
add anything else.
– False (0) means that the library should print the
usual description of the object.
9. 10/10/2021 9
Programming Tip
• In an object's `before' routine, it's very
common to want to
– execute some code
– print some text to tell the player what has
happened
– return 1 to prevent the library from doing anything
else.
• A good trick in this situation is to omit the
`print' keyword from the last print statement.
10. 10/10/2021 10
Simple Object
Object -> Note "note"
with
name 'note',
description "The note says 'Be sure to know where your towel is'.",
initial "A note has been fixed to the wall with a knife.",
after [;
Take:
if(Knife hasnt moved && self hasnt general) {
! Use the general attribute to say we've already pulled
! the note from the wall, so we don't print this twice.
give self general;
move knife to player;
"The knife rips a long hole in the note as you pull the
note from the wall.";
}
];
11. 10/10/2021 11
Scenery Object
Object -> Rainpipe "rainpipe"
with
name 'rainpipe' 'pipe',
description "A rainpipe leading down from the roof
and ending right under the balcony. When it's raining,
it splashes water on the pedestrians 10 meters below.",
before [;
Climb:
print "You carefully climb up on the
rainpipe.^";
PlayerTo(TheRoof);
rtrue;
],
has scenery;
12. 10/10/2021 12
Building and Testing the Game
Compile the game using the Inform6 compiler
inform6 -v3 +lib game.inf
Testing under Windows with
Frotz
Building a C64 version with Ozmoo
ruby make.rb -S1 -f fontsdesoftwriter-ger.fnt -dd -rc:8=15 -dc:6:9 -
bc:6 -sc:15 -i houseonahill.kla buccaneers_cache_r2.z3
Z-Code Interpreters for many platforms available