Added toolbar aliases, Save as LUA table

This commit is contained in:
Kevin Taylor
2020-05-17 11:24:13 +01:00
parent d0a23a1a59
commit 6481cf9755
2 changed files with 7 additions and 7 deletions

View File

@@ -2,5 +2,5 @@
-- @config Preset-Player-Quickbar
return {
dangerarea={'transport-belt','fast-transport-belt'}
dangerarea={"transport-belt",[2]="fast-transport-belt","express-transport-belt",[11]="transport-belt",[23]="fast-transport-belt",[33]="express-transport-belt"}
}

View File

@@ -13,12 +13,13 @@ local config = require 'config.preset_player_quickbar' --- @dep config.preset_pl
--- 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)
player.set_quick_bar_slot(i, item_name)
end
end
else
@@ -29,16 +30,15 @@ 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
table.insert(quickbar_names, slot.name)
else
table.insert(quickbar_names, "")
table.insert(quickbar_names, i, slot.name)
end
end
game.write_file("quickbar_preset.txt", game.table_to_json(quickbar_names), false)
Commands.print("Quickbar saved to local script-output folder")
game.write_file("quickbar_preset.txt", player.name .. " = " .. serpent.line(quickbar_names) .. "\n", true)
Commands.print("Quickbar saved")
end)