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

Handle invalid param2 in presets.lua #623

Merged
merged 1 commit into from
Sep 11, 2022

Conversation

TurkeyMcMac
Copy link
Contributor

Fixes #610.

To test, load up devtest with Mesecons and homedecor_lighting. Place a Mesecons lever and, separately, a homedecor:glowlight_small_cube_14. Use the param2 tool to set the lever's param2 to 25 and the light's param2 to 6. Try turning on the lever. Then try turning on the light using a switch adjacent to it. The game should not crash.

@sfan5
Copy link
Member

sfan5 commented Aug 25, 2022

Can't we place the check closer to the cause of the issue?

@TurkeyMcMac
Copy link
Contributor Author

We could validate the param2 values, but that would be more complicated. I see the current approach as similar to checking for NaN after doing a numeric calculation.

Really the root cause is some other mod changing param2 values willy-nilly, but Mesecons has no control of that.

Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

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

I would also expect an empty table of rules if there is none for the current mesecon direction.
Looks good 👍

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.

Attempt to index nil value caused by nodes with invalid param2
3 participants