From: Christopher Allan Webber Date: Mon, 30 Jan 2017 01:58:03 +0000 (-0600) Subject: create-gameobj X-Git-Tag: fosdem-2017~42 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=9588c965d19182edf4d8ee752bc880ff5a0945dc;p=mudsync.git create-gameobj --- 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