Two questions about the empty table as a property

I decided to use properties more heavily, and in one case, I had code as so:

a room has a table name called actions-table.

r1 is a room.

r2 is a room. actions-table of r2 is table of r2 actions.

table of r2 thinks
temperature  happened  text
30   false    "It's hot in here."

The basic idea is that if a temperature is above a certain level, a random activity happens, if any is left. Then the “happened” column is marked false.

Now what I am wondering is, does the code

repeat running through actions-table of location of player:
    (etc.)

have any chance of going wrong if the table is empty? I mean, it doesn’t seem like it should, but a search of the docs turned up nothing.

Also, how would we check for “if actions-table of location of player is the empty table?” It doesn’t seem to work in 6g60.

Thanks!

You can check “if [table] is empty”. But repeating through an empty table is safe, it just won’t do anything.

3 Likes

Oh, man. I feel a bit silly about not trying that, since I also had indexed text as the property for a room and wrote the code if certain-text is empty, say "[default-text]";

Thanks again!

yeah, there isn’t a table that is the empty table, (the empty table) is just what Inform outputs when you try to say a table name that’s null. (There are a handful of exceptions to the variables/properties always default to some non-null value thing.)

2 Likes