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

Unintuitive change: checking a number for string type #680

Closed
SwissalpS opened this issue Aug 15, 2024 · 3 comments
Closed

Unintuitive change: checking a number for string type #680

SwissalpS opened this issue Aug 15, 2024 · 3 comments

Comments

@SwissalpS
Copy link
Contributor

SwissalpS commented Aug 15, 2024

If anything this should check for number not string and then meta:set_int()
https://github.com/minetest-mods/mesecons/blame/d52eac5a4afec3d68f39224a8da541b3ba52b561/mesecons_detector/init.lua#L226

Having to pass a number as a string is not intuitive at all. This is even worse than the zero based-ness of this value.

In lua indexes begin with 1 not 0 and I can't think of any other node that treats distance this way. Everywhere else radius/distance of 0 is the node itself, a radius of 1 are the eight 26 nodes around it and a distance of 1 a node next to it.

It may be too late to change to 1-based distance, but IMO the distance field should be treated as a number not a string.

(It is ruining my automated blueberry fields because the code used to accept a number for the distance field, but now the number is ignored and the wrong nodes are being dug. These blueberry leaves can't be dug and placed, they need to be grown in place or moved using pistons and similar.)

Sorry for the forceful tone, I admit I'm venting a bit.

@sfan5
Copy link
Member

sfan5 commented Aug 15, 2024

0c7bb31 | #670

@SwissalpS
Copy link
Contributor Author

The traceback shows that the error was thrown for using meta:set_string() with a table as value.
I agree with type checking, but not for string.

The value is then correctly read as int.

local distance = meta:get_int("distance")

Wouldn't it be correct to check the digiline msg.distance for an integer and then use meta:set_int()?

@sfan5 sfan5 closed this as completed in fe57ade Aug 15, 2024
@SwissalpS
Copy link
Contributor Author

Thank you.

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

2 participants