Defining things with Tables (6M62) Can you specify what room they're in?

I’d like to use the table to say where some things are in the game, on top of all else the table’s doing.

If I create a column called ‘location’, that doesn’t compile.

If I create a column called ‘room’, each thing in the table seems to get a variable called room, with a value of the specified room, but the thing isn’t placed there.

Is what I’m trying to do actually possible?

-Wade

This is a hack, but can you do a when play begins rule that runs through the table and moves each object to its room variable?

2 Likes

That’s not a hack, that’s the obvious way to do it.

But, do you know if I can do what I asked about? I mean, I’m inferring ‘no’, but you didn’t actually say you know that the answer is no. It felt like a step was jumped when you said a suggested workaround was not a hack.

Yeah, however by the time I’m doing that, I feel this whole table thing has lost its shine :slight_smile: I’ve never used the table definition method before, and thought it might be neater than writing another set of initialisation routines to run at boot time. The first problem was – it was actually tricky to make the table in question compile in the first place (it seemed to divert to off-target error messages pretty easily. I had to work it out in a test project). The second problem is this ‘It can’t put things in a room?’ thing.

So for now, abandoning definition by table is winning.

-Wade

1 Like
Lab is a room.

Some things are defined by the table of stuff.

Table of Stuff
thing   description     initial-loc (room)
spam    "spammy"        lab

when play begins:
    repeat through table of stuff begin;
      now the thing entry is in the initial-loc entry;
    end repeat;
1 Like

I’m not entirely sure how you mean but understand it like you want a “cell” in a table holding the location of an specific object and update that “cell” when an object moves and vice verse.

I don’t think it’s possible in the z-machine (or glulx) to define a “pointer” in that way (I don’t know Inform7). Could something similiar be done by storing the thing in the “cell” and then read/write the things location through the things location property?

As far as I can tell, location is not treated as a property by Inform. For instance,

now the location of the ball is the garden.

is not allowed.

If it’s not a property, then it’s not inconsistent with the documentation on defining things with tables that using a location column wouldn’t work.

My guess is that it’s not possible, but Zed’s solution is 90% of the way there.

My solution was tested in 10.1, and I don’t expect any difference with 9.3/6M62 on this point. The tabs got screwed up on copy-paste though. Wow, do I hate syntactically significant tab characters.

3 Likes

@heasm66 To clarify, this is a specified use of a table (16.16 Defining things with tables) where you put data in a table, and each line of the table creates one thing - which is in the leftmost column - and ‘pastes’ all the data of the columns to the right to that thing. It’s a little more sophisticated than a paste, though, because this method can create variables in the process. If you name a column and put text in it, Inform will give each thing in the table a text variable with the column name. However it will also take properties e.g. you can have a “printed name” column.

As @rileypb was saying, a thing’s location in the game is not data stored in a property. And it looks like this tables trick has no built-in allowance for that.

The closest you can get is ala what @DeusIrae and @Zed have said. Loop through the table at runtime to move the thing to that location. I was never interested in tracking it afterwards, just in having it created in that place.

Thanks all.

-Wade