Parameter | Type | Description |
---|---|---|
PLAYER | PLAYER | The player to inspect. |
VALUE(BOOLEAN) | TRUE if the provided player has no current room, or FALSE otherwise. |
This function checks if a specific player has no current room (the player's room stack is empty), returning TRUE if so, or FALSE if the player's room stack as at least one room in it.
// Actions
action modal a_go named "go" uses modes "north", "south", "west", "east";
action transitive a_examine named "look at", "examine", "x";
action transitive a_talkto named "talk to";
action general a_quit named "quit";
// Conversation Actions
action transitive a_talkabout named "talk about";
action general a_leave named "back", "leave";
// "Hidden" Actions
action general a_look; // queued every action.
action general a_roomcheck; // queued every action.
// ================== Topics (as objects) =======================
object archetype o_topic;
object ot_sports : o_topic named "sports";
object ot_music : o_topic named "music";
object ot_movies : o_topic named "movies";
object ot_dogs : o_topic named "dogs";
// ===================== All about Bob ==========================
room convo_bob
{
onAction(a_look) {} // Do nothing on "look".
// If "in" the conversation, this block will be hit instead of the player fallback.
onAction(a_leave)
{
textln("You cease talking to Bob.");
popRoom(player); // Go back to where you were.
}
onActionWith(a_talkabout, ot_sports)
{
textln("Bob says, \"Oh yeah! I love sports!\"");
}
onActionWith(a_talkabout, ot_movies)
{
textln("Bob says, \"Heck yeah! I love movies!\"");
}
onActionWith(a_talkabout, ot_dogs)
{
textln("Bob says, \"Oh man, I love dogs! They're adorable!\"");
}
// Omitting "music"
onActionWithAncestor(a_talkabout, o_topic)
{
textln("Bob says, \"I dunno much about that.\"");
}
onActionWithOther(a_talkabout)
{
textln("That's not a topic of conversation.");
}
}
object o_bob named "Bob"
{
onAction(a_examine)
{
textln("That's Bob. He likes to talk about things (\"TALK TO\" him).");
}
onAction(a_talkto)
{
textln("You are now talking to Bob. (TALK ABOUT sports, movies, music, or dogs. You can LEAVE the conversation, too)");
pushRoom(player, convo_bob); // Keep current room for "leave".
}
onRoomBrowse()
{
textln("Bob is here.");
}
}
// ======================== Actual Rooms ==========================
room r_bedroom; // Prototyped due to early use in r_livingroom
room r_livingroom
{
init()
{
giveObject(this, o_bob);
}
onAction(a_look)
{
textln("You are in the living room.");
textln("North goes to the bedroom.");
browse(this);
}
onModalAction(a_go, "north")
{
setRoom(player, r_bedroom);
}
}
extend room r_bedroom
{
onAction(a_look)
{
textln("You are in the bedroom.");
textln("South goes to the living room.");
browse(this);
}
onModalAction(a_go, "south")
{
setRoom(player, r_livingroom);
}
}
player p_main
{
init()
{
// add topics (so that they are always accessible to the player).
giveObject(this, ot_sports);
giveObject(this, ot_movies);
giveObject(this, ot_music);
giveObject(this, ot_dogs);
}
onAction(a_roomcheck)
{
if (!currentRoomIs(this, r_livingroom) && playerHasRoomInStack(this, r_livingroom))
textln("(NOTE: You are still \"in\" the living room, but can't access things in it - \"TALK TO BOB\" will not work)");
}
onUnhandledAction(a_go)
{
textln("You can't go that way.");
}
onIncompleteCommand(a_talkto)
{
textln("TALK TO what?");
}
onUnhandledAction(a_talkto)
{
textln("I can't TALK TO that.");
}
onIncompleteCommand(a_talkabout)
{
textln("TALK ABOUT what?");
}
onUnhandledAction(a_talkabout)
{
textln("You must be conversing with somebody to TALK ABOUT things.");
}
onAction(a_leave)
{
textln("You're not in a conversation.");
}
}
world
{
init()
{
setRoom(p_main, r_bedroom);
setPlayer(p_main); // from this moment on, this is the "player" keyword.
}
start()
{
textln("Type \"quit\" to quit, \"go\" and a compass direction to move between rooms.");
textln("Examine things with \"look at\" or \"examine\".");
textln("");
queue a_look;
queue a_roomcheck;
}
onAction(a_quit)
{
quit;
}
afterSuccessfulCommand()
{
queue a_look;
queue a_roomcheck;
}
}
SetRoom() — Sets the current room on a player, after clearing its room stack.
PushRoom() — Adds a room onto a player's room stack, preserving the previous rooms on the stack.
PopRoom() — Removes the topmost room from a player's room stack.
SwapRoom() — Changes the topmost room on a player's room stack, preserving the rest of the stack.
CurrentRoomIs() — Checks the topmost room on a player's room stack against another room.
PlayerHasRoomInStack() — Checks if a room is in a player's room stack.