Function: CurrentRoomIs
Function: CurrentRoomIs

Function: CurrentRoomIs

CurrentRoomIs ( PLAYER, ROOM )

Checks if a specific player's current room is the room provided.

Parameters

Parameter Type Description
PLAYER PLAYER The player to inspect.
ROOM ROOM The room to check for.

Returns

VALUE(BOOLEAN) TRUE if the provided room is current on the provided player, FALSE otherwise.

What It Does

This function checks if the topmost room in a specific player's room stack is the provided room, returning TRUE if so, or FALSE if not, or if the provided player has no current room.

Example

Conversation Example


// 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;
	}

}

See Also

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.
PlayerHasRoomInStack() — Checks if a room is in a player's room stack.
NoCurrentRoom() — Checks if a player is not in any room.

×

Modal Header