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 support for area_pos1 and area_pos2 chatcommands to accept coordinates separated by commas AND spaces #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lumberjackgames
Copy link

Add support for area_pos1 and area_pos2 chatcommands to accept coordinates separated by commas AND spaces rather than only commas OR spaces. Will also handle combinations of both such as caused by typos (e.g. /area_pos 1, 2,3)

Comment on lines +50 to 51
local found, _, x, y, z = param:gsub(", ", ","):find(
"^(-?%d+)[, ](-?%d+)[, ](-?%d+)$")
Copy link
Member

@SmallJoker SmallJoker Mar 17, 2024

Choose a reason for hiding this comment

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

Suggestion: instead of additional processing, fix the regular expression.
This here works: "^(-?%d+)[, ] *(-?%d+)[, ] *(-?%d+)$"

FYI: The Minetest builtin commands parse it like this: https://github.com/minetest/minetest/blob/master/builtin/game/chat.lua#L584
Those also support relative positions, which however is not a feature we need in this case (player position is too unrealiable).

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