Skip to content

Add ESX.GetConfig optional parameter#1667

Merged
Kenshiin13 merged 2 commits into
esx-framework:devfrom
Zykem:getconfig-single-value-2
Jul 6, 2025
Merged

Add ESX.GetConfig optional parameter#1667
Kenshiin13 merged 2 commits into
esx-framework:devfrom
Zykem:getconfig-single-value-2

Conversation

@Zykem

@Zykem Zykem commented Jul 6, 2025

Copy link
Copy Markdown
Member

Description

This PR enhances the ESX.GetConfig() function to accept an optional key parameter.
When provided, the function returns a specific config value instead of the full config table.
This change maintains backward compatibility.


Motivation

Currently, to retrieve a single config value, you are forced to pull the entire Config table using ESX.GetConfig().
This is unnecessary in most cases and leads to inefficient code.
By allowing key-based access, we simplify config lookups and reduce coupling to internal config structure.


Implementation Details

  • Modified the ESX.GetConfig() function to accept an optional key.
  • If the key is present, Config[key] is returned. Otherwise, the whole config is returned as before.
  • Updated the type annotations to reflect the new return type (any).

Usage Example

-- Getting whole config:
local config = ESX.GetConfig()

-- Checking if EnableDebug is enabled
local debugEnabled = ESX.GetConfig("EnableDebug")

PR Checklist

  • [1] My commit messages and PR title follow the Conventional Commits standard.
  • [] My changes have been tested locally and function as expected.
  • [1] My PR does not introduce any breaking changes.
  • [1] I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.

@github-project-automation github-project-automation Bot moved this to 🆕 To be Discussed in ESX Roadmap Jul 6, 2025

@Kenshiin13 Kenshiin13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks!

@github-project-automation github-project-automation Bot moved this from 🆕 To be Discussed to Ready for Next Update in ESX Roadmap Jul 6, 2025
@Kenshiin13 Kenshiin13 merged commit e79c781 into esx-framework:dev Jul 6, 2025
1 check passed
@Kenshiin13

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for Next Update

Development

Successfully merging this pull request may close these issues.

3 participants