-- everything is a location, an object or a timer --
As of version 2.4, XVAN supports choice and hybrid play modes.
By default, the XVAN interpreter works in interpreter mode: user input
is entered as sentences via the command line. In choice and hybrid mode,
at the beginning of each turn the user is presented with a numbered list
of options to choose from. By entering a number, the corresponding
option is selected. Hybrid mode is reserved for IFI-XVAN. The idea is to
create a ‘quick command’ list in the side bar that is updated every
turn, while keyboard input is also active.
By default, XVAN operates in interpreter mode. Choice/hybrid mode can be
activated in two ways:
In the story info section from the main story file;
During gameplay through the playmode() function.
One of the differences between choice and interpreter games is that
choice is about finding out ‘what’ to do and that in an interpreter
game one must find out ‘how’ to do it. Porting an interpreter game to a
choice game without giving away clues is not always easy.
How does choice mode work? As an example, we will activate choice mode
for our bedroom location. The list of possible choices is composed by
the location and its contained objects. XVAN has a predefined trigger
t_choice and a function addchoice() for this purpose.
Just before user input is required (after prologue, t_entrance etc), the
interpreter checks the play mode. If it is not interpreter mode, it will
tell the location and contained objects to execute their t_choice
trigger. In t_choice an object can use the addchoice() function to add a
possible choice to the list of choices.
E.g. addchoice(“Get out”, “west”) will add the text “Get out” to the
choice list. When this option is selected, the text “west” will be fed
into the interpreter as user input.
Back to our bedroom location example. In the bedroom there are 3
contained objects:
the sink (o_sink);
the tap (o_tap);
the water (o_water_bedroom);
the drain pipe (o_drain_pipe_bedroom)
In choice mode, the bedroom, tap and water are likely to want to contribute to the choices list:
Bedroom: leave the room;
Tap: open or close the tap;
Water: drink it.
This gives us the following t_choice code:
$LOCATION l_bedroom
……
t_choice
addchoice(“Leave”, “east”)
……
END_LOC
$OBJECT o_tap
……
t_choice
if testflag(f_open) then
addchoice(“Close the tap”, “close tap”)
else
addchoice(“Open the tap”, “open tap”)
……
END_OBJ
$OBJECT o_water_bedroom
……
t_choice
if not(testflag(f_hidden)) then
addchoice(“Drink from the water”, “drink water”)
……
END_OBJ
But when do we best switch on and off the choice mode?
Switching on choice mode:
Choice mode has to be switched on before the interpreter checks to see
where it must get the user input from. Possible moments are in t_exit
from l_upstairs or in t_entrance from l_bedroom. My choice would be
t_entrance, because in t_exit from l_upstairs, the t_choice has to do an
additional check to make sure we are actually going west to the bedroom
and not downstairs again.
Switching off choice mode:
This can be done in t_exit from l_bedroom.
$LOCATION l_upstairs
……
t_exit
if equal(%dir, west) then
playmode(choice)
……
END_LOC
$LOCATION l_bedroom
……
t_entrance # replaces code in t_exit for l_upstairs
…..
playmode(choice)
…..
t_exit
playmode(interpreter)
……
END_LOC
This ends the tutorial. Everything we did is in the files
part6-end.xvn
and part6-end.lib (which is the same as
part5-end.lib). I hope the tutorial gave enough information to start
implementing your own game. The XVAN distribution comes with a number of
sample stories that can serve as examples.
For comments or questions, contact met at
marnix.home@gmail.com .
.