mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Iterate save using pairs instaid of ipairs, remove erronus require, add save fuction
This commit is contained in:
@@ -141,7 +141,8 @@ Roles.new_role('Sponsor','Spon')
|
|||||||
'command/home-get',
|
'command/home-get',
|
||||||
'command/return',
|
'command/return',
|
||||||
'fast-tree-decon',
|
'fast-tree-decon',
|
||||||
'command/load-quickbar'
|
'command/load-quickbar',
|
||||||
|
'command/save-quickbar'
|
||||||
}
|
}
|
||||||
|
|
||||||
Roles.new_role('Supporter','Sup')
|
Roles.new_role('Supporter','Sup')
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
--[[-- Commands Module - Quickbar
|
--[[-- Commands Module - Quickbar
|
||||||
- Adds a command that allows players to load Quickbar presets
|
- Adds a command that allows players to load Quickbar presets
|
||||||
@commands LoadQuickbar
|
@commands LoadQuickbar
|
||||||
|
@commands SaveQuickbar
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||||
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
local Game = require 'utils.game' --- @dep utils.game
|
||||||
local config = require 'config.preset_player_quickbar' --- @dep config.preset_player_quickbar
|
local config = require 'config.preset_player_quickbar' --- @dep config.preset_player_quickbar
|
||||||
require 'config.expcore.command_general_parse'
|
|
||||||
|
|
||||||
|
|
||||||
--- Loads your quickbar preset
|
--- Loads your quickbar preset
|
||||||
@@ -16,10 +16,29 @@ Commands.new_command('load-quickbar','Loads your preset Quickbar items')
|
|||||||
:register(function(player)
|
:register(function(player)
|
||||||
if config[player.name] then
|
if config[player.name] then
|
||||||
local custom_quickbar = config[player.name]
|
local custom_quickbar = config[player.name]
|
||||||
for i, item_name in ipairs(custom_quickbar) do
|
for i, item_name in pairs(custom_quickbar) do
|
||||||
player.set_quick_bar_slot(i, item_name)
|
if item_name ~= nil and item_name ~= '' then
|
||||||
|
player.set_quick_bar_slot(i, item_name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Commands.error('Quickbar preset not found')
|
Commands.error('Quickbar preset not found')
|
||||||
end
|
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')
|
||||||
|
:register(function(player)
|
||||||
|
local quickbar_names = {}
|
||||||
|
for i=1, 100 do
|
||||||
|
local slot = player.get_quick_bar_slot(i)
|
||||||
|
if slot ~= nil then
|
||||||
|
table.insert(quickbar_names, slot.name)
|
||||||
|
else
|
||||||
|
table.insert(quickbar_names, "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
game.write_file("quickbar_preset.txt", game.table_to_json(quickbar_names), false)
|
||||||
|
Commands.print("Quickbar saved to local script-output folder")
|
||||||
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user