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

add a way to check if an Instance is part of a family in scripting #416

Open
2 tasks done
F3der1co opened this issue Jan 8, 2025 · 0 comments
Open
2 tasks done

Comments

@F3der1co
Copy link

F3der1co commented Jan 8, 2025

Reviewed guidelines

  • I have read and understand the suggestion guidelines

Checked for duplicate suggestions

  • I checked for existing similar suggestions

Summary

Currently I am not aware of any way to know if an instance or object is part of a specific family in scripting.

Possible workarounds or alternatives

none that I am aware of. (aside from looping through every families instances and compare uid)

Proposed solution

A way to query if an instance is in a family.
could be: IInstance.isInFamily(runtime.objects.SpriteFam) //or maybe just pass the name as string?
could also be on IObjectClass, or both, but on IInstance will be the most useful.

Why is this idea important?

Sometimes you want to run logic only if an instance is part of a specific family and this cannot be infered in cases were you haven't gotten the instance by that family.
for example *children(), getInstanceByUId() or any case where you got it by its base type or a different family.

example:

for (const child of player.children()) {
    if (child.isInFamily(runtime.objects.arms)) {
            equipWeapon(child)
        }
    }

(this specific example case could also be solved by an objectType specific children iterator, but a general solution for this problem makes sense regardless)

Additional remarks

No response

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

No branches or pull requests

1 participant