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

Settings API improvements #452

Merged
merged 9 commits into from
Jan 17, 2025
Merged

Settings API improvements #452

merged 9 commits into from
Jan 17, 2025

Conversation

marchc1
Copy link
Member

@marchc1 marchc1 commented Jan 16, 2025

Significantly removes the amount of setup to create a server-side setting.

Previously, to set up a server-side setting, you had to call several functions in three different files...


acf/core/globals.lua

ACF.RequireFuel          = true

acf/menu/data_callbacks.lua

RequireFuel = function(Player, _, Value)
    local Bool = tobool(Value)
    if ACF.RequireFuel == Bool then return end
    ACF.RequireFuel = Bool
    if CLIENT and not IsValid(Player) then return end
    Message("Info", "Engine fuel requirements have been " .. (Bool and "enabled." or "disabled."))
end,

acf/persisted_vars/vars_sv.lua

ACF.PersistServerData("RequireFuel", true)

... which can now be consolidated into a single call in acf/core/globals.lua:

ACF.DefineSetting("RequireFuel", true, "Engine fuel requirements have been %s.", ACF.BooleanDataCallback())

@marchc1
Copy link
Member Author

marchc1 commented Jan 16, 2025

Hold on; going to try something to make panels simpler as well

There might be a better way to do it, but this is the simplest I can think of right now and it works
@LiddulBOFH
Copy link
Member

Looks good, will definitely make this sort of work much easier. Another notch towards #230 as well.

@marchc1
Copy link
Member Author

marchc1 commented Jan 17, 2025

Going to merge to dev then

@marchc1 marchc1 merged commit d26a777 into dev Jan 17, 2025
3 checks passed
@marchc1 marchc1 removed the request for review from thecraftianman January 17, 2025 00:02
@marchc1 marchc1 deleted the settings-changes-2 branch January 17, 2025 00:02
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