diff --git a/core/message.lisp b/core/message.lisp index e84308f..6a8faad 100644 --- a/core/message.lisp +++ b/core/message.lisp @@ -6,7 +6,7 @@ (:shape :scopes/shape) (:util :scopes/util)) (:export #:message-meta #:message #:create - #:head #:data)) + #:action-key #:object-key)) (in-package :scopes/core/message) @@ -28,3 +28,12 @@ (defmethod actor:content ((msg message)) (list (shape:head-plist msg) (shape:data msg))) + +(defun action-key (msg) + (let ((head (shape:head msg))) + (list (car head) (cadr head)))) + +(defun object-key (msg) + (let ((head (shape:head msg))) + (cons (car head) (cddr head)))) + diff --git a/csys/csys.lisp b/csys/csys.lisp index 7b9bafc..6c235ea 100644 --- a/csys/csys.lisp +++ b/csys/csys.lisp @@ -81,8 +81,7 @@ (actor:send sn msg))) (defun find-sensors (msg) - (let* ((head (shape:head msg)) - (key (cons (car head) (cddr head))) + (let* ((key (message:object-key msg)) (sns (gethash key (sensors *environment*)))) ;(util:lgi key sns *environment*) sns)) @@ -99,8 +98,7 @@ (funcall s msg))) (defun handle-action (msg state syns &key (default #'no-op)) - (let* ((head (shape:head msg)) - (key (list (car head) (cadr head))) + (let* ((key (message:action-key msg)) (act (gethash key (actions *environment*) default))) (funcall act msg state syns)))