lisdude / toaststunt

A network accessible, multi-user, programmable, interactive system for the creation of LambdaMOO style MOOs / MUDs.
63 stars 27 forks source link

:waifs() Built-In #58

Open biscuitWizard opened 2 years ago

biscuitWizard commented 2 years ago

Added a builtin that returns all waifs called "waifs()"

It is garbage collector safe and doesn't maintain a reference to waifs.

For example:

;$waif
=> #118  (Generic Waif)
@prop me.test {} +rwc
Property added with value {}.
;me.test = {$waif:new()}
=> {[[class = #118, owner = #2]]}
;waifs()
=> {[[class = #118, owner = #2]]}
;me.test = {} 
=> {}
;waifs()
=> {}

When the game recycles the WAIF it also removes it from the cache of all waif references. This is much faster than the in-moo implementation of searching every property on every object in the game and is much safer.

biscuitWizard commented 2 years ago

I've also added an optional argument that lets you specify the type of waif you are looking for:

@prop me.test {} +rwc
Property added with value {}.
;me.test = {$waif:new()}
=> {[[class = #118, owner = #2]]}
;waifs($waif)
=> {[[class = #118, owner = #2]]}
@create $waif named "Mysterious Waif"
You now have Mysterious Waif with object number #64 and parent Generic Waif (#118).
;waifs(#64)
=> {}
;waif_stats()
=> ["pending_recycle" -> 0, "total" -> 0]
;me.test = {#64:new()}
=> {[[class = #64, owner = #2]]}
;waifs(#64)
=> {[[class = #64, owner = #2]]}
;waifs($waif)
=> {}