Allow entity-map:get-entity to accept a default value if none is found
This commit is contained in:
parent
43b3681b70
commit
bc2e3064d9
1 changed files with 4 additions and 2 deletions
|
@ -70,10 +70,12 @@ and integer already. Returns false if passed an invalid entity."
|
|||
((integer? entity) entity)
|
||||
(else (error "Invalid entity-key parameter" entity))))
|
||||
|
||||
(define (get-entity entity-map entity)
|
||||
(define* (get-entity entity-map entity #:key (default #f))
|
||||
"Returns the entity with the supplied entity-id if one exists.
|
||||
Returns false if no entity exists with that id."
|
||||
(hashtable-ref (entity-map-entities entity-map) (entity-key entity) #f))
|
||||
(hashtable-ref (entity-map-entities entity-map)
|
||||
(entity-key entity)
|
||||
default))
|
||||
|
||||
(define* (get-entities entity-map #:key (criteria? game-entity?))
|
||||
"Returns a list of all entities. When criteria? is provided,
|
||||
|
|
Loading…
Reference in a new issue