RCRPG/Inform 7: Difference between revisions

→‎Code: wrapped
(→‎Code: wrapped)
Line 32:
Section - Prize objects
 
[Inform objects aren't created dynamically, but we can fake it by predefining pools of identical objects. These will start out off-stage, and we'll move them to newly discovered rooms as needed.]
pools of identical objects. These will start out off-stage, and we'll move them
to newly discovered rooms as needed.]
 
A prize is a kind of thing.
Line 51 ⟶ 53:
Section - Dynamically naming rooms
 
A room has indexed text called the given name. The given name of a room is usually "The Unnamed Room".
The given name of a room is usually "The Unnamed Room".
 
Definition: a room is undubbed if the given name of it is "The Unnamed Room".
Line 59 ⟶ 62:
Section - Listing exits
 
The description of a room is "You are in [room coordinates of the item described], [the item described]. [room exit list]".
described], [the item described]. [room exit list]".
 
Definition: a direction (called D) is accessible rather than inaccessible if the room D from the location is not nothing.
the room D from the location is not nothing.
 
To say room exit list:
let L be the list of accessible directions;
if the number of entries in L is:
-- 0: say "There are no exits from this room. Perhaps you need to make one?[run paragraph on]";
to make one?[run paragraph on]";
-- 1: say "There is an exit [entry 1 in L].[run paragraph on]";
-- otherwise: say "There are exits [L].[run paragraph on]";
 
Rule for printing the name of a direction (called D) while looking: say exit direction of D.
say exit direction of D.
 
To say exit direction of (D - up): say "in the ceiling".
Line 78 ⟶ 85:
Section - The recycled room pool
 
[The room pool is similar to the prize pools, but "off-stage" is meaningless for rooms, so we define a new either/or property.]
for rooms, so we define a new either/or property.]
 
A room can be allocated or unallocated. A room is usually unallocated.
There are 100 unallocated rooms.
 
[When we run out of unallocated rooms, we'll reclaim rooms that have already been discovered. We prefer to reclaim rooms that haven't been named, and we'll never reclaim the current room, a neighboring room, or the two special rooms.]
been discovered. We prefer to reclaim rooms that haven't been named, and we'll
never reclaim the current room, a neighboring room, or the two special rooms.]
 
Definition: a room is reclaimable:
Line 98 ⟶ 108:
decide on a random reclaimable room.
 
[After a room is recycled for use, we need to clear out the traces of its previous use and fill it with a prize.]
previous use and fill it with a prize.]
 
To initialize (R - room):
Line 113 ⟶ 124:
if P is not nothing, move P to R.
 
To decide which room is a room allocated for position (X - number) / (Y - number) / (Z - number):
(Y - number) / (Z - number):
repeat with AR running through allocated rooms:
if the X position of AR is X and the Y position of AR is Y and the Z position of AR is Z, decide on AR;
the Y position of AR is Y and
the Z position of AR is Z, decide on AR;
let R be a recycled room;
initialize R;
Line 127 ⟶ 141:
The player is in Start Room.
 
Start Room is an allocated room with given name "Start Room". In Start room is a sledge.
In Start room is a sledge.
 
Prize Room is an allocated room with given name "Prize Room", X position 1, Y position 1, and Z position 5. In Prize Room are 8 gold coins.
Y position 1, and Z position 5. In Prize Room are 8 gold coins.
 
Section - Traveling in XYZ space
 
[Table syntax can be used to define new objects, or in this case to set the properties of previously defined ones.]
properties of previously defined ones.]
 
Some directions are defined by the Table of Directional Offsets.
Line 152 ⟶ 169:
northwest -1 1 0]
 
Before going up when the location does not contain a ladder and the player carries a ladder (called L):
carries a ladder (called L):
say "(first dropping [the L])";
silently try dropping L.
 
Instead of going up when the location does not contain a ladder, say "There needs to be a ladder in the room before you can climb."
"There needs to be a ladder in the room before you can climb."
 
Report going up for the first time: say "You climb up the ladder."
 
Report going down to a room that does not contain a ladder for the first time:
say "You jump down, but you'll need to find a ladder before you can get back up."
back up."
 
[Redirect CLIMB LADDER to GO UP.]
Line 169 ⟶ 189:
Before climbing a direction (called D), try going D instead.
 
Instead of jumping, say "You jump on the spot, but you can't quite reach the ceiling."
the ceiling."
 
Section - Equipment
Line 175 ⟶ 196:
A thing can be equipped or unequipped. A thing is usually unequipped.
 
[This lets the player refer to equipped objects in commands like "drop unequipped sledge", and also groups them apart in inventory listings.]
unequipped sledge", and also groups them apart in inventory listings.]
Understand the equipped property as referring to a thing.
 
Line 181 ⟶ 203:
say " (equipped)".
 
Wielding relates a person (called P) to a thing (called T) when P carries T and T is equipped. The verb to wield (he wields, they wield, he is wielding, it is wielded) implies the wielding relation.
and T is equipped. The verb to wield (he wields, they wield, he is wielding,
it is wielded) implies the wielding relation.
 
Chapter - Actions
Line 190 ⟶ 214:
 
Carry out naming:
now the given name of the location is the topic understood in title case.
title case.
 
Report naming:
say "OK, [room coordinates of the location] is now [given name of the location]."
location]."
 
Section - Sledging
 
Sledging is an action applying to one visible thing. Understand "attack [direction]" or "sledge [direction]" as sledging. Understand the command "a" as "attack".
[direction]" or "sledge [direction]" as sledging. Understand the command "a"
as "attack".
 
Before sledging when the player is not wielding a sledge and the player is carrying a sledge (called S):
carrying a sledge (called S):
say "(first equipping [the S])";
silently try equipping S.
Line 216 ⟶ 245:
 
Check sledging an unbashable direction:
instead say "You can only open exits to the [list of bashable directions]."
directions]."
 
Carry out sledging a direction (called D):
Line 228 ⟶ 258:
Report sledging a direction (called D):
let destination be the room D of the location;
say "You bash until the surface crumbles, leading a hole [exit direction of D] you can crawl through."
direction of D] you can crawl through."
 
Section - Equipping
 
Equipping is an action applying to one carried thing. Understand "equip [something]" or "wield [something]" as equipping.
[something]" or "wield [something]" as equipping.
 
Check equipping something which is equipped:
Line 248 ⟶ 280:
Section - Unequipping
 
Unequipping is an action applying to one carried thing. Understand "unequip" or "unequip [something]" as unequipping.
or "unequip [something]" as unequipping.
 
Rule for supplying a missing noun when unequipping:
if the player is wielding something (called the equipped item), now the noun is the equipped item.
the noun is the equipped item.
 
Check unequipping when the player is not wielding the noun:
Anonymous user