diff --git a/config/_file_loader.lua b/config/_file_loader.lua index 8e9de264..65d8f093 100644 --- a/config/_file_loader.lua +++ b/config/_file_loader.lua @@ -29,7 +29,6 @@ return { 'modules.commands.find', 'modules.commands.bonus', 'modules.commands.home', - 'modules.commands.quickbar', --- Addons 'modules.addons.chat-popups', @@ -48,6 +47,7 @@ return { --- Data 'modules.data.player-colours', 'modules.data.greetings', + 'modules.data.quickbar', --- GUI 'modules.gui.readme', diff --git a/config/expcore/roles.lua b/config/expcore/roles.lua index 383569a4..3b4b225d 100644 --- a/config/expcore/roles.lua +++ b/config/expcore/roles.lua @@ -140,9 +140,7 @@ Roles.new_role('Sponsor','Spon') 'command/home-set', 'command/home-get', 'command/return', - 'fast-tree-decon', - 'command/load-quickbar', - 'command/save-quickbar' + 'fast-tree-decon' } Roles.new_role('Supporter','Sup') @@ -152,7 +150,9 @@ Roles.new_role('Supporter','Sup') :set_parent('Veteran') :allow{ 'command/jail', - 'command/unjail' + 'command/unjail', + 'command/join-message', + 'command/save-quickbar' } Roles.new_role('Partner','Part') diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index f4555dec..081b8f36 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -75,8 +75,4 @@ return-set=Your return point has been set to x: __1__ y: __2__ home-get=Your home point is at x: __1__ y: __2__ [expcom-server-ups] -no-ext=No external source was found, cannot display server ups. - -[expcom-join-message] -greet=[color=0,1,0] Welcome to explosive gaming community server! If you like the server join our discord: __1__ [/color] -message-set=Your join message has been updated. \ No newline at end of file +no-ext=No external source was found, cannot display server ups. \ No newline at end of file diff --git a/locale/en/data.cfg b/locale/en/data.cfg new file mode 100644 index 00000000..6816c16b --- /dev/null +++ b/locale/en/data.cfg @@ -0,0 +1,6 @@ +[join-message] +greet=[color=0,1,0] Welcome to explosive gaming community server! If you like the server join our discord: __1__ [/color] +message-set=Your join message has been updated. + +[quickbar] +saved=Your quickbar filters have been saved. \ No newline at end of file diff --git a/modules/commands/quickbar.lua b/modules/commands/quickbar.lua deleted file mode 100644 index c297ddfe..00000000 --- a/modules/commands/quickbar.lua +++ /dev/null @@ -1,40 +0,0 @@ ---[[-- Commands Module - Quickbar - - Adds a command that allows players to load Quickbar presets - @commands Quickbar -]] - -local Commands = require 'expcore.commands' --- @dep expcore.commands -local config = require 'config.preset_player_quickbar' --- @dep config.preset_player_quickbar - ---- Loads your quickbar preset --- @command load-quickbar -Commands.new_command('load-quickbar', 'Loads your preset Quickbar items') -:add_alias('load-toolbar') -:register(function(player) - if config[player.name] then - local custom_quickbar = config[player.name] - for i, item_name in pairs(custom_quickbar) do - if item_name ~= nil and item_name ~= '' then - player.set_quick_bar_slot(i, item_name) - end - end - else - Commands.error('Quickbar preset not found') - end -end) - ---- Saves your quickbar preset to the script-output folder --- @command save-quickbar -Commands.new_command('save-quickbar', 'Saves your Quickbar preset items to file') -:add_alias('save-toolbar') -:register(function(player) - local quickbar_names = {} - for i=1, 100 do - local slot = player.get_quick_bar_slot(i) - if slot ~= nil then - quickbar_names[i] = slot.name - end - end - game.write_file("quickbar_preset.txt", player.name .. " = " .. serpent.line(quickbar_names) .. "\n", true) - Commands.print("Quickbar saved") -end) diff --git a/modules/data/greetings.lua b/modules/data/greetings.lua index 45d487f7..6816d0cc 100644 --- a/modules/data/greetings.lua +++ b/modules/data/greetings.lua @@ -15,7 +15,7 @@ CustomMessages:on_load(function(player_name, player_message) if custom_message then game.print(custom_message, player.color) else - player.print{'expcom-join-message.greet', {'links.discord'}} + player.print{'join-message.greet', {'links.discord'}} end end) @@ -28,5 +28,5 @@ Commands.new_command('join-message', 'Sets your custom join message') :register(function(player, message) if not player then return end CustomMessages:set(player, message) - return {'expcom-join-message.message-set'} + return {'join-message.message-set'} end) \ No newline at end of file diff --git a/modules/data/quickbar.lua b/modules/data/quickbar.lua new file mode 100644 index 00000000..5c53f183 --- /dev/null +++ b/modules/data/quickbar.lua @@ -0,0 +1,45 @@ +--[[-- Commands Module - Quickbar + - Adds a command that allows players to load Quickbar presets + @commands Quickbar +]] + +local Commands = require 'expcore.commands' --- @dep expcore.commands +local config = require 'config.preset_player_quickbar' --- @dep config.preset_player_quickbar + +--- Stores the quickbar filters for a player +local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data +local PlayerFilters = PlayerData.Settings:combine('QuickbarFilters') + +--- Loads your quickbar preset +PlayerFilters:on_load(function(player_name, filters) + if not filters then filters = config[player_name] end + if not filters then return end + local player = game.players[player_name] + for i, item_name in pairs(filters) do + if item_name ~= nil and item_name ~= '' then + player.set_quick_bar_slot(i, item_name) + end + end +end) + +--- Saves your quickbar preset to the script-output folder +-- @command save-quickbar +Commands.new_command('save-quickbar', 'Saves your Quickbar preset items to file') +:add_alias('save-toolbar') +:register(function(player) + local filters = {} + for i = 1, 100 do + local slot = player.get_quick_bar_slot(i) + if slot ~= nil then + filters[i] = slot.name + end + end + + if next(filters) then + PlayerFilters:set(player, filters) + else + PlayerFilters:remove(player) + end + + return {'quickbar.saved'} +end) \ No newline at end of file