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

check if entity exists before accessing #68

Merged
merged 6 commits into from
Sep 4, 2023

Conversation

LaserWitch
Copy link
Contributor

I've run into a few panics with world access if you happen to hold on to entity values between frames. I'm not certain this is the ideal way to handle them, so feel free to suggest changes or go with an alternate implementation if desired.

Check if entities exist before trying to add components to them
Copy link
Owner

@makspll makspll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! Would you be okay adding similar checks where we use w.entity or w.entity_mut. Much appreciated!

bevy_script_api/src/sub_reflect.rs Outdated Show resolved Hide resolved
bevy_script_api/src/common/bevy/mod.rs Outdated Show resolved Hide resolved
@LaserWitch
Copy link
Contributor Author

Great catch! Would you be okay adding similar checks where we use w.entity or w.entity_mut. Much appreciated!

Yeah, I'll do a search and see how many other places I can add it in.

I'm honestly tempted to try to implement an option or result style construct in lua, perhaps leverage multiple value return, but I think I can experiment with that a bit further down stream for the time being.

@makspll
Copy link
Owner

makspll commented Aug 26, 2023

Yeah, I'll do a search and see how many other places I can add it in.

Thanks!

I'm honestly tempted to try to implement an option or result style construct in lua, perhaps leverage multiple value return, but I think I can experiment with that a bit further down stream for the time being.

I've considered something like this in the past, although I've stuck with the mlua convention of converting None -> nil and Error -> Runtime Error, while creating proxy types for things like Vec when maintaining pass-by-reference behavior's.

@LaserWitch
Copy link
Contributor Author

I've been lost in some other weeds the past week but I'll see if I can get this done this weekend.

@LaserWitch
Copy link
Contributor Author

I have some more bases covered now. There's some other things that look like potential cases that could be checked, but I wouldn't really want to mess with them without first having a test case that is known to fail, and building those tests cases is not something I'm up for doing at the moment

makspll
makspll previously approved these changes Sep 3, 2023
Copy link
Owner

@makspll makspll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, if we need any more checks anywhere else we can add later. Thanks!

@LaserWitch
Copy link
Contributor Author

Looks like I've finally made CI happy. Not sure why it says I dismissed the review above, that must have been something automatic.

@makspll
Copy link
Owner

makspll commented Sep 4, 2023

Yeah it's automatic, might disable that as the message looks quite confusing.

@makspll makspll merged commit 7590248 into makspll:main Sep 4, 2023
12 checks passed
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.

2 participants