From 9588c965d19182edf4d8ee752bc880ff5a0945dc Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sun, 29 Jan 2017 19:58:03 -0600 Subject: [PATCH] create-gameobj --- mudsync/gameobj.scm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mudsync/gameobj.scm b/mudsync/gameobj.scm index 6011be2..21c6559 100644 --- a/mudsync/gameobj.scm +++ b/mudsync/gameobj.scm @@ -32,6 +32,7 @@ #:use-module (oop goops) #:export ( + create-gameobj gameobj-loc gameobj-gm @@ -187,6 +188,27 @@ ;;; gameobj message handlers ;;; ======================== +;; TODO: This init stuff is a mess, and should be redone now that +;; we have the *init* action stuff. We've really spread out the +;; logic for creating a gameobj in several places, eg gm-inject-special! +(define (create-gameobj class gm loc . args) + "Create a gameobj of CLASS with GM and set to location LOC, applying rest of ARGS. +Note that this doesn't do any special dyn-ref of the location." + (let ((new-gameobj (apply create-actor (%current-actor) class + #:gm gm args))) + ;; Set the location + (<-wait new-gameobj 'set-loc! #:loc loc) + ;; Initialize the object + (<-wait new-gameobj 'init))) + +;; ;; @@: Should we also dyn-ref the loc here? We can do that, unlike with +;; ;; create-gameobj. +;; ;; Another route could be to have set-loc! itself know how to use the +;; ;; dyn-ref. +;; (define (gameobj-create-gameobj gameobj class loc . args) +;; "Like create-gameobj but saves the step of passing in the gm." +;; (apply create-gameobj class (gameobj-gm gameobj) loc args)) + ;; Kind of a useful utility, maybe? (define (simple-slot-getter slot) (lambda (actor message) @@ -455,6 +477,8 @@ By default, this is whether or not the generally-visible flag is set." (match special-symbol ;; if it's a symbol, look it up dynamically ((? symbol? _) + ;; TODO: If we get back an #f at this point, should we throw + ;; an error? Obviously #f is okay, but maybe not if (mbody-val (<-wait (slot-ref gameobj 'gm) 'lookup-special #:symbol special-symbol))) ;; if it's false, return nothing -- 2.31.1