Get a reference to a thing by its name.

Let’s say I have a text that varied and that contains “lobby”.

Now let’s say I have a room a in my story called “lobby”.

Is there a way to move a person (let’s call her Laura) to the lobby based on that?

What I’m looking for is something like:

Let place be the room called "[the room name]".

Surely, there must be something like that. But I can’t find it.

Does the text come directly from the player’s typed command?

(If it doesn’t, there’s probably an easier way that doesn’t involve text.)

The text would come from a file loaded into a table.

No, rooms and other objects are referenced internally by pointers rather than by name. If you really need to do that, you’d have to use a construction like this:

To decide which object is the (D - description of objects) referenced as (T - text):
    repeat with X running through D:
        if the printed name of X exactly matches T:
            decide on X;
    decide on nothing.

That solves it. It’s a slow solution but it would work. Thanks!

I can always cache the result in a table or something.

The fast solution would be to store the numerical address of each room in the table rather than its name. Although that wouldn’t be portable between game versions; I don’t know if you need that.

Re Draconis’s suggestion: you want just “is”, not “exactly matches”. Or “exactly matches the text…”

If you need it to work cross version you could manually assign an id number to each.

That’s what I’d do, yeah. Looking up a manually-assigned ID number would be somewhat faster than looking up the printed name (or a manually-assigned ID string).

This code works:

To decide which object is the (D - description of objects) referenced as (T - text):
    repeat with X running through D:
        if the printed name of X exactly matches T:
            decide on X;
    decide on nothing.

For me to get to work I had to make a minor edit:

To decide which object is the (D - description of objects) referenced as (T - text):
	repeat with X running through D:
		if "[the printed name of X]" exactly matches the text T:
			decide on X;
	decide on nothing.

And then, to actually see it do its thing, I invoked it thus:

toy is a thing. The printed name of toy is "yoyo".
chest is a container.
...
let myvar be the thing referenced as "yoyo";
move myvar to chest;

I think for eje211 to move Laura it would go like this:

Let place be the room referenced as "[the room name]".

Maybe I’ll come back and attach a whole example file… Thanks for the topic.