1;; Keys are a bit unusual in that each unique key must be a unique object
2;; type. This is because player inventory consists only of object types, not
3;; instances, and to use a key it must be in player inventory.
4
5(define (mk-key-type tag name sprite)
6  (mk-reusable-item
7   tag name sprite norm
8   (lambda (ktype kuser)
9     (let ((ktarg (ui-target (kern-obj-get-location kuser)
10                             1
11                             (mk-ifc-query 'use-key))))
12       (cond ((null? ktarg)
13              result-no-target)
14             (else
15              (ifccall ktarg 'use-key ktype)
16              result-ok))))))
17
18(define (mk-key type)
19  (kern-mk-obj type 1))
20
21;; List all the key types. This doesn't *need* to be done here, but like any
22;; type, it must be done in a file that is kern-loaded, which means it can't be
23;; done in a place file. So by convention let's list them here.
24(mk-key-type 't_brundegardt_tower_4_key "weathered key" s_picklock)
25(mk-key-type 't_stewardess_chest_key    "shiny key"     s_picklock)
26