mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Merge pull request #156 from kevintayloruk/feature/loadquickbar
Feature/loadquickbar
This commit is contained in:
@@ -27,6 +27,7 @@ return {
|
||||
'modules.commands.find',
|
||||
'modules.commands.bonus',
|
||||
'modules.commands.home',
|
||||
'modules.commands.quickbar',
|
||||
-- QoL Addons
|
||||
'modules.addons.station-auto-name',
|
||||
'modules.addons.greetings',
|
||||
@@ -57,4 +58,4 @@ return {
|
||||
'config.expcore.command_runtime_disable', -- allows commands to be enabled and disabled during runtime
|
||||
'config.expcore.permission_groups', -- loads some predefined permission groups
|
||||
'config.expcore.roles', -- loads some predefined roles
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +141,8 @@ Roles.new_role('Sponsor','Spon')
|
||||
'command/home-get',
|
||||
'command/return',
|
||||
'fast-tree-decon',
|
||||
'command/load-quickbar',
|
||||
'command/save-quickbar'
|
||||
}
|
||||
|
||||
Roles.new_role('Supporter','Sup')
|
||||
|
||||
6
config/preset_player_quickbar.lua
Normal file
6
config/preset_player_quickbar.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
--- Preset quickbar items that players can load
|
||||
-- @config Preset-Player-Quickbar
|
||||
|
||||
return {
|
||||
dangerarea = {"transport-belt", "underground-belt", "splitter", "pipe", "pipe-to-ground", "inserter", "fast-inserter", "long-handed-inserter", "stack-inserter", "roboport", "small-electric-pole", "medium-electric-pole", "big-electric-pole", "substation", nil, "rail", "rail-signal", "rail-chain-signal", "landfill", "cliff-explosives", "fast-transport-belt", "fast-underground-belt", "fast-splitter", "pipe", "pipe-to-ground", "fast-inserter", "long-handed-inserter", "stack-inserter", "stack-filter-inserter", "roboport", [81] = "red-wire", [82] = "green-wire", [83] = "arithmetic-combinator", [84] = "decider-combinator", [85] = "constant-combinator", [86] = "power-switch", [91] = "logistic-chest-active-provider", [92] = "logistic-chest-passive-provider", [93] = "logistic-chest-storage", [94] = "logistic-chest-buffer", [95] = "logistic-chest-requester", [96] = "roboport"}
|
||||
}
|
||||
43
modules/commands/quickbar.lua
Normal file
43
modules/commands/quickbar.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
--[[-- Commands Module - Quickbar
|
||||
- Adds a command that allows players to load Quickbar presets
|
||||
@commands Quickbar
|
||||
]]
|
||||
|
||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||
local Game = require 'utils.game' --- @dep utils.game
|
||||
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)
|
||||
Reference in New Issue
Block a user