Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:waifs() Built-In #58

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

biscuitWizard
Copy link
Contributor

@biscuitWizard biscuitWizard commented Jan 20, 2022

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
Copy link
Contributor Author

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)
=> {}

@biscuitWizard biscuitWizard changed the title All waifs :waifs() Built-In Jan 20, 2022
StraylightRunMOO added a commit to StraylightRunMOO/toaststunt that referenced this pull request Apr 5, 2023
MAX_BASE_FUNC overflow causes function 256 (counting from 0) to overflow, creating a call to function 0 (run_gc)

Checking out from master, the function is `char_list()`. Checking `;function_info()[257][1]` should tell you the affected builtin if you're running a modified build.

Before:
```
;char_list("bob")
#-1:Input to EVAL (this == #-1), line 3:  Incorrect number of arguments (expected 0; got 1)
... called from built-in function eval()
... called from lisdude#58:eval_cmd_string, line 19
... called from lisdude#58:eval*-d, line 13
(End of traceback)
```

After:
```
;char_list("bob")
=> {"b", "o", "b"}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant