]> git.jsancho.org Git - gacela.git/blobdiff - src/gacela_mobs.scm
(no commit message)
[gacela.git] / src / gacela_mobs.scm
index aeb65d96c5c6b9ccf63b1f4171b8089c4e4b0522..a9c13fa1acc8994713ee7f94f3eeb1a2c9a9b951 100755 (executable)
 
 
 (define-macro (show-mob mob)
-  `(show-mob-hash ',mob (lambda (option) (,mob option))))
+  (cond ((list? mob)
+        `(let ((m ,mob))
+           (show-mob-hash (m 'get-mob-id) m)))
+       (else
+        `(show-mob-hash (,mob 'get-mob-id) (lambda () (,mob))))))
 
 (define-macro (hide-mob mob)
   `(hide-mob-hash ',mob))
 
 (define (set-mob-look! mob look)
   (mob 'set-look look))
+
+
+
+
+
+(define-macro (define-mob mob-head . body)
+  (let ((name (car mob-head)) (attr (cdr mob-head)))
+    `(define ,(string->symbol (string-concatenate (list "make-" (symbol->string name))))
+       (lambda-mob ,attr ,@body))))
+
+(define-macro (lambda-mob attr . body)
+  `(lambda ()
+     (let ,(cons '(mob-id (gensym)) attr)
+       (lambda* (#:optional (option #f))
+        (case option
+          ((get-mob-id)
+           mob-id)
+          (else
+           (catch #t
+                  (lambda () ,@body)
+                  (lambda (key . args) #f))))))))