diff --git a/ExpCore/GuiParts/left.lua b/ExpCore/GuiParts/left.lua index 372f0289..ef42a7c6 100644 --- a/ExpCore/GuiParts/left.lua +++ b/ExpCore/GuiParts/left.lua @@ -160,8 +160,8 @@ function left._left.toggle(event) else left.style.visible = false end - if open == false then player_return({'gui.cant-open-no-reason'},defines.text_color.crit,player) player.play_sound{path='utility/cannot_build'} - elseif open ~= true then player_return({'gui.cant-open',open},defines.text_color.crit,player) player.play_sound{path='utility/cannot_build'} end + if open == false then player_return({'gui.cant-open-no-reason'},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} + elseif open ~= true then player_return({'gui.cant-open',open},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} end end -- draws the left guis when a player first joins, fake_event is just because i am lazy diff --git a/ExpCore/commands.lua b/ExpCore/commands.lua index f8e9de87..05986d75 100644 --- a/ExpCore/commands.lua +++ b/ExpCore/commands.lua @@ -82,7 +82,7 @@ local function run_custom_command(command) local player_name = Game.get_player(command) and Game.get_player(command).name or 'server' -- is the player allowed to use this command if is_type(Ranking,'table') and Ranking._presets and Ranking._presets().meta.rank_count > 0 and not Ranking.get_rank(player_name):allowed(command.name) then - player_return({'commands.unauthorized'},defines.text_color.crit) + player_return({'commands.unauthorized'},defines.textcolor.crit) if game.player then game.player.play_sound{path='utility/cannot_build'} end game.write_file('commands.log', game.tick @@ -96,7 +96,7 @@ local function run_custom_command(command) -- gets the args for the command local args, valid = command_args(command,command_data) if not valid then - player_return({'commands.invalid-inputs',command.name,command_inputs(command_data)},defines.text_color.high) + player_return({'commands.invalid-inputs',command.name,command_inputs(command_data)},defines.textcolor.high) if game.player then game.player.play_sound{path='utility/deconstruct_big'} end game.write_file('commands.log', game.tick @@ -110,7 +110,7 @@ local function run_custom_command(command) -- runs the command local success, err = pcall(command_calls[command.name],command,args) if not success then error(err) end - if err ~= commands.error and player_name ~= 'server' then player_return({'commands.command-ran'},defines.text_color.info) end + if err ~= commands.error and player_name ~= 'server' then player_return({'commands.command-ran'},defines.textcolor.info) end game.write_file('commands.log', game.tick ..' Player: "'..player_name..'"' diff --git a/ExpCore/ranking.lua b/ExpCore/ranking.lua index 8d0549d2..29750360 100644 --- a/ExpCore/ranking.lua +++ b/ExpCore/ranking.lua @@ -121,7 +121,7 @@ end -- @param[opt='server'] by_player the player who is giving the rank -- @param[opt=game.tick] tick the tick that the rank is being given on function Ranking.give_rank(player,rank,by_player,tick) - local print_colour = defines.text_color.info + local print_colour = defines.textcolor.info local tick = tick or game.tick local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or game.player and game.player.name or is_type(by_player,'string') and by_player or 'server' local rank = Ranking.get_rank(rank) or Ranking.get_rank(Ranking._presets().meta.default) @@ -154,7 +154,7 @@ function Ranking.give_rank(player,rank,by_player,tick) if rank.group.name == 'Jail' and Ranking._presets().last_jail ~= player.name then Sync.emit_embeded{ title='Player Jail', - color=Color.to_hex(defines.text_color.med), + color=Color.to_hex(defines.textcolor.med), description='There was a player jailed.', ['Player:']=player.name, ['By:']='<>'..by_player_name, diff --git a/ExpCore/server.lua b/ExpCore/server.lua index c765c428..d4f77b07 100644 --- a/ExpCore/server.lua +++ b/ExpCore/server.lua @@ -122,7 +122,7 @@ function Server._thread_handler(event) table.each(Server._threads().print_to,function(print_to,player_index,event) if event.name == defines.events.on_tick then return true end if print_to[event.name] then - player_return(event,defines.text_color.bg,player_index) + player_return(event,defines.textcolor.bg,player_index) end end,event) local event_id = event.name diff --git a/ExpCore/sync.lua b/ExpCore/sync.lua index 4cfb4aa2..913ee247 100644 --- a/ExpCore/sync.lua +++ b/ExpCore/sync.lua @@ -93,7 +93,7 @@ end -- set up error handle verbose('Set New Error Handle') _G.error_handle = function(err) - local color = _G.Color and Color.to_hex(defines.text_color.bg) or '0x0' + local color = _G.Color and Color.to_hex(defines.textcolor.bg) or '0x0' Sync.emit_embeded{title='SCRIPT ERROR',color=color,description='There was an error in the script @Developers ',Error=err} end diff --git a/FactorioSoftmodManager.lua b/FactorioSoftmodManager.lua index 4daef9f1..cfaa326c 100644 --- a/FactorioSoftmodManager.lua +++ b/FactorioSoftmodManager.lua @@ -91,15 +91,25 @@ end -- @usage Manager.setVerbose[setting] -- returns the value of that setting -- @usage tostring(Manager.setVerbose) -- returns a formated list of the current settings Manager.setVerbose = setmetatable( + --- Different verbose settings used for setVerbose + -- @table Manager.verboseSettings + -- @tfield boolean selfInit called while the manager is being set up + -- @tfield boolean moduleLoad when a module is required by the manager + -- @tfield boolean moduleInit when and within the initation of a module + -- @tfield boolean moduleEnv during module runtime, this is a global option set within each module(module_verbose=true ln:1) for fine control + -- @tfield boolean eventRegistered when a module registers its event handlers + -- @tfield boolean errorCaught when an error is caught during runtime + -- @tfield function output can be: print || log || or other function + -- @field _output a constant value that can used to store output data { - selfInit=true, -- called while the manager is being set up - moduleLoad=false, -- when a module is required by the manager - moduleInit=false, -- when and within the initation of a module - moduleEnv=false, -- during module runtime, this is a global option set within each module(module_verbose=true ln:1) for fine control - eventRegistered=false, -- when a module registers its event handlers - errorCaught=true, -- when an error is caught during runtime - output=Manager._verbose, -- can be: print || log || or other function - _output={} -- a constant value that can used to store output data + selfInit=true, + moduleLoad=false, + moduleInit=false, + moduleEnv=false, + eventRegistered=false, + errorCaught=true, + output=Manager._verbose, + _output={} }, { __metatable=false, @@ -442,7 +452,6 @@ Manager.event = setmetatable({ --- Sub set to Manger.event and acts as a coverter between event_name and event_id -- @table Manager.event.names -- @usage Manager.event[event_name] --- @see Manager.event rawset(Manager.event,'names',setmetatable({},{ __index=function(tbl,key) if type(key) == 'number' or tonumber(key) then diff --git a/doc/index.html b/doc/index.html index 3856ff87..0c5889c6 100644 --- a/doc/index.html +++ b/doc/index.html @@ -45,9 +45,9 @@
  • ExpGamingLib
  • Color
  • Game
  • -
  • string
  • -
  • table
  • -
  • defines.time
  • +
  • String
  • +
  • Table
  • +
  • Time
  • Scripts

    Scripts

    Scripts

    Scripts

    Scripts

    Scripts

    Scripts

    Scripts

    Scripts

    Scripts

    Scripts

    Scripts

    Scripts

    Scripts

    Scripts

    Scripts

    @@ -78,7 +78,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-29 20:54:20 +Last updated 2018-05-29 22:53:53
    diff --git a/doc/scripts/index.lua.html b/doc/scripts/index.lua.html index ac0f9c3b..aeb35e86 100644 --- a/doc/scripts/index.lua.html +++ b/doc/scripts/index.lua.html @@ -53,9 +53,9 @@
  • ExpGamingLib
  • Color
  • Game
  • -
  • string
  • -
  • table
  • -
  • defines.time
  • +
  • String
  • +
  • Table
  • +
  • Time
  • @@ -78,7 +78,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-29 20:54:20 +Last updated 2018-05-29 22:53:53
    diff --git a/modules/ExpGamingLib/control.lua b/modules/ExpGamingLib/control.lua index efd40bd5..3cd59332 100644 --- a/modules/ExpGamingLib/control.lua +++ b/modules/ExpGamingLib/control.lua @@ -63,7 +63,7 @@ end -- @tparam[opt=defines.colour.white] ?defines.color|string colour the colour of the text for the player, ingroned when printing to console -- @tparam[opt=game.player] LuaPlayer player the player that return will go to, if no game.player then returns to server function ExpLib.player_return(rtn,colour,player) - local colour = ExpLib.is_type(colour) == 'table' and colour or defines.text_color[colour] ~= defines.color.white and defines.text_color[colour] or defines.color[colour] + local colour = ExpLib.is_type(colour) == 'table' and colour or defines.textcolor[colour] ~= defines.color.white and defines.textcolor[colour] or defines.color[colour] local player = player or game.player local function _return(callback,rtn) if ExpLib.is_type(rtn,'table') then diff --git a/modules/FactorioStdLib/color.lua b/modules/FactorioStdLib/color.lua index 2fe1e8e8..4a5e4c8d 100644 --- a/modules/FactorioStdLib/color.lua +++ b/modules/FactorioStdLib/color.lua @@ -12,125 +12,103 @@ defines = defines or {} --luacheck: ignore defines (This is used for testing locally) --- A table of colors allowing retrieval by color name. --- @usage color = defines.color.red --- @tfield Concepts.Color white --- @tfield Concepts.Color black --- @tfield Concepts.Color darkgrey --- @tfield Concepts.Color grey --- @tfield Concepts.Color lightgrey --- @tfield Concepts.Color red --- @tfield Concepts.Color darkred --- @tfield Concepts.Color lightred --- @tfield Concepts.Color green --- @tfield Concepts.Color darkgreen --- @tfield Concepts.Color lightgreen --- @tfield Concepts.Color blue --- @tfield Concepts.Color darkblue --- @tfield Concepts.Color lightblue --- @tfield Concepts.Color orange --- @tfield Concepts.Color yellow --- @tfield Concepts.Color pink --- @tfield Concepts.Color purple --- @tfield Concepts.Color brown +-- @table defines.color +-- @field white {r=1.00,g=1.00,b=1.00} +-- @field black {r=0.00,g=0.00,b=0.00} +-- @field darkgrey {r=0.25,g=0.25,b=0.25} +-- @field grey {r=0.50,g=0.50,b=0.50} +-- @field lightgrey {r=0.75,g=0.75,b=0.75} +-- @field red {r=1.00,g=0.00,b=0.00} +-- @field darkred {r=0.50,g=0.00,b=0.00} +-- @field lightred {r=1.00,g=0.50,b=0.50} +-- @field green {r=0.00,g=1.00,b=0.00} +-- @field darkgreen {r=0.00,g=0.50,b=0.00} +-- @field lightgreen {r=0.50,g=1.00,b=0.50} +-- @field blue {r=0.00,g=0.00,b=1.00} +-- @field darkblue {r=0.00,g=0.00,b=0.50} +-- @field lightblue {r=0.50,g=0.50,b=1.00} +-- @field orange {r=1.00,g=0.55,b=0.10} +-- @field yellow {r=1.00,g=1.00,b=0.00} +-- @field pink {r=1.00,g=0.00,b=1.00} +-- @field purple {r=0.60,g=0.10,b=0.60} +-- @field brown {r=0.60,g=0.40,b=0.10} defines.color = { - white = {r = 1.00, g = 1.00, b = 1.00}, - black = {r = 0.00, g = 0.00, b = 0.00}, - darkgrey = {r = 0.25, g = 0.25, b = 0.25}, - grey = {r = 0.50, g = 0.50, b = 0.50}, - lightgrey = {r = 0.75, g = 0.75, b = 0.75}, - red = {r = 1.00, g = 0.00, b = 0.00}, - darkred = {r = 0.50, g = 0.00, b = 0.00}, - lightred = {r = 1.00, g = 0.50, b = 0.50}, - green = {r = 0.00, g = 1.00, b = 0.00}, - darkgreen = {r = 0.00, g = 0.50, b = 0.00}, - lightgreen = {r = 0.50, g = 1.00, b = 0.50}, - blue = {r = 0.00, g = 0.00, b = 1.00}, - darkblue = {r = 0.00, g = 0.00, b = 0.50}, - lightblue = {r = 0.50, g = 0.50, b = 1.00}, - orange = {r = 1.00, g = 0.55, b = 0.10}, - yellow = {r = 1.00, g = 1.00, b = 0.00}, - pink = {r = 1.00, g = 0.00, b = 1.00}, - purple = {r = 0.60, g = 0.10, b = 0.60}, - brown = {r = 0.60, g = 0.40, b = 0.10} + white={r=1.00,g=1.00,b=1.00}, + black={r=0.00,g=0.00,b=0.00}, + darkgrey={r=0.25,g=0.25,b=0.25}, + grey={r=0.50,g=0.50,b=0.50}, + lightgrey={r=0.75,g=0.75,b=0.75}, + red={r=1.00,g=0.00,b=0.00}, + darkred={r=0.50,g=0.00,b=0.00}, + lightred={r=1.00,g=0.50,b=0.50}, + green={r=0.00,g=1.00,b=0.00}, + darkgreen={r=0.00,g=0.50,b=0.00}, + lightgreen={r=0.50,g=1.00,b=0.50}, + blue={r=0.00,g=0.00,b=1.00}, + darkblue={r=0.00,g=0.00,b=0.50}, + lightblue={r=0.50,g=0.50,b=1.00}, + orange={r=1.00,g=0.55,b=0.10}, + yellow={r=1.00,g=1.00,b=0.00}, + pink={r=1.00,g=0.00,b=1.00}, + purple={r=0.60,g=0.10,b=0.60}, + brown={r=0.60,g=0.40,b=0.10} } local colors = defines.color + --- Returns white for dark colors or black for lighter colors. --- @tfield Concepts.Color green defines.color.black --- @tfield Concepts.Color grey defines.color.black --- @tfield Concepts.Color lightblue defines.color.black --- @tfield Concepts.Color lightgreen defines.color.black --- @tfield Concepts.Color lightgrey defines.color.black --- @tfield Concepts.Color lightred defines.color.black --- @tfield Concepts.Color orange defines.color.black --- @tfield Concepts.Color white defines.color.black --- @tfield Concepts.Color yellow defines.color.black --- @tfield Concepts.Color black defines.color.white --- @tfield Concepts.Color blue defines.color.white --- @tfield Concepts.Color brown defines.color.white --- @tfield Concepts.Color darkblue defines.color.white --- @tfield Concepts.Color darkgreen defines.color.white --- @tfield Concepts.Color darkgrey defines.color.white --- @tfield Concepts.Color darkred defines.color.white --- @tfield Concepts.Color pink defines.color.white --- @tfield Concepts.Color purple defines.color.white --- @tfield Concepts.Color red defines.color.white +-- @table defines.anticolor defines.anticolor = { - green = colors.black, - grey = colors.black, - lightblue = colors.black, - lightgreen = colors.black, - lightgrey = colors.black, - lightred = colors.black, - orange = colors.black, - white = colors.black, - yellow = colors.black, - black = colors.white, - blue = colors.white, - brown = colors.white, - darkblue = colors.white, - darkgreen = colors.white, - darkgrey = colors.white, - darkred = colors.white, - pink = colors.white, - purple = colors.white, - red = colors.white + green = colors.black, -- defines.color.black + grey = colors.black, -- defines.color.black + lightblue = colors.black, -- defines.color.black + lightgreen = colors.black, -- defines.color.black + lightgrey = colors.black, -- defines.color.black + lightred = colors.black, -- defines.color.black + orange = colors.black, -- defines.color.black + white = colors.black, -- defines.color.black + yellow = colors.black, -- defines.color.black + black = colors.white, -- defines.color.white + blue = colors.white, -- defines.color.white + brown = colors.white, -- defines.color.white + darkblue = colors.white, -- defines.color.white + darkgreen = colors.white, -- defines.color.white + darkgrey = colors.white, -- defines.color.white + darkred = colors.white, -- defines.color.white + pink = colors.white, -- defines.color.white + purple = colors.white, -- defines.color.white + red = colors.white -- defines.color.white } --- Returns a lighter color of a named color. --- @tfield Concepts.Color white defines.color.lightgrey --- @tfield Concepts.Color grey defines.color.darkgrey --- @tfield Concepts.Color lightgrey defines.color.grey --- @tfield Concepts.Color red defines.color.lightred --- @tfield Concepts.Color green defines.color.lightgreen --- @tfield Concepts.Color blue defines.color.lightblue --- @tfield Concepts.Color yellow defines.color.orange --- @tfield Concepts.Color pink defines.color.purple +-- @table defines.lightcolor defines.lightcolor = { - white = colors.lightgrey, - grey = colors.darkgrey, - lightgrey = colors.grey, - red = colors.lightred, - green = colors.lightgreen, - blue = colors.lightblue, - yellow = colors.orange, - pink = colors.purple + white = colors.lightgrey, -- defines.color.lightgrey + grey = colors.darkgrey, -- defines.color.darkgrey + lightgrey = colors.grey, -- defines.color.grey + red = colors.lightred, -- defines.color.lightred + green = colors.lightgreen, -- defines.color.lightgreen + blue = colors.lightblue, -- defines.color.lightblue + yellow = colors.orange, -- defines.color.orange + pink = colors.purple -- defines.color.purple } --- added by cooldude2606 +-- added by cooldude260 + --- Returns a lighter color of a named color. --- @tfield Concepts.Color info --- @tfield Concepts.Color bg --- @tfield Concepts.Color low --- @tfield Concepts.Color med --- @tfield Concepts.Color high --- @tfield Concepts.Color crit -defines.text_color = { - info = {r = 0.21, g = 0.95, b = 1.00}, - bg = {r = 0.00, g = 0.00, b = 0.00}, - low = {r = 0.18, g = 0.77, b = 0.18}, - med = {r = 1.00, g = 0.89, b = 0.26}, - high = {r = 1.00, g = 0.33, b = 0.00}, - crit = {r = 1.00, g = 0.00, b = 0.00} +-- @table defines.textcolor +-- @field info {r=0.21,g=0.95,b=1.00} +-- @field bg {r=0.00,g=0.00,b=0.00} +-- @field low {r=0.18,g=0.77,b=0.18} +-- @field med {r=1.00,g=0.89,b=0.26} +-- @field high {r=1.00,g=0.33,b=0.00} +-- @field crit {r=1.00,g=0.00,b=0.00} +defines.textcolor = { + info={r=0.21,g=0.95,b=1.00}, + bg={r=0.00,g=0.00,b=0.00}, + low={r=0.18,g=0.77,b=0.18}, + med={r=1.00,g=0.89,b=0.26}, + high={r=1.00,g=0.33,b=0.00}, + crit={r=1.00,g=0.00,b=0.00} } -- metatable remade by cooldude @@ -152,7 +130,7 @@ local _mt = { setmetatable(defines.color, _mt) setmetatable(defines.anticolor, _mt) -setmetatable(defines.text_color, _mt) +setmetatable(defines.textcolor, _mt) setmetatable(defines.lightcolor, _mt) local Color = {} --luacheck: allow defined top @@ -166,7 +144,7 @@ local Color = {} --luacheck: allow defined top -- -- @tparam[opt=white] defines.color|Concepts.Color color the color to configure -- @tparam[opt=1] float alpha the alpha value (*[0 - 1]*) to set for the given color --- @treturn Concepts.Color a color table that has the specified value for the alpha channel +-- @treturn a color table that has the specified value for the alpha channel function Color.set(color, alpha) color = color or defines.color.white Color.to_table(color) @@ -176,7 +154,7 @@ end --- Converts a color in the array format to a color in the table format. -- @tparam table c_arr the color to convert --- @treturn Concepts.Color a converted color — { r = c\_arr[1], g = c\_arr[2], b = c\_arr[3], a = c\_arr[4] } +-- @treturn a converted color — { r = c\_arr[1], g = c\_arr[2], b = c\_arr[3], a = c\_arr[4] } function Color.to_table(c_arr) if #c_arr > 0 then return {r = c_arr[1], g = c_arr[2], b = c_arr[3], a = c_arr[4]} @@ -202,7 +180,7 @@ end -- Optionally provide the value for the alpha channel. -- @tparam string hex hexadecimal color string (#ffffff, not #fff) -- @tparam[opt=1] float alpha the alpha value to set; such that ***[ 0 ⋜ value ⋜ 1 ]*** --- @treturn Concepts.Color a color table with RGB converted from Hex and with alpha +-- @treturn a color table with RGB converted from Hex and with alpha function Color.from_hex(hex, alpha) if not _G.Game then error('StdLib/Game not loaded') end _G.Game.fail_if_missing(hex, "missing color hex value") diff --git a/modules/FactorioStdLib/table.lua b/modules/FactorioStdLib/table.lua index 1c8acd30..2afaf62b 100644 --- a/modules/FactorioStdLib/table.lua +++ b/modules/FactorioStdLib/table.lua @@ -69,11 +69,8 @@ end --- Given a candidate search function, iterates over the table, calling the function -- for each element in the table, and returns true if search function returned true. -- Passes the index as second argument to the function. --- @see table.find ---- @usage a= { 1, 2, 3, 4, 5} ----table.any(a, function(v) return v % 2 == 0 end) --produces: true ---- @usage a = {1, 2, 3, 4, 5} ----table.any(a, function(v, k, x) return k % 2 == 1 end) --produces: true +-- @usage a= { 1, 2, 3, 4, 5} table.any(a, function(v) return v % 2 == 0 end) --produces: true +-- @usage a = {1, 2, 3, 4, 5} table.any(a, function(v, k, x) return k % 2 == 1 end) --produces: true -- @tparam table tbl the table to be searched -- @tparam function func the function to use to search for any matching element -- @param[opt] ... additional arguments passed to the function diff --git a/modules/FactorioStdLib/time.lua b/modules/FactorioStdLib/time.lua index a7d9a128..f885f0e6 100644 --- a/modules/FactorioStdLib/time.lua +++ b/modules/FactorioStdLib/time.lua @@ -30,3 +30,7 @@ defines.time = { month = MONTH, -- the number of Factorio ticks in a month (30 days) year = YEAR, -- the number of Factorio ticks in a year (365 days) } + +--- Allows index to deines.time though the Time module +--@table Time +return setmetatable({},{__index=defines.time}) \ No newline at end of file