Skip to content

Commit

Permalink
added custom config option
Browse files Browse the repository at this point in the history
  • Loading branch information
DerpleMQ2 committed Dec 31, 2023
1 parent 9504746 commit 68ad0e9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
12 changes: 7 additions & 5 deletions class_configs/shd_class_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,19 @@ local Tooltips = {
}

local _ClassConfig = {
['Modes'] = {
_version = "0.1a",
_author = "Derple",
['Modes'] = {
[1] = 'Tank',
[2] = 'DPS',
},
['ItemSets'] = {
['ItemSets'] = {
['Epic'] = {
[1] = "Innoruuk's Dark Blessing",
[2] = "Innoruuk's Voice",
},
},
['AbilitySets'] = {
['AbilitySets'] = {
['Mantle'] = {
[1] = "Malarian Mantle",
[2] = "Gorgon Mantle",
Expand Down Expand Up @@ -540,7 +542,7 @@ local _ClassConfig = {
[5] = "Ignominious Influence",
},
},
['Rotations'] = {
['Rotations'] = {
['Downtime'] = {
[1] = {
name = "Dark Lord's Unity (Azia)",
Expand Down Expand Up @@ -1002,7 +1004,7 @@ local _ClassConfig = {
},
},
},
['Spells'] = {
['Spells'] = {
[1] = {
gem = 1,
spells = {
Expand Down
31 changes: 25 additions & 6 deletions modules/shd.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
-- Sample Basic Class Module
local mq = require('mq')
local RGMercsLogger = require("rgmercs.utils.rgmercs_logger")
local RGMercUtils = require("rgmercs.utils.rgmercs_utils")
local shdClassConfig = require("rgmercs.class_configs.shd_class_config")
local mq = require('mq')
local RGMercsLogger = require("rgmercs.utils.rgmercs_logger")
local RGMercUtils = require("rgmercs.utils.rgmercs_utils")

local custom_config_file = mq.configDir .. "/rgmercs/class_configs/shd_class_config.lua"

local shdClassConfig = nil
if RGMercUtils.file_exists(custom_config_file) then
RGMercsLogger.log_info("Loading Custom SK Config: %s", custom_config_file)
local config, err = loadfile(custom_config_file)
if not config or err then
RGMercsLogger.log_error("Failed to Load Custom SK Config: %s", custom_config_file)
else
shdClassConfig = config()
end
end

if not shdClassConfig then
printf(custom_config_file)
shdClassConfig = require("rgmercs.class_configs.shd_class_config")
end


local Module = { _version = '0.1a', name = "ShadowKnight", author = 'Derple' }
Module.__index = Module
Expand Down Expand Up @@ -34,12 +52,13 @@ function Module:SaveSettings(doBroadcast)
end

function Module:LoadSettings()
RGMercsLogger.log_info("Basic Combat Module Loading Settings for: %s.", RGMercConfig.Globals.CurLoadedChar)
RGMercsLogger.log_info("\arShadowKnight\ao Combat Module Loading Settings for: %s.", RGMercConfig.Globals.CurLoadedChar)
RGMercsLogger.log_info("\ayUsing Class Config by: \at%s\ay (\am%s\ay)", shdClassConfig._author, shdClassConfig._version)
local settings_pickle_path = getConfigFileName()

local config, err = loadfile(settings_pickle_path)
if err or not config then
RGMercsLogger.log_error("\ay[Basic]: Unable to load global settings file(%s), creating a new one!",
RGMercsLogger.log_error("\ay[ShadowKnight]: Unable to load global settings file(%s), creating a new one!",
settings_pickle_path)
self.settings = {}
self:SaveSettings(true)
Expand Down
10 changes: 10 additions & 0 deletions utils/rgmercs_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ Utils.ScriptName = "RGMercs"
Utils.LastZoneID = 0
Utils.NamedList = {}

function Utils.file_exists(path)
local f = io.open(path, "r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end

function Utils.BroadcastUpdate(module, event)
Utils.Actors.send({ from = RGMercConfig.Globals.CurLoadedChar, script = Utils.ScriptName, module = module, event = event })
end
Expand Down

0 comments on commit 68ad0e9

Please sign in to comment.