Specifying a single object by number

I have this project right now where there are hundreds of tables (the object kind, not the array kind) which are all numbered, and I want a way to have the player be able to do something like “EXAMINE TABLE 50” or “PUT TRAY ON TABLE 172” and it see if there is a specific response to that number. To specify, it’s one big lunch hall with about 740 different tables. I want to basically make it one object, referrable either as “tables” (to be generic) or “table [number]” for some specific puzzles where you need to interact with a specific table.

Is there any way to do this?

Thanks!

I think the best way to do this is with Subcommands, checking if the subcommand of the tables matches “table [number]” and then looking at “the number understood” if so. Sadly, I don’t feel confident enough in this to provide code that I can’t test at the moment.

1 Like

I’ve got something that I hope helps to give you a start. I borrowed from Example 318 - Tilt 1 to implement copies of tables that have unique properties and that can be referred to individually. In this case, I wanted the unique property to be the table number.

It’s not entirely clean, like you’ll probably want to fix some of the printing of the tables so that it doesn’t use the definite article (the Table 3), and you’ll probably want some way to not have the room description list all 740 tables as you’re wanting. But hopefully this will give you something you can work off of.

Additionally, because I’m working with duplicates of a kind, I felt that I needed a tabletop to be part of every table so that you can place things on top.

Code:

Lunch Hall is a room.

A table is a kind of thing.
A table has a number called table number.
Understand the table number property as describing a table.

A tabletop is a kind of supporter. A tabletop is part of every table.

5 tables are in the Lunch Storage.

A plate is in the Lunch Hall.
	
Rule for printing the name of a table (called target):
	say "Table [table number of the target]".

When play begins:
	repeat with i running from 1 to 5:
		let t be a random table in the Lunch Storage;
		now table number of t is i;
		now t is in the Lunch Hall.

Instead of putting something on a table:
	let tt be a random tabletop which is part of the second noun;
	now the noun is on tt;
	say "You place [the noun] on [the second noun].".

Instead of examining a table:
	let tt be a random tabletop which is part of the noun;
	say "[The noun] is holding [a list of things on tt].".

Output:

Lunch Hall
You can see a Table 5, a Table 4, a Table 3, a Table 2, a Table 1 and a plate here.

>put plate on table 3
You place the plate on the Table 3.

>showme table 3
Table 3 - table
    tabletop (part of Table 3) - tabletop
        plate
location: in Lunch Hall
unlit, inedible, portable; singular-named, improper-named
description: none
initial appearance: none
table number: 3
printed name: "table"
printed plural name: "tables"
indefinite article: none
list grouping key: none

>x table 3
The Table 3 is holding a plate.
1 Like

you’ll probably want to fix some of the printing of the tables so that it doesn’t use the definite article (the Table 3)

Remembered that you could probably achieve this by specifying that tables are proper-named:

A table is proper-named.

Which should let the output behave in this manner:

Lunch Hall
You can see Table 5, Table 4, Table 3, Table 2, Table 1 and a plate here.

>put plate on table 3
You place the plate on Table 3.

>x table 3
Table 3 is holding a plate.
1 Like

You can use the grouping together activity for this and make a slight change to the “printing the name of a table” rule above:

Rule for printing the name of a table (called target) while not grouping together:
	say "Table [table number of the target]".
	
Before listing contents: group tables together.
Before grouping together tables: say "[listing group size in words] ".
For grouping together tables: say "tables".
After grouping together tables (this is the only works if the tables are numbered sequentially and never get moved or destroyed rule): say " (numbered from 1 to [listing group size])".

Will yield:

Lunch Hall
You can see five tables (numbered from 1 to 5) and a plate here.

3 Likes

The simple approach gets you a good part of the way there:

The table-group is a fixed in place supporter in the Kitchen.

Understand "table", "table [number]" as the table-group.

Check examining the table-group:
	instead say "You examine table [number understood]."

Now referring to “table 5” will match the table but also set number understood.

The problem is that number understood is a global variable, which could be used by other tokens. (Say if you had a SET DIAL TO NUMBER command.) Also, the player can just refer to “table”; then your action rules will see whatever number understood is left over from previous turns. That’s a mixed blessing.

>x table
You examine table 0.

>x table 5
You examine table 5.

>x table
You examine table 5.

>x table 13
You examine table 13.

You probably want to know whether the player typed a number or not, and that’s going to be tricky.

2 Likes

This is my stab at it…

lab is a room. "You are at [ur-table]".

current-table is initially 1.

The ur-table is a fixed in place thing in the lab. printed name is "table [current-table]".
understand "table [number]" as the ur-table.

The anonymous-table is a thing.
After deciding the scope of the player when the player is in the lab, place the anonymous-table in scope.
Understand "table" as the anonymous-table.
Before doing anything with the anonymous-table when the player is in the lab:
say "(table [current-table])[line break]";
now the number understood is current-table;
if the noun is the anonymous-table, now the noun is the ur-table;
if the second noun is the anonymous-table, now the second noun is the ur-table;

table-going is an action applying to one thing.
understand "go to/-- [thing]" as table-going.

[ insert check rule for > 0, <= the max ]
check table-going when the number understood is the current-table: instead say "[We]['re] already there."

carry out table-going: now the current-table is the number understood.

Report table-going: say "[We] [go] to table [current-table]."

carry out examining the ur-table:
  if the number understood is 17, say "magic table.";
  else say "There's nothing special about table [number understood].";
  now examine text printed is true;

test me with "x table 12 / x table 17 / go to table 17 / x table"

No attempt is made to handle the table(s) being able to support or tracking what things are on which tables.

2 Likes

Hey, thanks guys! I used Zed’s example plus the subcommands to make it work. Thanks!