I7 : Tracking absolute object location

Hullo!

Really quick question. I’ve been banging my head on a table about this one. Is there any way of keeping track of the ‘absolute’ location of an object.

i.e

currentLoc is a room that varies.
now currentLoc is the location of the Widget.
...
now Gadget is in currentLoc.

That’s fine if I just want to record the room it’s in. But, and this is the bit I can’t work out if there’s a simple way of doing it, what if it’s in something in the room:

The Cabinet is in the kitchen.
Widget is a thing in the Cabinet.

currentLoc is a ?location? that varies.
now currentLoc is the ?location? of the Widget.
...
now the ?location? of the Gadget is currentLoc

which would hopefully move Gadget into the cabinet.

So, in other words, is there a simple way of recording exactly where a thing is (in a location, in something, on something, part of something) and then using that as a variable? i.e. Whether the Widget is in the Kitchen, or in the Cabinet in the Kitchen, I can record that.

Thanks in advance,

Ade

Instead of ‘location of’ use ‘holder of’ (for more info see Documentation 8:13 and 8:17)

e.g.

"Holder" by PB

Lab is a room

The workbench is a supporter in the Lab.

The medicine cabinet is a lockable unlocked open container. It is on the workbench..

The pill bottle is a transparent closed openable container.  It is in the medicine cabinet.

The placebo is in the pill bottle.

The place is an object that varies.

When play begins:
	now the place is the holder of the placebo.
	
At 9:02 AM:
	move the placebo to the place.
	
At 9:03 AM:
	now the cabinet holds the placebo.
	
At 9:04 AM:
	now the place is the workbench;
	now the place holds the placebo.
	
Every turn:
	say "([Unless turn count is 1]Then at[else]At[end if]: [time of day])...[run paragraph on][line break]";
	
	
Test me with "open bottle/take placebo/look/look/look/look".
1 Like

Looks good. Thanks Peter. I hadn’t realized that ‘the holder of’ could also refer to a room as an object. This covers all cases except ‘is part of’ (which is the holder of, but I need to wrap some logic about making the 2nd object part of instead of inserted into). I need to have a think about how to handle that.

Yes, as far as I can see you would need to have a separate variable or property to hold this information. Here’s one possibility.

"Holder_2" by PB

Lab is a room

The workbench is a supporter in the Lab.

The medicine cabinet is a lockable unlocked open container. It is on the workbench..

The combination lock is part of the cabinet.

The pill bottle is a transparent closed openable container.  It is in the medicine cabinet.

The placebo is in the pill bottle.

An object can be comprising. An object has an object called the source.

To shift (component - an object) to (destination - an object):
	now the source of the component is the holder of the component;
	if the holder of the component incorporates the component:
		now the component is comprising;
	otherwise:
		now the component is not comprising;
	now the destination holds the component;
	
To integrate (component - an object) to (destination - an object):
	shift the component to the destination;
	now the component is part of the destination;
	
To reinstate (component - an object):
	if the component is comprising:
		now the component is part of the source of the component;
	otherwise:
		now the source of the component holds the component;
	
At 9:00 AM:
	shift the lock to the bottle.
	
At 9:01 AM:
	reinstate the lock.

At 9:02 AM:
	shift the bottle to the workbench.
	
At 9:03 AM:
	reinstate the bottle.

Every turn:
	say "([Unless turn count is 1]Then at[else]At[end if]: [time of day])...[run paragraph on][line break]";
	say "The lock is [if the lock is part of the holder of the lock]part of[otherwise]in[end if] [the holder of the lock].";
	
	
Test me with "look/look/look/look/look".

That’s excellent. I can definitely use that. Thank you for the detailed response. Very much appreciated.