mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 19:45:22 +09:00
Added Quickbar filters
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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-ext=No external source was found, cannot display server ups.
|
||||
6
locale/en/data.cfg
Normal file
6
locale/en/data.cfg
Normal file
@@ -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.
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
45
modules/data/quickbar.lua
Normal file
45
modules/data/quickbar.lua
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user