Photography (Question)

Hi! I have written some simple code to simulate a simple digital camera:

#camera
(name *)
	your digital camera
(descr *)
	(camera screen shows $Screen)
	Your digital camera's screen shows (a $Screen).
(item *)
(proper *)
(* is #heldby #player)
(global variable (camera screen shows []))
(understand [photograph | $Words] as [photograph $Obj])
	*(understand $Words as non-all object $Obj)
~(refuse [photograph $])
(prevent [photograph $])
	~(#camera is #heldby #player)
	You need a camera to do that.
(prevent [photograph #camera])
	How do you intend to do that?
(perform [photograph $Obj])
	\*CLICK\*
	(if) (player can see) (then)
		(now) (camera screen shows $Obj)
	(else)
		(now) (camera screen shows [])
	(endif)

What I don’t like is that and-ing objects results in multiple pictures being taken (and over-writing each other in this simple implementation).

> examine camera
Your digital camera's screen shows nothing.

> photograph apple and banana
Trying to photograph the apple: *CLICK*
Trying to photograph the banana: *CLICK*

> examine camera
Your digital camera's screen shows a banana.

Is there any way to collect the list of objects in an action call, rather than dispatch multiple actions on each object in turn? I’d be very interested in such a thing.

1 Like

It’s kind of undocumented, but you could intercept try-complex:

(try-complex [photograph [+ | $ObjList]])
        CLICK!
        (now) (camera screen shows $ObjList)

A complex action represents multiple objects as a list containing + followed by the objects.

Note that you are overriding this before the usual checks (e.g. refuse), so the above doesn’t stop the player from taking a picture of the apple and the camera. You could:

(try-complex [photograph [+ | $ObjList]])
        (if) *($Obj is one of $ObjList) (refuse [photograph $Obj]) (then)
                (stop)
        (else)
                CLICK!
                (now) (camera screen shows $ObjList)
        (endif)

Perhaps there should be a cleaner and fully documented way to do this. I’ll see if I can figure something out.

1 Like

Thank you, very interesting!