Magic Teleporting Items?

I’m trying to code a magic item which will mainly teleport the player from one area to another. These items are magic orbs which are always tied to specific locations, so they’ll always take the player to a certain room when used, but as a total novice to Inform, I have no clue how to set this up.

I also want the orbs to be automatically dropped when they’re used-- so that when the player uses one to teleport to another room, they leave the orb behind and drop it in whatever room they were just in, but this is secondary to the first issue of finding out how to actually make them teleport the player.

Thanks in advance!

2 Likes

This should do it:

The Orb Room is a room. "The Orb Room is full of glittering orbs of all sizes and colors." 

The Magic Kingdom is a room. "The magic of the orb has sent you to a magical realm. Talking mice and princesses are all around."

A magic orb is in the Orb Room.

Teleporting is an action applying to nothing. Understand "teleport" as teleporting.

Check teleporting: if the player does not hold the magic orb, say "You must first take the orb." instead.

Carry out teleporting:
	now the location contains the magic orb;
	move the player to the Magic Kingdom.

A note on containment: In Inform, “contains” is first-level containment, with no nesting. “Enclosed,” on the other hand, allows objects to be nested to any depth. So if the location “contains” the orb, the player does not hold the orb, but the location “encloses” the orb whether the player holds the orb or not.

3 Likes

I think that the “classical” SF teleport should be like an elevator with buttons on the outside (that is, the teleporter console, but perhaps the hard part in coding lies in the other direction… (“beam up, Scotty”…)

on the fantasy orbs, I think that should be like bi-directional doors between two fixed places.

of course, I admit that this is a “my two cents” reply…

Best regards from Italy,
dott. Piergiorgio.

For multiple magic orbs, one approach is a kind (teleporting orbs) each of which has a standard property pointing to a room (destination). Then the result of an action is to move the player to whatever destination the orb is assigned to.

The Orb Room is a room. "The Orb Room is full of glittering orbs of all sizes and colors." 
The Red Room is a room. "Everything is red."
The Green Room is a room. "Everything is green."

A teleorb is a kind of thing. A teleorb has a room called the destination.

The green orb is a teleorb. The destination of the green orb is the Green Room. The description of the green orb is "It glitters green." 

The red orb is a teleorb with destination Red Room and description "It radiates red."

When play begins:
	repeat with item running through every teleorb:
		move item to the Orb Room.

Check examining a teleorb (called the orb):
	If the player is holding the orb:
		say "As you gaze into the orb in your hand, it suddenly expands--or perhaps you fall into it? There is a flash.";
		now the location contains the orb;
		move the player to the destination of the orb instead.

Test me with "x red / take red / x green / x red / x red".

Now you can create as many orbs as you wish and tie them to different rooms. Rather than teaching the player a new verb like a spell (teleport) you can also tie the action to a standard verb – an orb teleports anyone who gazes into it with examine – but only if they are holding it.

This seems like an interesting setup for a puzzle if you can “move a room” and thus change the destination of an orb – either because the orb tracks the inner context (a tent that you can move around and then teleport into) or because it points to an absolute location (a place in an elevator shaft that must be aligned with an elevator car).

2 Likes