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

Feature Request 1143: Added 'coordinate' arg type for ESX.RegisterCommand() #1154

Merged
merged 3 commits into from
Aug 18, 2023

Conversation

Kenshiin13
Copy link
Contributor

@Kenshiin13 Kenshiin13 commented Aug 15, 2023

Feature Enhancement: Introducing 'coordinate' Argument Type for setcoords Command

Description

This pull request introduces a new argument type, 'coordinate', to the existing setcoords command. The 'coordinate' argument type allows more flexible input formats for specifying coordinates, accommodating user feedback and enhancing usability. The changes are made in response to a feature request discussed in GitHub Issue #1143.

Changes Made

In this pull request, a new argument type 'coordinate' has been added to the setcoords command. The code snippet for handling this argument type has been enhanced as follows:

elseif v.type == 'coordinate' then
    local coord = tonumber(args[k]:match("(-?%d+%.?%d*)"))
    if not coord then
        error = TranslateCap('commanderror_argumentmismatch_number', k)
    else
        newArgs[v.name] = coord
    end
end

This allows users to provide coordinates in various formats such as:

  • {x:-1, y:2, z:3}
  • {x=-1.01, y=2.02, z=3.03}
  • -1, 2, 3
  • 474.08966064453, -1718.7073974609, 29.329517364502

Reasoning

The motivation behind this change is to enhance the user experience when utilizing the setcoords command. The feature request (#1143) highlighted the need for a more permissive coordinate input format to make the command more versatile and user-friendly. The new 'coordinate' argument type accommodates a wider range of coordinate representations, allowing users to input coordinates in a format that suits their preference. This change seeks to improve the overall usability and flexibility of the command, promoting a more intuitive interaction for users working with coordinates.

Inspiration

These improvements draw inspiration from the setCoords handler in txAdmin, which has demonstrated exceptional effectiveness in facilitating the use of multiple coordinate formats, greatly enhancing user convenience. The provided test cases are directly sourced from the txAdmin codebase, which serves as a reliable reference for the proposed enhancements.

Thank you for considering this enhancement to the setcoords command. Your feedback and suggestions are appreciated.

Related GitHub Issue #1143

@CsokiHUN CsokiHUN changed the base branch from main to dev August 17, 2023 18:53
@Gellipapa
Copy link
Contributor

Gellipapa commented Aug 17, 2023

Hi! @Kenshiin13 I like your suggestion, I'll test it tomorrow and if it works and handles everything I've done so push and merge it. This is a better implementation. Thanks a lot.

@Kenshiin13
Copy link
Contributor Author

Hi! @Kenshiin13 I like your suggestion, I'll test it tomorrow and if it works and handles everything I've done so push and merge it. This is a better implementation. Thanks a lot.

Thank you, let me know if there are any unexpected issues!

As requested in Issue 1143.
@Gellipapa
Copy link
Contributor

@Kenshiin13 Hi! Well done, I'll tested and merged.

@tekkenkkk
Copy link
Contributor

@Kenshiin13 thank you 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants