From f5153f368684e91a44fba8d515a8eb7d4b4d8a5b Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Tue, 29 May 2018 20:15:20 +0100 Subject: [PATCH] Doc Added --- ExpCore/GuiParts/center.lua | 6 +- ExpCore/GuiParts/inputs.lua | 19 +- ExpCore/GuiParts/toolbar.lua | 2 +- ExpCore/commands.lua | 2 +- ExpCore/gui.lua | 17 +- ExpCore/ranking.lua | 5 +- ExpCore/server.lua | 8 +- ExpCore/sync.lua | 24 +- FactorioSoftmodManager.lua | 13 +- StdLib/event.lua | 172 --- control.lua | 4 +- doc/index.html | 155 +++ doc/ldoc.css | 303 +++++ doc/modules/Event.html | 210 +++ doc/modules/FSM.html | 337 +++++ doc/modules/Game.html | 231 ++++ doc/modules/defines.color.html | 519 ++++++++ doc/modules/defines.time.html | 148 +++ doc/modules/expcore.commands.html | 136 ++ doc/modules/expcore.gui.html | 172 +++ doc/modules/expcore.guiparts.center.html | 290 +++++ doc/modules/expcore.guiparts.inputs.html | 446 +++++++ doc/modules/expcore.guiparts.left.html | 193 +++ doc/modules/expcore.guiparts.popup.html | 138 ++ doc/modules/expcore.guiparts.toolbar.html | 129 ++ doc/modules/expcore.ranking.html | 386 ++++++ doc/modules/expcore.server.html | 571 ++++++++ doc/modules/expcore.sync.html | 542 ++++++++ doc/modules/modules.expgaminglib.control.html | 350 +++++ doc/modules/string.html | 310 +++++ doc/modules/table.html | 1145 +++++++++++++++++ doc/scripts/control.lua.html | 85 ++ doc/scripts/index.lua.html | 85 ++ modules/ExpGamingLib/control.lua | 40 +- {StdLib => modules/FactorioStdLib}/LICENSE | 0 {StdLib => modules/FactorioStdLib}/color.lua | 7 +- {StdLib => modules/FactorioStdLib}/game.lua | 0 {StdLib => modules/FactorioStdLib}/load.lua | 0 modules/FactorioStdLib/softmod.json | 14 + {StdLib => modules/FactorioStdLib}/string.lua | 0 {StdLib => modules/FactorioStdLib}/table.lua | 4 +- {StdLib => modules/FactorioStdLib}/time.lua | 0 modules/index.lua | 2 + 43 files changed, 6979 insertions(+), 241 deletions(-) delete mode 100644 StdLib/event.lua create mode 100644 doc/index.html create mode 100644 doc/ldoc.css create mode 100644 doc/modules/Event.html create mode 100644 doc/modules/FSM.html create mode 100644 doc/modules/Game.html create mode 100644 doc/modules/defines.color.html create mode 100644 doc/modules/defines.time.html create mode 100644 doc/modules/expcore.commands.html create mode 100644 doc/modules/expcore.gui.html create mode 100644 doc/modules/expcore.guiparts.center.html create mode 100644 doc/modules/expcore.guiparts.inputs.html create mode 100644 doc/modules/expcore.guiparts.left.html create mode 100644 doc/modules/expcore.guiparts.popup.html create mode 100644 doc/modules/expcore.guiparts.toolbar.html create mode 100644 doc/modules/expcore.ranking.html create mode 100644 doc/modules/expcore.server.html create mode 100644 doc/modules/expcore.sync.html create mode 100644 doc/modules/modules.expgaminglib.control.html create mode 100644 doc/modules/string.html create mode 100644 doc/modules/table.html create mode 100644 doc/scripts/control.lua.html create mode 100644 doc/scripts/index.lua.html rename {StdLib => modules/FactorioStdLib}/LICENSE (100%) rename {StdLib => modules/FactorioStdLib}/color.lua (97%) rename {StdLib => modules/FactorioStdLib}/game.lua (100%) rename {StdLib => modules/FactorioStdLib}/load.lua (100%) create mode 100644 modules/FactorioStdLib/softmod.json rename {StdLib => modules/FactorioStdLib}/string.lua (100%) rename {StdLib => modules/FactorioStdLib}/table.lua (99%) rename {StdLib => modules/FactorioStdLib}/time.lua (100%) diff --git a/ExpCore/GuiParts/center.lua b/ExpCore/GuiParts/center.lua index 0cf0f107..9179df26 100644 --- a/ExpCore/GuiParts/center.lua +++ b/ExpCore/GuiParts/center.lua @@ -38,7 +38,7 @@ end --- Used to open a center frame for a player -- @usage Gui.center.open(player,'server-info') -- return true -- @param player a player indifier to get the flow for --- @tparam center string the name of the center frame to open +-- @tparam string center the name of the center frame to open -- @treturn boelon based on if it successed or not function center.open(player,center) local player = Game.get_player(player) @@ -54,8 +54,8 @@ end --- Used to open a center frame for a player -- @usage Gui.center.open_tab(player,'readme','rules') -- return true -- @param player a player indifier to get the flow for --- @tparam center string the name of the center frame to open --- @tparam tab string the name of the tab to open +-- @tparam string center the name of the center frame to open +-- @tparam string tab the name of the tab to open -- @treturn boelon based on if it successed or not function center.open_tab(player,center,tab) local player = Game.get_player(player) diff --git a/ExpCore/GuiParts/inputs.lua b/ExpCore/GuiParts/inputs.lua index 73e249e1..605a7518 100644 --- a/ExpCore/GuiParts/inputs.lua +++ b/ExpCore/GuiParts/inputs.lua @@ -182,9 +182,9 @@ end --- Used to define a choose-elem-button callback only on elem_changed -- @usage Gui.inputs.add_elem_button('test','Test','Just for testing',function) -- @tparam string name the name of this button --- @tparam string the display for this button, either text or sprite path +-- @tparam string elem_type the display for this button, either text or sprite path -- @tparam string tooltip the tooltip to show on the button --- @tparam function the callback to call on change function(player,element,elem) +-- @tparam function callback the callback to call on change function(player,element,elem) -- @treturn table the button object that was made, to allow a custom error event if wanted function inputs.add_elem_button(name,elem_type,tooltip,callback) local button = inputs.add{ @@ -210,9 +210,11 @@ end --- Used to define a checkbox callback only on state_changed -- @usage Gui.inputs.add_checkbox('test',false,'Just for testing',function,function,funvtion) -- @tparam string name the name of this button --- @tparam string the display for this button, either text or sprite path --- @tparam string tooltip the tooltip to show on the button --- @tparam function the callback to call on change function(player,element,elem) +-- @tparam boolean radio if this is a radio button +-- @tparam string display the display for this button, either text or sprite path +-- @tparam function default the callback which choses the default check state +-- @tparam function callback_true the callback to call when changed to true +-- @tparam function callback_false the callback to call when changed to false -- @treturn table the button object that was made, to allow a custom error event if wanted function inputs.add_checkbox(name,radio,display,default,callback_true,callback_false) local type = 'checkbox'; if radio then type='radiobutton' end @@ -279,7 +281,7 @@ end -- @tparam string name the name of this button -- @tparam boolean box is it a text box rather than a text field -- @tparam string text the starting text --- @tparam function the callback to call on change function(player,text,element) +-- @tparam function callback the callback to call on change function(player,text,element) -- @treturn table the text object that was made, to allow a custom error event if wanted function inputs.add_text(name,box,text,callback) local type = 'textfield'; if box then type='text-box' end @@ -305,10 +307,10 @@ end --- Used to define a slider callback only on value_changed -- @usage Gui.inputs.add_slider('test','horizontal',1,10,5,function) -- @tparam string name the name of this button --- @tapram string text the caption to go with the slider +-- @tparam string orientation direction of the slider -- @tparam number min the lowest number -- @tparam number max the highest number --- @param start_callback either a number or a function to return a number +-- @tparam function start_callback either a number or a function to return a number -- @tparam function callback the function to be called on value_changed function(player,value,percent,element) -- @treturn table the slider object that was made, to allow a custom error event if wanted function inputs.add_slider(name,orientation,min,max,start_callback,callback) @@ -338,6 +340,7 @@ end --- Used to define a drop down callback only on value_changed -- @usage Gui.inputs.add_drop_down('test',{1,2,3},1,function) +-- @tparam string name name of the drop down -- @param items either a list or a function which returns a list -- @param index either a number or a function which returns a number -- @tparam function callback the callback which is called when a new index is selected function(player,selected,items,element) diff --git a/ExpCore/GuiParts/toolbar.lua b/ExpCore/GuiParts/toolbar.lua index f197312e..7c515f9d 100644 --- a/ExpCore/GuiParts/toolbar.lua +++ b/ExpCore/GuiParts/toolbar.lua @@ -13,7 +13,7 @@ local toolbar = {} -- @usage toolbar.add('foo','Foo','Test',function() game.print('test') end) -- @tparam string name the name of the button -- @tparam string caption can be a sprite path or text to show --- @tparma string tooltip the help to show for the button +-- @tparam string tooltip the help to show for the button -- @tparam function callback the function which is called on_click -- @treturn table the button object that was made function toolbar.add(name,caption,tooltip,callback) diff --git a/ExpCore/commands.lua b/ExpCore/commands.lua index 8b6ca10e..f8e9de87 100644 --- a/ExpCore/commands.lua +++ b/ExpCore/commands.lua @@ -76,7 +76,7 @@ end --- Used to call the custom commands -- @usage You dont its an internal command --- @tparam defines.events.on_console_command event the event rasied by the command= +-- @tparam defines.events.on_console_command command the event rasied by the command local function run_custom_command(command) local command_data = command_data[command.name] local player_name = Game.get_player(command) and Game.get_player(command).name or 'server' diff --git a/ExpCore/gui.lua b/ExpCore/gui.lua index d5649e79..a3ee80da 100644 --- a/ExpCore/gui.lua +++ b/ExpCore/gui.lua @@ -97,14 +97,15 @@ end) --- Adds a camera that updates every tick (or less depeading on how many are opening) it will move to follow an entity -- @usage Gui.cam_link{entity=game.player.character,frame=frame,width=50,hight=50,zoom=1} -- @usage Gui.cam_link{entity=game.player.character,cam=frame.camera,surface=game.surfaces['testing']} --- @param entity this is the entity that the camera will follow --- @param[opt] cam a camera that you already have in the gui --- @param[opt] frame the frame to add the camera to, no effect if cam param is given --- @param[chain=frame] zoom the zoom to give the new camera --- @param[chain=frame] width the width to give the new camera --- @param[chain=frame] height the height to give the new camera --- @param[opt] surface this will over ride the surface that the camera follows on, allowing for a 'ghost surface' while keeping same position --- @param[opt] respawn_open if set to true then the camera will auto re link to the player after a respawn +-- @tparam table data contains all other params given below +-- @field entity this is the entity that the camera will follow +-- @field cam a camera that you already have in the gui +-- @field frame the frame to add the camera to, no effect if cam param is given +-- @field zoom the zoom to give the new camera +-- @field width the width to give the new camera +-- @field height the height to give the new camera +-- @field surface this will over ride the surface that the camera follows on, allowing for a 'ghost surface' while keeping same position +-- @field respawn_open if set to true then the camera will auto re link to the player after a respawn -- @return the camera that the function used be it made or given as a param function Gui.cam_link(data) if not data.entity or not data.entity.valid then return end diff --git a/ExpCore/ranking.lua b/ExpCore/ranking.lua index bad35ad0..8d0549d2 100644 --- a/ExpCore/ranking.lua +++ b/ExpCore/ranking.lua @@ -97,6 +97,7 @@ end -- @usage Ranking.print('admin','We got a grifer') -- @param rank_base the rank that acts as the cut off point (rank is always included) -- @param rtn what do you want to return to the players +-- @tparam defines.color colour the colour that will be used to print -- @tparam bolean below if true rank below base are printed to function Ranking.print(rank_base,rtn,colour,below) local colour = colour or defines.color.white @@ -185,7 +186,7 @@ end --- Given the player has a rank in the preset table it is given -- @usage Ranking.find_preset(1) -- @param player the player to test for an auto rank --- @tparam[opt=nil] tick the tick it happens on +-- @tparam[opt=nil] number tick the tick it happens on function Ranking.find_preset(player,tick) local presets = Ranking._presets().current local meta_data = Ranking._presets().meta @@ -250,6 +251,8 @@ end --- Print a message to all players of this rank -- @usage rank:print('foo') -- @param rtn any value you want to return +-- @tparam define.color colour the colour that will be used to print +-- @tparam boolean show_default weather to use the default rank name for the print function Ranking._rank:print(rtn,colour,show_default) local colour = colour or defines.color.white local meta_data = Ranking._presets().meta diff --git a/ExpCore/server.lua b/ExpCore/server.lua index ed79419c..c765c428 100644 --- a/ExpCore/server.lua +++ b/ExpCore/server.lua @@ -63,8 +63,8 @@ end --- Adds a thread into the resolve queue, can be used to lower lag -- @usage Server.queue_thread(thread) -- return true/false --- @tparam table the thread to add to the queue must have a resolve function (must be open) --- @treturn bolean was the thread added +-- @tparam table thread_to_queue the thread to add to the queue must have a resolve function (must be open) +-- @treturn boolean was the thread added function Server.queue_thread(thread_to_queue) if not thread_to_queue and not thread_to_queue.valid and not thread_to_queue:valid() then return false end if not thread_to_queue._resolve then return false end @@ -87,7 +87,7 @@ function Server.close_all_threads(with_force) end --- Runs all the theads which have opened with an on_tick event --- @ussage Server.run_tick_threads() +-- @usage Server.run_tick_threads() function Server.run_tick_threads() table.each(Server._threads().tick,function(uuid) local next_thread = Server.get_thread(uuid) @@ -99,7 +99,7 @@ function Server.run_tick_threads() end --- Checks the timeout on all active timeout threads --- @ussage Server.check_timeouts() +-- @usage Server.check_timeouts() function Server.check_timeouts() table.each(Server._threads().timeout,function(uuid) local next_thread = Server.get_thread(uuid) diff --git a/ExpCore/sync.lua b/ExpCore/sync.lua index dec82cf8..4cfb4aa2 100644 --- a/ExpCore/sync.lua +++ b/ExpCore/sync.lua @@ -29,7 +29,7 @@ end -- @param player_message the message to be printed in chat -- @param player_name the name of the player sending the message -- @param[opt] player_tag the tag apllied to the player's name --- @param[opt] plyaer_colour the colour of the message +-- @param[opt] player_colour the colour of the message -- @param[opt] prefix add a prefix before the chat eg [IRC] function Sync.print(player_message,player_name,player_tag,player_colour,prefix) if not player_message then return 'No Message Found' end @@ -53,13 +53,13 @@ end --- Logs an embed to the json.data we use a js script to add things we cant here -- @usage Sync.emit_embeded{title='BAN',color='0x0',description='A player was banned' ... } --- @tparam table arg a table which contains everything that the embeded will use --- @param[opt=''] title the tile of the embed --- @param[opt='0x0'] color the color given in hex you can use Color.to_hex{r=0,g=0,b=0} --- @param[opt=''] description the description of the embed --- @param[opt=''] server_detail sting to add onto the pre-set server detail --- @param[opt] fieldone the filed to add to the embed (key is name) (value is text) (start value with <> to make inline) --- @param[optchain] fieldtwo +-- @tparam table args a table which contains everything that the embeded will use +-- @field title the tile of the embed +-- @field color the color given in hex you can use Color.to_hex{r=0,g=0,b=0} +-- @field description the description of the embed +-- @field server_detail sting to add onto the pre-set server detail +-- @field fieldone the filed to add to the embed (key is name) (value is text) (start value with <> to make inline) +-- @field fieldtwo the filed to add to the embed (key is name) (value is text) (start value with <> to make inline) function Sync.emit_embeded(args) if not is_type(args,'table') then return end local title = is_type(args.title,'string') and args.title or '' @@ -166,7 +166,7 @@ end --- used to return the global list and set values in it -- @usage Sync.info{server_name='Factorio Server 2'} --- @tparam[opt=nil] table keys to be replaced in the server info +-- @tparam[opt=nil] table set keys to be replaced in the server info -- @return either returns success when setting or the info when not setting function Sync.info(set) if not global.exp_core then global.exp_core = {} end @@ -203,7 +203,7 @@ end --- used to return the global time and set its value -- @usage Sync.time('Sun Apr 1 18:44:30 UTC 2018') --- @tparam[opt=nil] string the date time to be set +-- @tparam[opt=nil] string set the date time to be set -- @return either true false if setting or the date time and tick off set function Sync.time(set) local info = Sync.info() @@ -242,8 +242,8 @@ end --- Adds a callback to be called when the info is updated -- @usage Sync.add_update('players',function() return #game.players end) --- @tparam key string the key that the value will be stored in --- @tparam callback function the function which will return this value +-- @tparam string key the key that the value will be stored in +-- @tparam function callback the function which will return this value function Sync.add_update(key,callback) if game then return end if not is_type(callback,'function') then return end diff --git a/FactorioSoftmodManager.lua b/FactorioSoftmodManager.lua index 34580b2c..cb1137fb 100644 --- a/FactorioSoftmodManager.lua +++ b/FactorioSoftmodManager.lua @@ -1,3 +1,8 @@ +--- Factorio Softmod Manager +-- @module FSM +-- @alias Manager +-- @author Cooldude2606 +-- @usage Manager = require("FactorioSoftmodManager") -- Used to load all other modules that are indexed in index.lua local moduleIndex = require("/modules/index") local Manager = {} @@ -46,7 +51,7 @@ Manager.currentState = 'selfInit' --- Default output for the verbose -- @usage Manager.verbose('Hello, World!') --- @tparm rtn string the value that will be returned though verbose output +-- @tparam string rtn the value that will be returned though verbose output Manager._verbose = function(rtn) -- creates one file per game, ie clears file on reset if game and Manager.setVerbose._output ~= true then Manager.setVerbose._output=true game.write_file('verbose.log',rtn) @@ -58,8 +63,8 @@ end --- Used to call the output of the verbose when the current state allows it -- @usage Manager.verbose('Hello, World!') --- @tparm rtn string the value that will be returned though verbose output --- @tparm action string is used to decide which verbose this is error || event etc +-- @tparam string rtn the value that will be returned though verbose output +-- @tparam string action is used to decide which verbose this is error || event etc Manager.verbose = function(rtn,action) local settings = Manager.setVerbose local state = Manager.currentState @@ -428,7 +433,9 @@ Manager.event = setmetatable({ end }) --- Sub set to Manger.event and acts as a coverter between event_name and event_id +-- @field names -- @usage Manager.event[event_name] -- see above, can not be accessed via Manager.event.names +-- @see Manager.event rawset(Manager.event,'names',setmetatable({},{ __index=function(tbl,key) if type(key) == 'number' or tonumber(key) then diff --git a/StdLib/event.lua b/StdLib/event.lua deleted file mode 100644 index 9a4a380b..00000000 --- a/StdLib/event.lua +++ /dev/null @@ -1,172 +0,0 @@ ---- Makes working with events in factorio a lot more simple. ---

Factorio can only have one handler registered per event. This module --- allows you to easily register multiple handlers for each event. --- Using this module is as simple as replacing script.on_event(...) with Event.register(...)

--- @module Event --- @usage require('stdlib/event/event') - -local Event = { --luacheck: allow defined top - _registry = {}, - core_events = { - init = -1, - load = -2, - configuration_changed = -3, - _register = function(id) - if id == Event.core_events.init then - script.on_init( - function() - Event.dispatch({name = Event.core_events.init, tick = game.tick}) - end - ) - elseif id == Event.core_events.load then - script.on_load( - function() - Event.dispatch({name = Event.core_events.load, tick = -1}) - end - ) - elseif id == Event.core_events.configuration_changed then - script.on_configuration_changed( - function(event) - event.name = Event.core_events.configuration_changed - event.data = event -- for backwards compatibilty - Event.dispatch(event) - end - ) - end - end - } -} - ---[[ edit by cooldude2606 to allow change during run-time without desyncs -- still going to use this but FACTORIO NO LIKE -Event.__registry = Event._registry -Event._registry = function() - if game and global then - if not global.event_registry then global.event_registry = Event.__registry end - return global.event_registry - end - return Event.__registry -end]] - ---- Registers a function for a given event. If a nil handler is passed remove all events and stop listening for that event. --- Events are dispatched in the order they are registered. --- @usage Event.register(defines.events.on_tick, function(event) print event.tick end) --- -- creates an event that prints the current tick every tick. --- @tparam defines.events|{defines.events,...} event events to register --- @tparam function handler Function to call when event is triggered --- @treturn Event -function Event.register(event, handler) - if not _G.Game then error('StdLib/Game not loaded') end - _G.Game.fail_if_missing(event, "missing event argument") - - event = (type(event) == "table" and event) or {event} - - for _, event_id in pairs(event) do - if not (type(event_id) == "number" or type(event_id) == "string") then - error("Invalid Event Id, Must be string or int, or array of strings and/or ints", 2) - end - if handler == nil then - Event._registry[event_id] = nil - script.on_event(event_id, nil) - else - if not Event._registry[event_id] then - Event._registry[event_id] = {} - - if type(event_id) == "string" or event_id >= 0 then - script.on_event(event_id, Event.dispatch) - elseif event_id < 0 then - Event.core_events._register(event_id) - end - end - table.insert(Event._registry[event_id], handler) - end - end - return Event -end - ---- Calls the registerd handlers --- Will stop dispatching remaning handlers if any handler passes invalid event userdata. --- Handlers are dispatched in the order they were created --- @tparam table event LuaEvent as created by script.raise_event --- @see https://forums.factorio.com/viewtopic.php?t=32039#p202158 Invalid Event Objects -function Event.dispatch(event) - if event then - local _registry = event.name and Event._registry[event.name] or event.input_name and Event._registry[event.input_name] - if _registry then - local force_crc = Event.force_crc - for idx, handler in ipairs(_registry) do - - -- Check for userdata and stop processing further handlers if not valid - for _, val in pairs(event) do - if type(val) == "table" and val.__self == "userdata" and not val.valid then - return - end - end - - setmetatable(event, { __index = { _handler = handler } }) - - -- Call the handler - local success, err = pcall(handler, event) - - -- If the handler errors lets make sure someone notices - if not success then - if _G.game then -- may be nil in on_load - -- edit by cooldude2606 custom error haddle - --if Game.print_all(err) == 0 then - --error(err) -- no players received the message, force a real error so someone notices - --end - error(err) - else - error(err) -- no way to handle errors cleanly when the game is not up - end - -- continue processing the remaning handlers. In most cases they won't be related to the failed code. - end - - -- force a crc check if option is enabled. This is a debug option and will hamper perfomance if enabled - if (force_crc or event.force_crc) and _G.game then - local msg = 'CRC check called for event '..event.name..' handler #'..idx - log(msg) -- log the message to factorio-current.log - game.force_crc() - end - - -- if present stop further handlers for this event - if event.stop_processing then - return - end - end - end - else - error('missing event argument') - end -end - ---- Removes the handler from the event. If it removes the last handler for an event stop listening for that event. --- @tparam defines.events|{defines.events,...} event events to remove the handler for --- @tparam function handler to remove --- @return Event -function Event.remove(event, handler) - if not _G.Game then error('StdLib/Game not loaded') end - _G.Game.fail_if_missing(event, "missing event argument") - _G.Game.fail_if_missing(handler, "missing handler argument") - - event = (type(event) == "table" and event) or {event} - - for _, event_id in pairs(event) do - if not (type(event_id) == "number" or type(event_id) == "string") then - error("Invalid Event Id, Must be string or int, or array of strings and/or ints", 2) - end - if Event._registry[event_id] then - for i=#Event._registry[event_id], 1, -1 do - if Event._registry[event_id][i] == handler then - table.remove(Event._registry[event_id], i) - end - end - if #Event._registry[event_id] == 0 then - Event._registry[event_id] = nil - script.on_event(event_id, nil) - end - end - end - return Event -end - -return Event \ No newline at end of file diff --git a/control.lua b/control.lua index fe3b3285..9aba66bc 100644 --- a/control.lua +++ b/control.lua @@ -1,3 +1,5 @@ +--- Root Script File +-- @script control.lua function _log(...) log(...) end --[[ Explosive Gaming @@ -8,8 +10,6 @@ Any changes that you may make to the code are yours but that does not make the s Discord: https://discord.gg/r6dC2uK ]] --Please Only Edit Below This Line----------------------------------------------------------- - --- File Which Factorio Will Call Manager = require("FactorioSoftmodManager") Manager.setVerbose{ selfInit=true, -- called while the manager is being set up diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 00000000..a9153abb --- /dev/null +++ b/doc/index.html @@ -0,0 +1,155 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ + + +

Modules

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
expcore.guiparts.centerAdds a new obj to the center gui
expcore.guiparts.inputsSets the input to trigger on an certain event
expcore.guiparts.leftUsed to add a left gui frame
expcore.guiparts.popupUsed to add a popup gui style
expcore.guiparts.toolbarAdd a button to the toolbar, ranks need to be allowed to use these buttons if ranks is preset
expcore.commandsUses a commands data to return the inputs as a string
expcore.guiAdd a white bar to any gui frame
expcore.rankingReturns a rank object given a player or rank name
expcore.serverReturns a un-used uuid (better system needed)
expcore.syncUsed as a faster way to get to the ranking function, overrides previous
FSMFactorio Softmod Manager
modules.expgaminglib.controlLoads a table into _G even when sandboxed; will not overwrite values or append to tables; will not work during runtime to avoid desyncs
defines.colorA defines module for retrieving colors by name.
GameThe game module.
stringExtends Lua 5.2 string.
tableExtends Lua 5.2 table.
defines.timeA defines module for retrieving the number of ticks in 1 unit of time.
+

Scripts

+ + + + + + + + + +
control.luaRoot Script File
index.luaUsed to index the files to be loaded
+ +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/ldoc.css b/doc/ldoc.css new file mode 100644 index 00000000..52c4ad2b --- /dev/null +++ b/doc/ldoc.css @@ -0,0 +1,303 @@ +/* BEGIN RESET + +Copyright (c) 2010, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.com/yui/license.html +version: 2.8.2r1 +*/ +html { + color: #000; + background: #FFF; +} +body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { + margin: 0; + padding: 0; +} +table { + border-collapse: collapse; + border-spacing: 0; +} +fieldset,img { + border: 0; +} +address,caption,cite,code,dfn,em,strong,th,var,optgroup { + font-style: inherit; + font-weight: inherit; +} +del,ins { + text-decoration: none; +} +li { + margin-left: 20px; +} +caption,th { + text-align: left; +} +h1,h2,h3,h4,h5,h6 { + font-size: 100%; + font-weight: bold; +} +q:before,q:after { + content: ''; +} +abbr,acronym { + border: 0; + font-variant: normal; +} +sup { + vertical-align: baseline; +} +sub { + vertical-align: baseline; +} +legend { + color: #000; +} +input,button,textarea,select,optgroup,option { + font-family: inherit; + font-size: inherit; + font-style: inherit; + font-weight: inherit; +} +input,button,textarea,select {*font-size:100%; +} +/* END RESET */ + +body { + margin-left: 1em; + margin-right: 1em; + font-family: arial, helvetica, geneva, sans-serif; + background-color: #ffffff; margin: 0px; +} + +code, tt { font-family: monospace; font-size: 1.1em; } +span.parameter { font-family:monospace; } +span.parameter:after { content:":"; } +span.types:before { content:"("; } +span.types:after { content:")"; } +.type { font-weight: bold; font-style:italic } + +body, p, td, th { font-size: .95em; line-height: 1.2em;} + +p, ul { margin: 10px 0 0 0px;} + +strong { font-weight: bold;} + +em { font-style: italic;} + +h1 { + font-size: 1.5em; + margin: 20px 0 20px 0; +} +h2, h3, h4 { margin: 15px 0 10px 0; } +h2 { font-size: 1.25em; } +h3 { font-size: 1.15em; } +h4 { font-size: 1.06em; } + +a:link { font-weight: bold; color: #004080; text-decoration: none; } +a:visited { font-weight: bold; color: #006699; text-decoration: none; } +a:link:hover { text-decoration: underline; } + +hr { + color:#cccccc; + background: #00007f; + height: 1px; +} + +blockquote { margin-left: 3em; } + +ul { list-style-type: disc; } + +p.name { + font-family: "Andale Mono", monospace; + padding-top: 1em; +} + +pre { + background-color: rgb(245, 245, 245); + border: 1px solid #C0C0C0; /* silver */ + padding: 10px; + margin: 10px 0 10px 0; + overflow: auto; + font-family: "Andale Mono", monospace; +} + +pre.example { + font-size: .85em; +} + +table.index { border: 1px #00007f; } +table.index td { text-align: left; vertical-align: top; } + +#container { + margin-left: 1em; + margin-right: 1em; + background-color: #f0f0f0; +} + +#product { + text-align: center; + border-bottom: 1px solid #cccccc; + background-color: #ffffff; +} + +#product big { + font-size: 2em; +} + +#main { + background-color: #f0f0f0; + border-left: 2px solid #cccccc; +} + +#navigation { + float: left; + width: 14em; + vertical-align: top; + background-color: #f0f0f0; + overflow: visible; +} + +#navigation h2 { + background-color:#e7e7e7; + font-size:1.1em; + color:#000000; + text-align: left; + padding:0.2em; + border-top:1px solid #dddddd; + border-bottom:1px solid #dddddd; +} + +#navigation ul +{ + font-size:1em; + list-style-type: none; + margin: 1px 1px 10px 1px; +} + +#navigation li { + text-indent: -1em; + display: block; + margin: 3px 0px 0px 22px; +} + +#navigation li li a { + margin: 0px 3px 0px -1em; +} + +#content { + margin-left: 14em; + padding: 1em; + width: 700px; + border-left: 2px solid #cccccc; + border-right: 2px solid #cccccc; + background-color: #ffffff; +} + +#about { + clear: both; + padding: 5px; + border-top: 2px solid #cccccc; + background-color: #ffffff; +} + +@media print { + body { + font: 12pt "Times New Roman", "TimeNR", Times, serif; + } + a { font-weight: bold; color: #004080; text-decoration: underline; } + + #main { + background-color: #ffffff; + border-left: 0px; + } + + #container { + margin-left: 2%; + margin-right: 2%; + background-color: #ffffff; + } + + #content { + padding: 1em; + background-color: #ffffff; + } + + #navigation { + display: none; + } + pre.example { + font-family: "Andale Mono", monospace; + font-size: 10pt; + page-break-inside: avoid; + } +} + +table.module_list { + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.module_list td { + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.module_list td.name { background-color: #f0f0f0; min-width: 200px; } +table.module_list td.summary { width: 100%; } + + +table.function_list { + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.function_list td { + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.function_list td.name { background-color: #f0f0f0; min-width: 200px; } +table.function_list td.summary { width: 100%; } + +ul.nowrap { + overflow:auto; + white-space:nowrap; +} + +dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;} +dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;} +dl.table h3, dl.function h3 {font-size: .95em;} + +/* stop sublists from having initial vertical space */ +ul ul { margin-top: 0px; } +ol ul { margin-top: 0px; } +ol ol { margin-top: 0px; } +ul ol { margin-top: 0px; } + +/* make the target distinct; helps when we're navigating to a function */ +a:target + * { + background-color: #FF9; +} + + +/* styles for prettification of source */ +pre .comment { color: #558817; } +pre .constant { color: #a8660d; } +pre .escape { color: #844631; } +pre .keyword { color: #aa5050; font-weight: bold; } +pre .library { color: #0e7c6b; } +pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; } +pre .string { color: #8080ff; } +pre .number { color: #f8660d; } +pre .operator { color: #2239a8; font-weight: bold; } +pre .preprocessor, pre .prepro { color: #a33243; } +pre .global { color: #800080; } +pre .user-keyword { color: #800080; } +pre .prompt { color: #558817; } +pre .url { color: #272fc2; text-decoration: underline; } + diff --git a/doc/modules/Event.html b/doc/modules/Event.html new file mode 100644 index 00000000..85168be6 --- /dev/null +++ b/doc/modules/Event.html @@ -0,0 +1,210 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Event

+

Makes working with events in factorio a lot more simple.

+

+

Factorio can only have one handler registered per event. This module + allows you to easily register multiple handlers for each event. + Using this module is as simple as replacing script.on_event(...) with Event.register(...)

+

Usage:

+
    +
    require('stdlib/event/event')
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + +
register (event, handler)Registers a function for a given event.
dispatch (event)Calls the registerd handlers + Will stop dispatching remaning handlers if any handler passes invalid event userdata.
remove (event, handler)Removes the handler from the event.
+ +
+
+ + +

Functions

+ +
+
+ + register (event, handler) +
+
+ Registers a function for a given event. If a nil handler is passed remove all events and stop listening for that event. + Events are dispatched in the order they are registered. + + +

Parameters:

+
    +
  • event + defines.events or {defines.events,...} + events to register +
  • +
  • handler + function + Function to call when event is triggered +
  • +
+ +

Returns:

+
    + + Event + +
+ + + +

Usage:

+
    +
    Event.register(defines.events.on_tick, function(event) print event.tick end)
    + -- creates an event that prints the current tick every tick.
    +
+ +
+
+ + dispatch (event) +
+
+ Calls the registerd handlers + Will stop dispatching remaning handlers if any handler passes invalid event userdata. + Handlers are dispatched in the order they were created + + +

Parameters:

+
    +
  • event + table + LuaEvent as created by script.raise_event +
  • +
+ + + +

See also:

+
    +
+ + +
+
+ + remove (event, handler) +
+
+ Removes the handler from the event. If it removes the last handler for an event stop listening for that event. + + +

Parameters:

+
    +
  • event + defines.events or {defines.events,...} + events to remove the handler for +
  • +
  • handler + function + to remove +
  • +
+ +

Returns:

+
    + + Event +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:06:55 +
+
+ + diff --git a/doc/modules/FSM.html b/doc/modules/FSM.html new file mode 100644 index 00000000..1c9fd6bf --- /dev/null +++ b/doc/modules/FSM.html @@ -0,0 +1,337 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module FSM

+

Factorio Softmod Manager

+

+

Usage:

+
    +
    Manager = require("FactorioSoftmodManager")
    + Used to load all other modules that are indexed in index.lua
    +
    +
+

Info:

+
    +
  • Author: Cooldude2606
  • +
+ + +

Functions

+ + + + + + + + + +
_verbose (rtn)Default output for the verbose
verbose (rtn, action)Used to call the output of the verbose when the current state allows it
+

Fields

+ + + + + + + + + + + + + + + + + + + + + +
setVerboseMain logic for allowing verbose at different stages though out the script
sandboxCreates a sand box envorment and runs a callback in that sand box; provents global pollution
loadModulesLoads the modules that are present in the index list
errorA more detailed replacement for the lua error function to allow for handlers to be added; repleaces default error so error can be used instead of Manager.error
namesSub set to Manger.event and acts as a coverter between event_name and event_id
+ +
+
+ + +

Functions

+ +
+
+ + _verbose (rtn) +
+
+ Default output for the verbose + + +

Parameters:

+
    +
  • rtn + string + the value that will be returned though verbose output +
  • +
+ + + + +

Usage:

+
    +
    Manager.verbose('Hello, World!')
    +
+ +
+
+ + verbose (rtn, action) +
+
+ Used to call the output of the verbose when the current state allows it + + +

Parameters:

+
    +
  • rtn + string + the value that will be returned though verbose output +
  • +
  • action + string + is used to decide which verbose this is error || event etc +
  • +
+ + + + +

Usage:

+
    +
    Manager.verbose('Hello, World!')
    +
+ +
+
+

Fields

+ +
+
+ + setVerbose +
+
+ Main logic for allowing verbose at different stages though out the script + + +
    +
  • table + newTbl + the table that will be searched for settings to be updated +
  • +
+ + + + +

Usage:

+
    +
  • Manager.setVerbose{output=log}
  • +
  • Manager.setVerbose[setting] -- returns the value of that setting
  • +
  • tostring(Manager.setVerbose) -- returns a formated list of the current settings
  • +
+ +
+
+ + sandbox +
+
+ Creates a sand box envorment and runs a callback in that sand box; provents global pollution + + +
    +
  • function + callback + the function that will be ran in the sandbox +
  • +
  • any + other params that the function will use + (optional) +
  • +
+ + + + +

Usage:

+
    +
  • Manager.sandbox(callback) -- return sandbox, success, other returns from callback
  • +
  • Manager.sandbox() -- returns and empty sandbox
  • +
  • Manager.sandbox[key] -- returns the sand box value in that key
  • +
+ +
+
+ + loadModules +
+
+ Loads the modules that are present in the index list + + + + + + +

Usage:

+
    +
  • Manager.loadModules() -- loads all moddules in the index list
  • +
  • #Manager.loadModules -- returns the number of modules loaded
  • +
  • tostring(Manager.loadModules) -- returns a formatted list of all modules loaded
  • +
  • pairs(Manager.loadModules) -- loops over the loaded modules moduleName, module
  • +
+ +
+
+ + error +
+
+ A more detailed replacement for the lua error function to allow for handlers to be added; repleaces default error so error can be used instead of Manager.error + + +
    +
  • string + name + || fucntion the name that is given to the callback || the callback that will be used +
  • +
  • string + name + || fucntion the name that is given to the callback || the callback that will be used +
  • +
  • function + callback + if name is given as a string this will be the callback used +
  • +
+ + + + +

Usage:

+
    +
  • Manager.error(err) -- calls all error handlers that are set or if none then prints to game and if that fails crashs game
  • +
  • Manager.error() -- returns an error constant that can be used to crash game
  • +
  • Manager.error(Manager.error()) -- crashs the game
  • +
  • Manager.error.addHandler(name,callback) -- adds a new handler if handler returns Manager.error() then game will crash
  • +
  • Manager.error[name] -- returns the handler of that name if present
  • +
  • #Manager.error -- returns the number of error handlers that are present
  • +
  • pairs(Manager.error) -- loops over only the error handlers handler_name,hander
  • +
+ +
+
+ + names +
+
+ Sub set to Manger.event and acts as a coverter between event_name and event_id + + +
    +
  • names + +
  • +
+ + + +

See also:

+
    +
+ +

Usage:

+
    +
    Manager.event[event_name] -- see above, can not be accessed via Manager.event.names
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/Game.html b/doc/modules/Game.html new file mode 100644 index 00000000..27aa7ddb --- /dev/null +++ b/doc/modules/Game.html @@ -0,0 +1,231 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Game

+

The game module.

+

+

Usage:

+
    +
    local Game = require('stdlib/game')
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + + + + + +
fail_if_missing (var[, msg="missing value"])Print msg if specified var evaluates to false.
get_player (mixed)Return a valid player object from event, index, string, or userdata
get_force (mixed)Return a valid force object from event, string, or userdata
print_all (msg[, condition])Messages all players currently connected to the game.
+ +
+
+ + +

Functions

+ +
+
+ + fail_if_missing (var[, msg="missing value"]) +
+
+ Print msg if specified var evaluates to false. + + +

Parameters:

+
    +
  • var + Mixed + variable to evaluate +
  • +
  • msg + string + message + (default "missing value") +
  • +
+ + + + + +
+
+ + get_player (mixed) +
+
+ Return a valid player object from event, index, string, or userdata + + +

Parameters:

+
    +
  • mixed + string, number, LuaPlayer or event + +
  • +
+ +

Returns:

+
    + + LuaPlayer + a valid player or nil +
+ + + + +
+
+ + get_force (mixed) +
+
+ Return a valid force object from event, string, or userdata + + +

Parameters:

+
    +
  • mixed + string, LuaForce or event + +
  • +
+ +

Returns:

+
    + + LuaForce + a valid force or nil +
+ + + + +
+
+ + print_all (msg[, condition]) +
+
+ Messages all players currently connected to the game. +> Offline players are not counted as having received the message. + If no players exist msg is stored in the `global._print_queue` table. + + +

Parameters:

+
    +
  • msg + string + the message to send to players +
  • +
  • condition + nil or boolean + the condition to be true for a player to be messaged + (optional) +
  • +
+ +

Returns:

+
    + + uint + the number of players who received the message. +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/defines.color.html b/doc/modules/defines.color.html new file mode 100644 index 00000000..38dc3a04 --- /dev/null +++ b/doc/modules/defines.color.html @@ -0,0 +1,519 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module defines.color

+

A defines module for retrieving colors by name.

+

+ Extends the Factorio defines table.

+

Usage:

+
    +
    require('stdlib/defines/color')
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + + + + + +
Color.set ([color=white[, alpha=1]])Set a value for the alpha channel in the given color table.
Color.to_table (c_arr)Converts a color in the array format to a color in the table format.
Color.from_rgb ([r=0[, g=0[, b=0[, a=255]]]])Converts a color in the rgb format to a color table
Color.from_hex (hex[, alpha=1])Get a color table with a hexadecimal string.
+

Tables

+ + + + + + + + + + + + + +
defines.colorA table of colors allowing retrieval by color name.
defines.anticolorReturns white for dark colors or black for lighter colors.
defines.lightcolorReturns a lighter color of a named color.
+ +
+
+ + +

Functions

+ +
+
+ + Color.set ([color=white[, alpha=1]]) +
+
+ Set a value for the alpha channel in the given color table. + `color.a` represents the alpha channel in the given color table. +
    +
  • If ***alpha*** is given, set `color.a` to it. +
  • If ***alpha*** is not given, and if the given color table does not have a value for `color.a`, set `color.a` to 1. +
  • If ***alpha*** is not given, and if the given color table already has a value for `color.a`, then leave `color.a` alone. +
+ + +

Parameters:

+
    +
  • color + defines.color or Concepts.Color + the color to configure + (default white) +
  • +
  • alpha + float + the alpha value (*[0 - 1]*) to set for the given color + (default 1) +
  • +
+ +

Returns:

+
    + + Concepts.Color + a color table that has the specified value for the alpha channel +
+ + + + +
+
+ + Color.to_table (c_arr) +
+
+ Converts a color in the array format to a color in the table format. + + +

Parameters:

+
    +
  • c_arr + table + the color to convert +
  • +
+ +

Returns:

+
    + + Concepts.Color + a converted color — { r = c\_arr[1], g = c\_arr[2], b = c\_arr[3], a = c\_arr[4] } +
+ + + + +
+
+ + Color.from_rgb ([r=0[, g=0[, b=0[, a=255]]]]) +
+
+ Converts a color in the rgb format to a color table + + +

Parameters:

+
    +
  • r + int + 0-255 red + (default 0) +
  • +
  • g + int + 0-255 green + (default 0) +
  • +
  • b + int + 0-255 blue + (default 0) +
  • +
  • a + int + 0-255 alpha + (default 255) +
  • +
+ +

Returns:

+
    + + Concepts.Color + +
+ + + + +
+
+ + Color.from_hex (hex[, alpha=1]) +
+
+ Get a color table with a hexadecimal string. + Optionally provide the value for the alpha channel. + + +

Parameters:

+
    +
  • hex + string + hexadecimal color string (#ffffff, not #fff) +
  • +
  • alpha + float + the alpha value to set; such that ***[ 0 ⋜ value ⋜ 1 ]*** + (default 1) +
  • +
+ +

Returns:

+
    + + Concepts.Color + a color table with RGB converted from Hex and with alpha +
+ + + + +
+
+

Tables

+ +
+
+ + defines.color +
+
+ A table of colors allowing retrieval by color name. + + +

Fields:

+
    +
  • white + Concepts.Color + +
  • +
  • black + Concepts.Color + +
  • +
  • darkgrey + Concepts.Color + +
  • +
  • grey + Concepts.Color + +
  • +
  • lightgrey + Concepts.Color + +
  • +
  • red + Concepts.Color + +
  • +
  • darkred + Concepts.Color + +
  • +
  • lightred + Concepts.Color + +
  • +
  • green + Concepts.Color + +
  • +
  • darkgreen + Concepts.Color + +
  • +
  • lightgreen + Concepts.Color + +
  • +
  • blue + Concepts.Color + +
  • +
  • darkblue + Concepts.Color + +
  • +
  • lightblue + Concepts.Color + +
  • +
  • orange + Concepts.Color + +
  • +
  • yellow + Concepts.Color + +
  • +
  • pink + Concepts.Color + +
  • +
  • purple + Concepts.Color + +
  • +
  • brown + Concepts.Color + +
  • +
+ + + + +

Usage:

+
    +
    color = defines.color.red
    +
+ +
+
+ + defines.anticolor +
+
+ Returns white for dark colors or black for lighter colors. + + +

Fields:

+
    +
  • green + Concepts.Color + defines.color.black +
  • +
  • grey + Concepts.Color + defines.color.black +
  • +
  • lightblue + Concepts.Color + defines.color.black +
  • +
  • lightgreen + Concepts.Color + defines.color.black +
  • +
  • lightgrey + Concepts.Color + defines.color.black +
  • +
  • lightred + Concepts.Color + defines.color.black +
  • +
  • orange + Concepts.Color + defines.color.black +
  • +
  • white + Concepts.Color + defines.color.black +
  • +
  • yellow + Concepts.Color + defines.color.black +
  • +
  • black + Concepts.Color + defines.color.white +
  • +
  • blue + Concepts.Color + defines.color.white +
  • +
  • brown + Concepts.Color + defines.color.white +
  • +
  • darkblue + Concepts.Color + defines.color.white +
  • +
  • darkgreen + Concepts.Color + defines.color.white +
  • +
  • darkgrey + Concepts.Color + defines.color.white +
  • +
  • darkred + Concepts.Color + defines.color.white +
  • +
  • pink + Concepts.Color + defines.color.white +
  • +
  • purple + Concepts.Color + defines.color.white +
  • +
  • red + Concepts.Color + defines.color.white +
  • +
+ + + + + +
+
+ + defines.lightcolor +
+
+ Returns a lighter color of a named color. + + +

Fields:

+
    +
  • white + Concepts.Color + defines.color.lightgrey +
  • +
  • grey + Concepts.Color + defines.color.darkgrey +
  • +
  • lightgrey + Concepts.Color + defines.color.grey +
  • +
  • red + Concepts.Color + defines.color.lightred +
  • +
  • green + Concepts.Color + defines.color.lightgreen +
  • +
  • blue + Concepts.Color + defines.color.lightblue +
  • +
  • yellow + Concepts.Color + defines.color.orange +
  • +
  • pink + Concepts.Color + defines.color.purple +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/defines.time.html b/doc/modules/defines.time.html new file mode 100644 index 00000000..fd176df3 --- /dev/null +++ b/doc/modules/defines.time.html @@ -0,0 +1,148 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module defines.time

+

A defines module for retrieving the number of ticks in 1 unit of time.

+

+ Extends the Factorio defines table.

+

Usage:

+
    +
    require('stdlib/defines/time')
    +
    +
+ + +

Tables

+ + + + + +
defines.timeReturns the number of ticks in a second, minute, hour, day, week, month, or year.
+ +
+
+ + +

Tables

+ +
+
+ + defines.time +
+
+ Returns the number of ticks in a second, minute, hour, day, week, month, or year. + + +

Fields:

+
    +
  • second + the number of Factorio ticks in a second +
  • +
  • minute + the number of Factorio ticks in a second +
  • +
  • hour + the number of Factorio ticks in an hour +
  • +
  • day + the number of Factorio ticks in an day +
  • +
  • week + the number of Factorio ticks in a week +
  • +
  • month + the number of Factorio ticks in a month (30 days) +
  • +
  • year + the number of Factorio ticks in a year (365 days) +
  • +
+ + + + +

Usage:

+
    +
    local ten_seconds = defines.time.second * 10
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/expcore.commands.html b/doc/modules/expcore.commands.html new file mode 100644 index 00000000..a553e593 --- /dev/null +++ b/doc/modules/expcore.commands.html @@ -0,0 +1,136 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module expcore.commands

+

Uses a commands data to return the inputs as a string

+

+

Usage:

+
    +
    command = command_data[command_name]
    + command_inputs(command) -- returns "<input1> <input2> "
    +
    +
+ + +

Functions

+ + + + + +
get_commands (player)Used to return all the commands a player can use
+ +
+
+ + +

Functions

+ +
+
+ + get_commands (player) +
+
+ Used to return all the commands a player can use + + +

Parameters:

+
    +
  • player + the player refreced by string|number|LuaPlayer|event +
  • +
+ +

Returns:

+
    + + table + a table containg all the commands the player can use +
+ + + +

Usage:

+
    +
    get_commands(1) -- return {{command data},{command data}}
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/expcore.gui.html b/doc/modules/expcore.gui.html new file mode 100644 index 00000000..a6368064 --- /dev/null +++ b/doc/modules/expcore.gui.html @@ -0,0 +1,172 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module expcore.gui

+

Add a white bar to any gui frame

+

+

Usage:

+
    +
    Gui.bar(frame,100)
    +
    +
+ + +

Functions

+ + + + + + + + + +
Gui.set_dropdown_index (dropdown, _item)Used to set the index of a drop down to a certian item
Gui.cam_link (data)Adds a camera that updates every tick (or less depeading on how many are opening) it will move to follow an entity
+ +
+
+ + +

Functions

+ +
+
+ + Gui.set_dropdown_index (dropdown, _item) +
+
+ Used to set the index of a drop down to a certian item + + +

Parameters:

+
    +
  • dropdown + the dropdown that is to be effected +
  • +
  • _item + this is the item to look for +
  • +
+ +

Returns:

+
    + + returns the dropdown if it was successful +
+ + + +

Usage:

+
    +
    Gui.set_dropdown_index(dropdown,player.name)
    +
+ +
+
+ + Gui.cam_link (data) +
+
+ Adds a camera that updates every tick (or less depeading on how many are opening) it will move to follow an entity + + +

Parameters:

+
    +
  • data + table + contains all other params given below +
  • +
+ +

Returns:

+
    + + the camera that the function used be it made or given as a param +
+ + + +

Usage:

+
    +
  • Gui.cam_link{entity=game.player.character,frame=frame,width=50,hight=50,zoom=1}
  • +
  • Gui.cam_link{entity=game.player.character,cam=frame.camera,surface=game.surfaces['testing']}
  • +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/expcore.guiparts.center.html b/doc/modules/expcore.guiparts.center.html new file mode 100644 index 00000000..ed110104 --- /dev/null +++ b/doc/modules/expcore.guiparts.center.html @@ -0,0 +1,290 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module expcore.guiparts.center

+

Adds a new obj to the center gui

+

+

Usage:

+
    +
    Gui.center.add{name='foo',caption='Foo',tooltip='Testing',draw=function}
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + +
get_flow (player)Used to get the center frame of the player, used mainly in script
open (player, center)Used to open a center frame for a player
open_tab (player, center, tab)Used to open a center frame for a player
clear (player)Used to clear the center frame of the player, used mainly in script
center._center:add_tab (name, caption[, tooltip], callback)If deafult draw is used then you can add tabs to the gui with this function
+ +
+
+ + +

Functions

+ +
+
+ + get_flow (player) +
+
+ Used to get the center frame of the player, used mainly in script + + +

Parameters:

+
    +
  • player + a player indifier to get the flow for +
  • +
+ +

Returns:

+
    + + table + the gui element flow +
+ + + +

Usage:

+
    +
    Gui.center.get_flow(player) -- returns gui emelemt
    +
+ +
+
+ + open (player, center) +
+
+ Used to open a center frame for a player + + +

Parameters:

+
    +
  • player + a player indifier to get the flow for +
  • +
  • center + string + the name of the center frame to open +
  • +
+ +

Returns:

+
    + + boelon + based on if it successed or not +
+ + + +

Usage:

+
    +
    Gui.center.open(player,'server-info') -- return true
    +
+ +
+
+ + open_tab (player, center, tab) +
+
+ Used to open a center frame for a player + + +

Parameters:

+
    +
  • player + a player indifier to get the flow for +
  • +
  • center + string + the name of the center frame to open +
  • +
  • tab + string + the name of the tab to open +
  • +
+ +

Returns:

+
    + + boelon + based on if it successed or not +
+ + + +

Usage:

+
    +
    Gui.center.open_tab(player,'readme','rules') -- return true
    +
+ +
+
+ + clear (player) +
+
+ Used to clear the center frame of the player, used mainly in script + + +

Parameters:

+
    +
  • player + a player indifier to get the flow for +
  • +
+ + + + +

Usage:

+
    +
    Gui.center.clear(player)
    +
+ +
+
+ + center._center:add_tab (name, caption[, tooltip], callback) +
+
+ If deafult draw is used then you can add tabs to the gui with this function + + +

Parameters:

+
    +
  • name + string + this is the name of the tab +
  • +
  • caption + string + this is the words that appear on the tab button +
  • +
  • tooltip + string + the tooltip that is on the button + (optional) +
  • +
  • callback + function + this is called when button is pressed with function(root_frame) +
  • +
+ +

Returns:

+
    + + self to allow chaining of _center:add_tab +
+ + + +

Usage:

+
    +
    _center:add_tab('foo','Foo','Just a tab',function)
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/expcore.guiparts.inputs.html b/doc/modules/expcore.guiparts.inputs.html new file mode 100644 index 00000000..f8de31de --- /dev/null +++ b/doc/modules/expcore.guiparts.inputs.html @@ -0,0 +1,446 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module expcore.guiparts.inputs

+

Sets the input to trigger on an certain event

+

+

Usage:

+
    +
    button:on_event(defines.events.on_gui_click,player_return)
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
inputs._input:draw (root)Draw the input into the root element
add (obj)Add a new input, this is the same as doing frame.add{} but returns a diffrent object
add_elem_button (name, elem_type, tooltip, callback)Used to define a choose-elem-button callback only on elem_changed
add_checkbox (name, radio, display, default, callback_true, callback_false)Used to define a checkbox callback only on state_changed
reset_radio (elements)Used to reset the state of radio buttons, recomened to be called on_state_change to reset any radio buttons it is ment to work with.
add_text (name, box, text, callback)Used to define a text callback only on text_changed
add_slider (name, orientation, min, max, start_callback, callback)Used to define a slider callback only on value_changed
add_drop_down (name, items, index, callback)Used to define a drop down callback only on value_changed
+ +
+
+ + +

Functions

+ +
+
+ + inputs._input:draw (root) +
+
+ Draw the input into the root element + + +

Parameters:

+
    +
  • root + the element you want to add the input to +
  • +
+ +

Returns:

+
    + + returns the element that was added +
+ + + +

Usage:

+
    +
    button:draw(frame)
    +
+ +
+
+ + add (obj) +
+
+ Add a new input, this is the same as doing frame.add{} but returns a diffrent object + + +

Parameters:

+
    +
  • obj + table + the new element to add if caption is a sprite path then sprite is used +
  • +
+ +

Returns:

+
    + + table + the custom input object +
+ + + +

Usage:

+
    +
    Gui.inputs.add{type='button',name='test',caption='Test'}
    +
+ +
+
+ + add_elem_button (name, elem_type, tooltip, callback) +
+
+ Used to define a choose-elem-button callback only on elem_changed + + +

Parameters:

+
    +
  • name + string + the name of this button +
  • +
  • elem_type + string + the display for this button, either text or sprite path +
  • +
  • tooltip + string + the tooltip to show on the button +
  • +
  • callback + function + the callback to call on change function(player,element,elem) +
  • +
+ +

Returns:

+
    + + table + the button object that was made, to allow a custom error event if wanted +
+ + + +

Usage:

+
    +
    Gui.inputs.add_elem_button('test','Test','Just for testing',function)
    +
+ +
+
+ + add_checkbox (name, radio, display, default, callback_true, callback_false) +
+
+ Used to define a checkbox callback only on state_changed + + +

Parameters:

+
    +
  • name + string + the name of this button +
  • +
  • radio + boolean + if this is a radio button +
  • +
  • display + string + the display for this button, either text or sprite path +
  • +
  • default + function + the callback which choses the default check state +
  • +
  • callback_true + function + the callback to call when changed to true +
  • +
  • callback_false + function + the callback to call when changed to false +
  • +
+ +

Returns:

+
    + + table + the button object that was made, to allow a custom error event if wanted +
+ + + +

Usage:

+
    +
    Gui.inputs.add_checkbox('test',false,'Just for testing',function,function,funvtion)
    +
+ +
+
+ + reset_radio (elements) +
+
+ Used to reset the state of radio buttons, recomened to be called on_state_change to reset any radio buttons it is ment to work with. + + +

Parameters:

+
    +
  • elements + can be a list of elements or a single element +
  • +
+ + + + +

Usage:

+
    +
    Gui.inputs.reset_radio{radio1,radio2,...}
    +
+ +
+
+ + add_text (name, box, text, callback) +
+
+ Used to define a text callback only on text_changed + + +

Parameters:

+
    +
  • name + string + the name of this button +
  • +
  • box + boolean + is it a text box rather than a text field +
  • +
  • text + string + the starting text +
  • +
  • callback + function + the callback to call on change function(player,text,element) +
  • +
+ +

Returns:

+
    + + table + the text object that was made, to allow a custom error event if wanted +
+ + + +

Usage:

+
    +
    Gui.inputs.add_text('test',false,'Just for testing',function)
    +
+ +
+
+ + add_slider (name, orientation, min, max, start_callback, callback) +
+
+ Used to define a slider callback only on value_changed + + +

Parameters:

+
    +
  • name + string + the name of this button +
  • +
  • orientation + string + direction of the slider +
  • +
  • min + number + the lowest number +
  • +
  • max + number + the highest number +
  • +
  • start_callback + function + either a number or a function to return a number +
  • +
  • callback + function + the function to be called on value_changed function(player,value,percent,element) +
  • +
+ +

Returns:

+
    + + table + the slider object that was made, to allow a custom error event if wanted +
+ + + +

Usage:

+
    +
    Gui.inputs.add_slider('test','horizontal',1,10,5,function)
    +
+ +
+
+ + add_drop_down (name, items, index, callback) +
+
+ Used to define a drop down callback only on value_changed + + +

Parameters:

+
    +
  • name + string + name of the drop down +
  • +
  • items + either a list or a function which returns a list +
  • +
  • index + either a number or a function which returns a number +
  • +
  • callback + function + the callback which is called when a new index is selected function(player,selected,items,element) +
  • +
+ +

Returns:

+
    + + table + the drop-down object that was made, to allow a custom error event if wanted +
+ + + +

Usage:

+
    +
    Gui.inputs.add_drop_down('test',{1,2,3},1,function)
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/expcore.guiparts.left.html b/doc/modules/expcore.guiparts.left.html new file mode 100644 index 00000000..ce4257f8 --- /dev/null +++ b/doc/modules/expcore.guiparts.left.html @@ -0,0 +1,193 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module expcore.guiparts.left

+

Used to add a left gui frame

+

+

Usage:

+
    +
    Gui.left.add{name='foo',caption='Foo',tooltip='just testing',open_on_join=true,can_open=function,draw=function}
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + +
update ([frame[, players]])This is used to update all the guis of conected players, good idea to use our thread system as it as nested for loops
open (left_name)Used to open the left gui of every player
close (left_name)Used to close the left gui of every player
+ +
+
+ + +

Functions

+ +
+
+ + update ([frame[, players]]) +
+
+ This is used to update all the guis of conected players, good idea to use our thread system as it as nested for loops + + +

Parameters:

+
    +
  • frame + string + this is the name of a frame if you only want to update one + (optional) +
  • +
  • players + the player to update for, if not given all players are updated, can be one player + (optional) +
  • +
+ + + + +

Usage:

+
    +
    Gui.left.update()
    +
+ +
+
+ + open (left_name) +
+
+ Used to open the left gui of every player + + +

Parameters:

+
    +
  • left_name + string + this is the gui that you want to open +
  • +
+ + + + +

Usage:

+
    +
    Gui.left.open('foo')
    +
+ +
+
+ + close (left_name) +
+
+ Used to close the left gui of every player + + +

Parameters:

+
    +
  • left_name + string + this is the gui that you want to close +
  • +
+ + + + +

Usage:

+
    +
    Gui.left.close('foo')
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/expcore.guiparts.popup.html b/doc/modules/expcore.guiparts.popup.html new file mode 100644 index 00000000..987917ff --- /dev/null +++ b/doc/modules/expcore.guiparts.popup.html @@ -0,0 +1,138 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module expcore.guiparts.popup

+

Used to add a popup gui style

+

+

Usage:

+
    +
    Gui.left.add{name='foo',caption='Foo',draw=function}
    +
    +
+ + +

Functions

+ + + + + +
open (style, data[, players=game.connected_players])Use to open a popup for these players
+ +
+
+ + +

Functions

+ +
+
+ + open (style, data[, players=game.connected_players]) +
+
+ Use to open a popup for these players + + +

Parameters:

+
    +
  • style + string + this is the name you gave to the popup when added +
  • +
  • data + this is the data that is sent to the draw function +
  • +
  • players + table + the players to open the popup for + (default game.connected_players) +
  • +
+ + + + +

Usage:

+
    +
    Gui.popup.open('ban',nil,{player=1,reason='foo'})
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/expcore.guiparts.toolbar.html b/doc/modules/expcore.guiparts.toolbar.html new file mode 100644 index 00000000..cdbf2952 --- /dev/null +++ b/doc/modules/expcore.guiparts.toolbar.html @@ -0,0 +1,129 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module expcore.guiparts.toolbar

+

Add a button to the toolbar, ranks need to be allowed to use these buttons if ranks is preset

+

+

Usage:

+
    +
    toolbar.add('foo','Foo','Test',function() game.print('test') end)
    +
    +
+ + +

Functions

+ + + + + +
draw (player)Draws the toolbar for a certain player
+ +
+
+ + +

Functions

+ +
+
+ + draw (player) +
+
+ Draws the toolbar for a certain player + + +

Parameters:

+
    +
  • player + the player to draw the tool bar of +
  • +
+ + + + +

Usage:

+
    +
    toolbar.draw(1)
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/expcore.ranking.html b/doc/modules/expcore.ranking.html new file mode 100644 index 00000000..d1d22f6e --- /dev/null +++ b/doc/modules/expcore.ranking.html @@ -0,0 +1,386 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module expcore.ranking

+

Returns a rank object given a player or rank name

+

+

Usage:

+
    +
    Ranking.get_rank(game.player)
    + Ranking.get_rank('admin')
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Ranking.get_group (mixed)Returns the group object used to sort ranks given group name or see Ranking.get_rank
Ranking.print (rank_base, rtn, colour, below)Prints to all rank of greater/lower power of the rank given
Ranking.give_rank (player, rank[, by_player='server'[, tick=game.tick]])Gives a user a rank
Ranking.revert (player[, by_player=nil])Revert the last change to a players rank
Ranking.find_preset (player[, tick=nil])Given the player has a rank in the preset table it is given
Ranking._rank:allowed (action)Is this rank allowed to open this gui or use this command etc.
Ranking._rank:get_players (online)Get all the players in this rank
Ranking._rank:print (rtn, colour, show_default)Print a message to all players of this rank
+ +
+
+ + +

Functions

+ +
+
+ + Ranking.get_group (mixed) +
+
+ Returns the group object used to sort ranks given group name or see Ranking.get_rank + + +

Parameters:

+
    +
  • mixed + player|player index|player name|rank name|rank|'server'|'root'|group name|group what group to get +
  • +
+ +

Returns:

+
    + + table + the group that is linked to mixed +
+ + + +

Usage:

+
    +
    Ranking.get_group(game.player)
    + Ranking.get_group('root')
    +
+ +
+
+ + Ranking.print (rank_base, rtn, colour, below) +
+
+ Prints to all rank of greater/lower power of the rank given + + +

Parameters:

+
    +
  • rank_base + the rank that acts as the cut off point (rank is always included) +
  • +
  • rtn + what do you want to return to the players +
  • +
  • colour + defines.color + the colour that will be used to print +
  • +
  • below + bolean + if true rank below base are printed to +
  • +
+ + + + +

Usage:

+
    +
    Ranking.print('admin','We got a grifer')
    +
+ +
+
+ + Ranking.give_rank (player, rank[, by_player='server'[, tick=game.tick]]) +
+
+ Gives a user a rank + + +

Parameters:

+
    +
  • player + the player to give the rank to +
  • +
  • rank + the rank to give to the player +
  • +
  • by_player + the player who is giving the rank + (default 'server') +
  • +
  • tick + the tick that the rank is being given on + (default game.tick) +
  • +
+ + + + +

Usage:

+
    +
    Ranking.give_rank(1,'admin')
    +
+ +
+
+ + Ranking.revert (player[, by_player=nil]) +
+
+ Revert the last change to a players rank + + +

Parameters:

+
    +
  • player + the player to revert the rank of +
  • +
  • by_player + the player who is doing the revert + (default nil) +
  • +
+ + + + +

Usage:

+
    +
    Ranking.revert(1)
    +
+ +
+
+ + Ranking.find_preset (player[, tick=nil]) +
+
+ Given the player has a rank in the preset table it is given + + +

Parameters:

+
    +
  • player + the player to test for an auto rank +
  • +
  • tick + number + the tick it happens on + (default nil) +
  • +
+ + + + +

Usage:

+
    +
    Ranking.find_preset(1)
    +
+ +
+
+ + Ranking._rank:allowed (action) +
+
+ Is this rank allowed to open this gui or use this command etc. + + +

Parameters:

+
    +
  • action + teh + to test for +
  • +
+ +

Returns:

+
    + + bolean + is it allowed +
+ + + +

Usage:

+
    +
    rank:allowed('server-interface')
    +
+ +
+
+ + Ranking._rank:get_players (online) +
+
+ Get all the players in this rank + + +

Parameters:

+
    +
  • online + bolean + get only online players +
  • +
+ +

Returns:

+
    + + table + a table of all players in this rank +
+ + + +

Usage:

+
    +
    rank:get_players()
    +
+ +
+
+ + Ranking._rank:print (rtn, colour, show_default) +
+
+ Print a message to all players of this rank + + +

Parameters:

+
    +
  • rtn + any value you want to return +
  • +
  • colour + define.color + the colour that will be used to print +
  • +
  • show_default + boolean + weather to use the default rank name for the print +
  • +
+ + + + +

Usage:

+
    +
    rank:print('foo')
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/expcore.server.html b/doc/modules/expcore.server.html new file mode 100644 index 00000000..4dec0cb5 --- /dev/null +++ b/doc/modules/expcore.server.html @@ -0,0 +1,571 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module expcore.server

+

Returns a un-used uuid (better system needed)

+

+

Usage:

+
    +
    obj.uuid = Server.new_uuid()
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Server.threads ([count=nil])Returns either the number of threads or a able of threads
Server.get_thread (mixed)Used to get a thread via it's uuid or by name if one is given
Server.queue_thread (thread_to_queue)Adds a thread into the resolve queue, can be used to lower lag
Server.close_all_threads (with_force)Closes all active threads, can use force if it causes errors
Server.run_tick_threads ()Runs all the theads which have opened with an on_tick event
Server.check_timeouts ()Checks the timeout on all active timeout threads
Server._thread_handler (event)Calles all threads on a certain game event (used with script.on_event)
Server.interface (callback[, use_thread[, ...]])Given a string or function it will run that function and return any values
Server._thread:valid (skip_location_check)Test if the thread has all requied parts
Server._thread:open ()Opens the thread by storing it in a place the server object can find it
Server._thread:close ()Inverse of thread:open() - it removes the thread and calles on_close
Server._thread:resolve ([...])Trigger the on_resolve function and closes the thread - error and success called based on result of pcall (useful for async)
Server._thread:check_timeout ()Checks the timeout on a thread - if timedout then it calles on_timeout and closes
Server._thread:error (err)Rasies an error on this thread
Server._thread:on_event (event, callback)Set function to run then an event is called on a thread, none of them are 'needed' but you are advised to have atleast one
+ +
+
+ + +

Functions

+ +
+
+ + Server.threads ([count=nil]) +
+
+ Returns either the number of threads or a able of threads + + +

Parameters:

+
    +
  • count + bolean + true to return the number of threads + (default nil) +
  • +
+ +

Returns:

+
    + + either a list of threads or a number +
+ + + +

Usage:

+
    +
    Server.threads() -- return {...}
    + Server.threads(true) -- return int
    +
+ +
+
+ + Server.get_thread (mixed) +
+
+ Used to get a thread via it's uuid or by name if one is given + + +

Parameters:

+
    +
  • mixed + either a uuid or the name given to a thread +
  • +
+ +

Returns:

+
    + + table + the thread by that name or uuid +
+ + + +

Usage:

+
    +
    Server.get_thread('decon') -- return thread
    +
+ +
+
+ + Server.queue_thread (thread_to_queue) +
+
+ Adds a thread into the resolve queue, can be used to lower lag + + +

Parameters:

+
    +
  • thread_to_queue + table + the thread to add to the queue must have a resolve function (must be open) +
  • +
+ +

Returns:

+
    + + boolean + was the thread added +
+ + + +

Usage:

+
    +
    Server.queue_thread(thread) -- return true/false
    +
+ +
+
+ + Server.close_all_threads (with_force) +
+
+ Closes all active threads, can use force if it causes errors + + +

Parameters:

+
    +
  • with_force + bolean + use force when closing +
  • +
+ + + + +

Usage:

+
    +
    Server.close_all_threads()
    + Server.close_all_threads(true) -- use if no force makes errors
    +
+ +
+
+ + Server.run_tick_threads () +
+
+ Runs all the theads which have opened with an on_tick event + + + + + + +

Usage:

+
    +
    Server.run_tick_threads()
    +
+ +
+
+ + Server.check_timeouts () +
+
+ Checks the timeout on all active timeout threads + + + + + + +

Usage:

+
    +
    Server.check_timeouts()
    +
+ +
+
+ + Server._thread_handler (event) +
+
+ Calles all threads on a certain game event (used with script.on_event) + + +

Parameters:

+
    +
  • event + table + the event that is called +
  • +
+ + + + + +
+
+ + Server.interface (callback[, use_thread[, ...]]) +
+
+ Given a string or function it will run that function and return any values + + +

Parameters:

+
    +
  • callback + either a function or string which will be ran via pcall +
  • +
  • use_thread + give a thread for the interface to run on (does not need to be open, but cant use on_resolve) + (optional) +
  • +
  • ... + any args you want to pass to the function + (optional) +
  • +
+ + + + +

Usage:

+
    +
    Server.interface('local x = 1+1 print(x) return x') -- return 2
    + Server.interface('local x = 1+1 print(x)',thread) -- no return
    +
+ +
+
+ + Server._thread:valid (skip_location_check) +
+
+ Test if the thread has all requied parts + + +

Parameters:

+
    +
  • skip_location_check + bolean + true to skip the location check +
  • +
+ +

Returns:

+
    + + bolean + is the thread valid +
+ + + +

Usage:

+
    +
    if thread:valid() then end
    +
+ +
+
+ + Server._thread:open () +
+
+ Opens the thread by storing it in a place the server object can find it + + + +

Returns:

+
    + + bolean + if the thread was opened +
+ + + +

Usage:

+
    +
    thread:open() -- return true
    +
+ +
+
+ + Server._thread:close () +
+
+ Inverse of thread:open() - it removes the thread and calles on_close + + + +

Returns:

+
    + + bolean + if the thread had a on_close function +
+ + + +

Usage:

+
    +
    thread:close() -- return true
    +
+ +
+
+ + Server._thread:resolve ([...]) +
+
+ Trigger the on_resolve function and closes the thread - error and success called based on result of pcall (useful for async) + + +

Parameters:

+
    +
  • ... + any arguments you want to pass to the resolve function + (optional) +
  • +
+ +

Returns:

+
    + + bolean + true if the thread called on_success or on_error +
+ + + +

Usage:

+
    +
    thread:resolve(x,y,z) -- return true
    +
+ +
+
+ + Server._thread:check_timeout () +
+
+ Checks the timeout on a thread - if timedout then it calles on_timeout and closes + + + +

Returns:

+
    + + bolean + if the thread timedout +
+ + + +

Usage:

+
    +
    thread:check_timeout() -- return true
    +
+ +
+
+ + Server._thread:error (err) +
+
+ Rasies an error on this thread + + +

Parameters:

+
    +
  • err + the err to be rasied +
  • +
+ +

Returns:

+
    + + bolean + did the thread handdle the error +
+ + + +

Usage:

+
    +
    thread:error(err) -- return true
    +
+ +
+
+ + Server._thread:on_event (event, callback) +
+
+ Set function to run then an event is called on a thread, none of them are 'needed' but you are advised to have atleast one + + +

Parameters:

+
    +
  • event + string + the name of the event that it is called on +
  • +
  • callback + function + the function which is called on the event +
  • +
+ +

Returns:

+
    + + table + returns self so that there can be chained +
+ + + +

Usage:

+
    +
    thread:on_event('close',function) -- return true
    +events = ['close','timeout','tick','resolve','success','error']
    +if event is a number then it is asumed to be a game event
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/expcore.sync.html b/doc/modules/expcore.sync.html new file mode 100644 index 00000000..74f4dd89 --- /dev/null +++ b/doc/modules/expcore.sync.html @@ -0,0 +1,542 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module expcore.sync

+

Used as a faster way to get to the ranking function, overrides previous

+

+

Usage:

+
    +
    Sync.set_ranks{name=rank_name}
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sync.tick_format (tick)Used to standidise the tick format for any sync info
Sync.print (player_message, player_name[, player_tag[, player_colour[, prefix]]])Prints to chat as if it were a player
Sync.emit_embeded (args)Logs an embed to the json.data we use a js script to add things we cant here
Sync.count_admins ()used to get the number of admins currently online
Sync.count_afk ([time=7200])used to get the number of afk players defined by 2 min by default
Sync.count_ranks ()used to get the number of players in each rank and currently online
Sync.count_players (online)used to get the number of players either online or all
Sync.count_player_times ()used to get the number of players resulting in there play times
Sync.info ([set=nil])used to return the global list and set values in it
Sync.time ([set=nil])used to return the global time and set its value
Sync.update ()called to update values inside of the info
Sync.add_update (key, callback)Adds a callback to be called when the info is updated
Sync.emit_data ()outputs the curent server info into a file
Sync.add_to_gui (element)Adds a emeltent to the sever info gui
+ +
+
+ + +

Functions

+ +
+
+ + Sync.tick_format (tick) +
+
+ Used to standidise the tick format for any sync info + + +

Parameters:

+
    +
  • tick + +
  • +
+ + + + +

Usage:

+
    +
    Sync.tick_format(60) -- return {60,'1.00M'}
    +
+ +
+
+ + Sync.print (player_message, player_name[, player_tag[, player_colour[, prefix]]]) +
+
+ Prints to chat as if it were a player + + +

Parameters:

+
    +
  • player_message + the message to be printed in chat +
  • +
  • player_name + the name of the player sending the message +
  • +
  • player_tag + the tag apllied to the player's name + (optional) +
  • +
  • player_colour + the colour of the message + (optional) +
  • +
  • prefix + add a prefix before the chat eg [IRC] + (optional) +
  • +
+ + + + +

Usage:

+
    +
    Sync.print('Test','Cooldude2606')
    +
+ +
+
+ + Sync.emit_embeded (args) +
+
+ Logs an embed to the json.data we use a js script to add things we cant here + + +

Parameters:

+
    +
  • args + table + a table which contains everything that the embeded will use +
  • +
+ + + + +

Usage:

+
    +
    Sync.emit_embeded{title='BAN',color='0x0',description='A player was banned' ... }
    +
+ +
+
+ + Sync.count_admins () +
+
+ used to get the number of admins currently online + + + +

Returns:

+
    + + int + the number of admins online +
+ + + +

Usage:

+
    +
    Sync.count_admins()
    +
+ +
+
+ + Sync.count_afk ([time=7200]) +
+
+ used to get the number of afk players defined by 2 min by default + + +

Parameters:

+
    +
  • time + int + in ticks that a player is called afk + (default 7200) +
  • +
+ +

Returns:

+
    + + int + the number of afk players +
+ + + +

Usage:

+
    +
    Sync.count_afk()
    +
+ +
+
+ + Sync.count_ranks () +
+
+ used to get the number of players in each rank and currently online + + + +

Returns:

+
    + + table + contains the ranks and the players in that rank +
+ + + +

Usage:

+
    +
    Sync.count_ranks()
    +
+ +
+
+ + Sync.count_players (online) +
+
+ used to get the number of players either online or all + + +

Parameters:

+
    +
  • online + bolean + if true only get online players +
  • +
+ +

Returns:

+
    + + table + contains player names +
+ + + +

Usage:

+
    +
    Sync.count_players()
    +
+ +
+
+ + Sync.count_player_times () +
+
+ used to get the number of players resulting in there play times + + + +

Returns:

+
    + + table + contains players and each player is given a tick amount and a formated string +
+ + + +

Usage:

+
    +
    Sync.count_player_times()
    +
+ +
+
+ + Sync.info ([set=nil]) +
+
+ used to return the global list and set values in it + + +

Parameters:

+
    +
  • set + table + keys to be replaced in the server info + (default nil) +
  • +
+ +

Returns:

+
    + + either returns success when setting or the info when not setting +
+ + + +

Usage:

+
    +
    Sync.info{server_name='Factorio Server 2'}
    +
+ +
+
+ + Sync.time ([set=nil]) +
+
+ used to return the global time and set its value + + +

Parameters:

+
    +
  • set + string + the date time to be set + (default nil) +
  • +
+ +

Returns:

+
    + + either true false if setting or the date time and tick off set +
+ + + +

Usage:

+
    +
    Sync.time('Sun Apr  1 18:44:30 UTC 2018')
    +
+ +
+
+ + Sync.update () +
+
+ called to update values inside of the info + + + +

Returns:

+
    + + all of the new info +
+ + + +

Usage:

+
    +
    Sync.update()
    +
+ +
+
+ + Sync.add_update (key, callback) +
+
+ Adds a callback to be called when the info is updated + + +

Parameters:

+
    +
  • key + string + the key that the value will be stored in +
  • +
  • callback + function + the function which will return this value +
  • +
+ + + + +

Usage:

+
    +
    Sync.add_update('players',function() return #game.players end)
    +
+ +
+
+ + Sync.emit_data () +
+
+ outputs the curent server info into a file + + + + + + +

Usage:

+
    +
    Sync.emit_data()
    +
+ +
+
+ + Sync.add_to_gui (element) +
+
+ Adds a emeltent to the sever info gui + + +

Parameters:

+
    +
  • element + see examples before for what can be used, it can also be a return from Gui.inputs.add +
  • +
+ +

Returns:

+
    + + bolean + based on weather it was successful or not +
+ + + +

Usage:

+
    +
    Sync.add_to_gui('string') -- return trues
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/modules.expgaminglib.control.html b/doc/modules/modules.expgaminglib.control.html new file mode 100644 index 00000000..63260c90 --- /dev/null +++ b/doc/modules/modules.expgaminglib.control.html @@ -0,0 +1,350 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module modules.expgaminglib.control

+

Loads a table into _G even when sandboxed; will not overwrite values or append to tables; will not work during runtime to avoid desyncs

+

+

Usage:

+
    +
    unpack_to_G{key1='foo',key2='bar'}
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpLib.get_env ()Used to get the current ENV with all _G keys removed; useful when saving function to global
ExpLib.is_type (v[, test_type=nil])Compear types faster for faster valadation of prams
ExpLib.player_return (rtn[, colour=defines.colour.white[, player=game.player]])Will return a value of any type to the player/server console, allows colour for in-game players
ExpLib.tick_to_hour (tick)Convert ticks to hours
ExpLib.tick_to_min (tick)Convert ticks to minutes
ExpLib.tick_to_display_format (tick)Converts a tick into a clean format for end user
ExpLib.gui_tree (root)Used as a way to view the structure of a gui, used for debuging
+ +
+
+ + +

Functions

+ +
+
+ + ExpLib.get_env () +
+
+ Used to get the current ENV with all _G keys removed; useful when saving function to global + + + +

Returns:

+
    + + table + the env table with _G keys removed +
+ + + +

Usage:

+
    +
    get_env() returns current ENV with _G keys removed
    +
+ +
+
+ + ExpLib.is_type (v[, test_type=nil]) +
+
+ Compear types faster for faster valadation of prams + + +

Parameters:

+
    +
  • v + the value to be tested +
  • +
  • test_type + string + the type to test for if not given then it tests for nil + (default nil) +
  • +
+ +

Returns:

+
    + + bolean + is v of type test_type +
+ + + +

Usage:

+
    +
  • is_type('foo','string') -- return true
  • +
  • is_type('foo') -- return false
  • +
+ +
+
+ + ExpLib.player_return (rtn[, colour=defines.colour.white[, player=game.player]]) +
+
+ Will return a value of any type to the player/server console, allows colour for in-game players + + +

Parameters:

+
    +
  • rtn + any value of any type that will be returned to the player or console +
  • +
  • colour + defines.color or string + the colour of the text for the player, ingroned when printing to console + (default defines.colour.white) +
  • +
  • player + LuaPlayer + the player that return will go to, if no game.player then returns to server + (default game.player) +
  • +
+ + + + +

Usage:

+
    +
  • player_return('Hello, World!') -- returns 'Hello, World!' to game.player or server console
  • +
  • player_return('Hello, World!','green') -- returns 'Hello, World!' to game.player with colour green or server console
  • +
  • player_return('Hello, World!',nil,player) -- returns 'Hello, World!' to the given player
  • +
+ +
+
+ + ExpLib.tick_to_hour (tick) +
+
+ Convert ticks to hours + + +

Parameters:

+
    +
  • tick + number + tick to convert to hours +
  • +
+ +

Returns:

+
    + + number + the number of whole hours from this tick +
+ + + +

Usage:

+
    +
    tick_to_hour(216001) -- return 1
    +
+ +
+
+ + ExpLib.tick_to_min (tick) +
+
+ Convert ticks to minutes + + +

Parameters:

+
    +
  • tick + number + tick to convert to minutes +
  • +
+ +

Returns:

+
    + + number + the number of whole minutes from this tick +
+ + + +

Usage:

+
    +
    tick_to_hour(3601) -- return 1
    +
+ +
+
+ + ExpLib.tick_to_display_format (tick) +
+
+ Converts a tick into a clean format for end user + + +

Parameters:

+
    +
  • tick + number + the tick to convert +
  • +
+ +

Returns:

+
    + + string + the formated string +
+ + + +

Usage:

+
    +
  • tick_to_display_format(3600) -- return '1.00 M'
  • +
  • tick_to_display_format(234000) -- return '1 H 5 M'
  • +
+ +
+
+ + ExpLib.gui_tree (root) +
+
+ Used as a way to view the structure of a gui, used for debuging + + +

Parameters:

+
    +
  • root + LuaGuiElement + the root to start the tree from +
  • +
+ +

Returns:

+
    + + table + the table that describes the gui +
+ + + +

Usage:

+
    +
    Gui_tree(root) returns all children of gui recusivly
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/string.html b/doc/modules/string.html new file mode 100644 index 00000000..2f757761 --- /dev/null +++ b/doc/modules/string.html @@ -0,0 +1,310 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module string

+

Extends Lua 5.2 string.

+

+

See also:

+ + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + +
trim (s)Returns a copy of the string with any leading or trailing whitespace from the string removed.
starts_with (s, start)Tests if a string starts with a given substring.
ends_with (s, ends)Tests if a string ends with a given substring.
contains (s, contains)Tests if a string contains a given substring.
is_empty (s)Tests whether a string is empty.
split (s[, sep="."[, pattern=false]])Splits a string into an array.
+ +
+
+ + +

Functions

+ +
+
+ + trim (s) +
+
+ Returns a copy of the string with any leading or trailing whitespace from the string removed. + + +

Parameters:

+
    +
  • s + string + the string to remove leading or trailing whitespace from +
  • +
+ +

Returns:

+
    + + string + a copy of the string without leading or trailing whitespace +
+ + + + +
+
+ + starts_with (s, start) +
+
+ Tests if a string starts with a given substring. + + +

Parameters:

+
    +
  • s + string + the string to check for the start substring +
  • +
  • start + string + the substring to test for +
  • +
+ +

Returns:

+
    + + boolean + true if the start substring was found in the string +
+ + + + +
+
+ + ends_with (s, ends) +
+
+ Tests if a string ends with a given substring. + + +

Parameters:

+
    +
  • s + string + the string to check for the end substring +
  • +
  • ends + string + the substring to test for +
  • +
+ +

Returns:

+
    + + boolean + true if the end substring was found in the string +
+ + + + +
+
+ + contains (s, contains) +
+
+ Tests if a string contains a given substring. + + +

Parameters:

+
    +
  • s + string + the string to check for the substring +
  • +
  • contains + string + the substring to test for +
  • +
+ +

Returns:

+
    + + boolean + true if the substring was found in the string +
+ + + + +
+
+ + is_empty (s) +
+
+ Tests whether a string is empty. + + +

Parameters:

+
    +
  • s + string + the string to test +
  • +
+ +

Returns:

+
    + + boolean + true if the string is empty +
+ + + + +
+
+ + split (s[, sep="."[, pattern=false]]) +
+
+ Splits a string into an array. + *Note:* Empty split substrings are not included in the resulting table. +

For example, `string.split("foo.bar...", ".", false)` results in the table `{"foo", "bar"}`. + + +

Parameters:

+
    +
  • s + string + the string to split +
  • +
  • sep + string + the separator to use. + (default ".") +
  • +
  • pattern + boolean + whether to interpret the separator as a lua pattern or plaintext for the string split + (default false) +
  • +
+ +

Returns:

+
    + + {string,...} + an array of strings +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/modules/table.html b/doc/modules/table.html new file mode 100644 index 00000000..ccf6d405 --- /dev/null +++ b/doc/modules/table.html @@ -0,0 +1,1145 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module table

+

Extends Lua 5.2 table.

+

+

See also:

+ + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
map (tbl, func[, ...])Given a mapping function, creates a transformed copy of the table + by calling the function for each element in the table, and using + the result as the new value for the key.
filter (tbl, func[, ...])Given a filter function, creates a filtered copy of the table + by calling the function for each element in the table, and + filtering out any key-value pairs for non-true results.
find (tbl, func[, ...])Given a candidate search function, iterates over the table, calling the function + for each element in the table, and returns the first element the search function returned true.
any (tbl, func[, ...])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.
each (tbl, func[, ...])Given a function, apply it to each element in the table.
flatten (tbl[, level])Returns a new array that is a one-dimensional recursive flattening of the given array.
first (tbl)Given an array, returns the first element or nil if no element exists.
last (tbl)Given an array, returns the last element or nil if no elements exist.
min (tbl)Given an array of only numeric values, returns the minimum or nil if no element exists.
max (tbl)Given an array of only numeric values, returns the maximum or nil if no element exists.
sum (tbl)Given an array of only numeric values, return the sum of all values, or 0 for empty arrays.
avg (tbl)Given an array of only numeric values, returns the average or nil if no element exists.
merge (tblA, tblB[, array_merge=false])Merges two tables — values from first get overwritten by the second.
deepcopy (object)Creates a deep copy of table without copying Factorio objects.
values (tbl[, sorted[, as_string]])Returns a copy of all of the values in the table.
keys (tbl[, sorted[, as_string]])Returns a copy of all of the keys in the table.
remove_keys (tbl, keys)Removes keys from a table by setting the values associated with the keys to nil.
count_keys (tbl[, func[, ...]])Returns the number of keys in a table, if func is passed only count keys when the function is true.
invert (tbl)Returns an inverted (***{[value] = key,...}***) copy of the given table.
size (table)Return the size of a table using built in table_size function
arr_to_bool (tbl)For all string or number values in an array map them to a key = true table
key_to_str (k)Returns a value in a form able to be read as a key
to_string (tbl)Returns a table in a form able to be read as a table
json (lua_table)Simmilar to table.to_string but converts a lua table to a json one
autokey (tbl, str)Returns the closest match to a key
alphanumsort (tbl)Returns the list is a sorted way that would be expected by people (this is by key)
keysort (tbl)Returns the list is a sorted way that would be expected by people (this is by key) (faster alterative than above)
+ +
+
+ + +

Functions

+ +
+
+ + map (tbl, func[, ...]) +
+
+ Given a mapping function, creates a transformed copy of the table + by calling the function for each element in the table, and using + the result as the new value for the key. Passes the index as second argument to the function. + + +

Parameters:

+
    +
  • tbl + table + the table to be mapped to the transform +
  • +
  • func + function + the function to transform values +
  • +
  • ... + additional arguments passed to the function + (optional) +
  • +
+ +

Returns:

+
    + + table + a new table containing the keys and mapped values +
+ + + +

Usage:

+
    +
  • a= { 1, 2, 3, 4, 5}
    +table.map(a, function(v) return v * 10 end) --produces: { 10, 20, 30, 40, 50 }
  • +
  • a = {1, 2, 3, 4, 5}
    +table.map(a, function(v, k, x) return v * k + x end, 100) --produces { 101, 104, 109, 116, 125}
  • +
+ +
+
+ + filter (tbl, func[, ...]) +
+
+ Given a filter function, creates a filtered copy of the table + by calling the function for each element in the table, and + filtering out any key-value pairs for non-true results. Passes the index as second argument to the function. + + +

Parameters:

+
    +
  • tbl + table + the table to be filtered +
  • +
  • func + function + the function to filter values +
  • +
  • ... + additional arguments passed to the function + (optional) +
  • +
+ +

Returns:

+
    + + table + a new table containing the filtered key-value pairs +
+ + + +

Usage:

+
    +
  • a= { 1, 2, 3, 4, 5}
    +table.filter(a, function(v) return v % 2 == 0 end) --produces: { 2, 4 }
  • +
  • a = {1, 2, 3, 4, 5}
    +table.filter(a, function(v, k, x) return k % 2 == 1 end) --produces: { 1, 3, 5 }
  • +
+ +
+
+ + find (tbl, func[, ...]) +
+
+ Given a candidate search function, iterates over the table, calling the function + for each element in the table, and returns the first element the search function returned true. + Passes the index as second argument to the function. + + +

Parameters:

+
    +
  • tbl + table + the table to be searched +
  • +
  • func + function + the function to use to search for any matching element +
  • +
  • ... + additional arguments passed to the function + (optional) +
  • +
+ +

Returns:

+
    + + nil or Mixed + the first found value, or nil if none was found +
+ + + +

Usage:

+
    +
  • a= { 1, 2, 3, 4, 5}
    +table.find(a, function(v) return v % 2 == 0 end) --produces: 2
  • +
  • a = {1, 2, 3, 4, 5}
    +table.find(a, function(v, k, x) return k % 2 == 1 end) --produces: 1
  • +
+ +
+
+ + any (tbl, func[, ...]) +
+
+ 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. + + +

Parameters:

+
    +
  • tbl + table + the table to be searched +
  • +
  • func + function + the function to use to search for any matching element +
  • +
  • ... + additional arguments passed to the function + (optional) +
  • +
+ +

Returns:

+
    + + boolean + true if an element was found, false if none was found +
+ + +

See also:

+ + +

Usage:

+
    +
  • a= { 1, 2, 3, 4, 5}
    +table.any(a, function(v) return v % 2 == 0 end) --produces: true
  • +
  • a = {1, 2, 3, 4, 5}
    +table.any(a, function(v, k, x) return k % 2 == 1 end) --produces: true
  • +
+ +
+
+ + each (tbl, func[, ...]) +
+
+ Given a function, apply it to each element in the table. + Passes the index as the second argument to the function. +

Iteration is aborted if the applied function returns true for any element during iteration. + + +

Parameters:

+
    +
  • tbl + table + the table to be iterated +
  • +
  • func + function + the function to apply to elements +
  • +
  • ... + additional arguments passed to the function + (optional) +
  • +
+ +

Returns:

+
    + + table + the table where the given function has been applied to its elements +
+ + + +

Usage:

+
    +
    a = {10, 20, 30, 40}
    +table.each(a, function(v) game.print(v) end) --prints 10, 20, 30, 40, 50
    +
+ +
+
+ + flatten (tbl[, level]) +
+
+ Returns a new array that is a one-dimensional recursive flattening of the given array. + For every element that is an array, extract its elements into the new array. +

The optional level argument determines the level of recursion to flatten. +> This function flattens an integer-indexed array, but not an associative array. + + +

Parameters:

+
    +
  • tbl + array + the array to be flattened +
  • +
  • level + uint + recursive levels, or no limit to recursion if not supplied + (optional) +
  • +
+ +

Returns:

+
    + + array + a new array that represents the flattened contents of the given array +
+ + + + +
+
+ + first (tbl) +
+
+ Given an array, returns the first element or nil if no element exists. + + +

Parameters:

+
    +
  • tbl + array + the array +
  • +
+ +

Returns:

+
    + + nil or Mixed + the first element +
+ + + + +
+
+ + last (tbl) +
+
+ Given an array, returns the last element or nil if no elements exist. + + +

Parameters:

+
    +
  • tbl + array + the array +
  • +
+ +

Returns:

+
    + + nil or Mixed + the last element or nil +
+ + + + +
+
+ + min (tbl) +
+
+ Given an array of only numeric values, returns the minimum or nil if no element exists. + + +

Parameters:

+
    +
  • tbl + {number,...} + the array with only numeric values +
  • +
+ +

Returns:

+
    + + nil or number + the minimum value +
+ + + + +
+
+ + max (tbl) +
+
+ Given an array of only numeric values, returns the maximum or nil if no element exists. + + +

Parameters:

+
    +
  • tbl + {number,...} + the array with only numeric values +
  • +
+ +

Returns:

+
    + + nil or number + the maximum value +
+ + + + +
+
+ + sum (tbl) +
+
+ Given an array of only numeric values, return the sum of all values, or 0 for empty arrays. + + +

Parameters:

+
    +
  • tbl + {number,...} + the array with only numeric values +
  • +
+ +

Returns:

+
    + + number + the sum of the numbers or zero if the given array was empty +
+ + + + +
+
+ + avg (tbl) +
+
+ Given an array of only numeric values, returns the average or nil if no element exists. + + +

Parameters:

+
    +
  • tbl + {number,...} + the array with only numeric values +
  • +
+ +

Returns:

+
    + + nil or number + the average value +
+ + + + +
+
+ + merge (tblA, tblB[, array_merge=false]) +
+
+ Merges two tables — values from first get overwritten by the second. + + +

Parameters:

+
    +
  • tblA + table + first table +
  • +
  • tblB + table + second table +
  • +
  • array_merge + boolean + set to true to merge the tables as an array or false for an associative array + (default false) +
  • +
+ +

Returns:

+
    + + array or table + an array or an associated array where tblA and tblB have been merged +
+ + + +

Usage:

+
    +
    function some_func(x, y, args)
    +    args = table.merge({option1=false}, args)
    +    if opts.option1 == true then return x else return y end
    +end
    +some_func(1,2) -- returns 2
    +some_func(1,2,{option1=true}) -- returns 1
    +
+ +
+
+ + deepcopy (object) +
+
+ Creates a deep copy of table without copying Factorio objects. + + +

Parameters:

+
    +
  • object + table + the table to copy +
  • +
+ +

Returns:

+
    + + table + a copy of the table +
+ + + +

Usage:

+
    +
    local copy = table.deepcopy[data.raw.["stone-furnace"]["stone-furnace"]] -- returns a copy of the stone furnace entity
    +
+ +
+
+ + values (tbl[, sorted[, as_string]]) +
+
+ Returns a copy of all of the values in the table. + + +

Parameters:

+
    +
  • tbl + table + the table to copy the keys from, or an empty table if tbl is nil +
  • +
  • sorted + boolean + whether to sort the keys (slower) or keep the random order from pairs() + (optional) +
  • +
  • as_string + boolean + whether to try and parse the values as strings, or leave them as their existing type + (optional) +
  • +
+ +

Returns:

+
    + + array + an array with a copy of all the values in the table +
+ + + + +
+
+ + keys (tbl[, sorted[, as_string]]) +
+
+ Returns a copy of all of the keys in the table. + + +

Parameters:

+
    +
  • tbl + table + the table to copy the keys from, or an empty table if tbl is nil +
  • +
  • sorted + boolean + whether to sort the keys (slower) or keep the random order from pairs() + (optional) +
  • +
  • as_string + boolean + whether to try and parse the keys as strings, or leave them as their existing type + (optional) +
  • +
+ +

Returns:

+
    + + array + an array with a copy of all the keys in the table +
+ + + + +
+
+ + remove_keys (tbl, keys) +
+
+ Removes keys from a table by setting the values associated with the keys to nil. + + +

Parameters:

+
    +
  • tbl + table + the table to remove the keys from +
  • +
  • keys + {Mixed,...} + an array of keys that exist in the given table +
  • +
+ +

Returns:

+
    + + table + tbl without the specified keys +
+ + + +

Usage:

+
    +
  • local a = {1, 2, 3, 4}
    +table.remove_keys(a, {1,3}) --returns {nil, 2, nil, 4}
  • +
  • local b = {k1 = 1, k2 = 'foo', old_key = 'bar'}
    +table.remove_keys(b, {'old_key'}) --returns {k1 = 1, k2 = 'foo'}
  • +
+ +
+
+ + count_keys (tbl[, func[, ...]]) +
+
+ Returns the number of keys in a table, if func is passed only count keys when the function is true. + + +

Parameters:

+
    +
  • tbl + table + to count keys +
  • +
  • func + function + to incremement counter + (optional) +
  • +
  • ... + additional arguments passed to the function + (optional) +
  • +
+ +

Returns:

+
    +
  1. + number + The number of keys matching the function or the number of all keys if func isn't passed
  2. +
  3. + number + The total number of keys
  4. +
+ + + +

Usage:

+
    +
  • local a = { 1, 2, 3, 4, 5}
    + table.count_keys(a) -- produces: 5, 5
  • +
  • local a = {1, 2, 3, 4, 5}
    + table.count_keys(a, function(v, k) return k % 2 == 1 end) -- produces: 3, 5
  • +
+ +
+
+ + invert (tbl) +
+
+ Returns an inverted (***{[value] = key,...}***) copy of the given table. If the values are not unique, the assigned key depends on the order of pairs(). + + +

Parameters:

+
    +
  • tbl + table + the table to invert +
  • +
+ +

Returns:

+
    + + table + a new table with inverted mapping +
+ + + +

Usage:

+
    +
  • local a = {k1 = 'foo', k2 = 'bar'}
    +table.invert(a) --returns {'foo' = k1, 'bar' = k2}
  • +
  • local b = {k1 = 'foo', k2 = 'bar', k3 = 'bar'}
    +table.invert(b) --returns {'foo' = k1, 'bar' = ?}
  • +
+ +
+
+ + size (table) +
+
+ Return the size of a table using built in table_size function + + +

Parameters:

+
    +
  • table + table + to use +
  • +
+ +

Returns:

+
    + + int + size of the table +
+ + + + +
+
+ + arr_to_bool (tbl) +
+
+ For all string or number values in an array map them to a key = true table + + +

Parameters:

+
    +
  • tbl + table + the table to convert +
  • +
+ +

Returns:

+
    + + table + the converted table +
+ + + +

Usage:

+
    +
    local a = {"v1", "v2"}
    + table.array_to_dict_bool(a) -- return {["v1"] = true, ["v2"]= true}
    +
+ +
+
+ + key_to_str (k) +
+
+ Returns a value in a form able to be read as a key + + +

Parameters:

+
    +
  • k + key to convert +
  • +
+ +

Returns:

+
    + + string + the converted key +
+ + + +

Usage:

+
    +
    local a = 'key'
    + table.key_to_str(a) -- return '["key"]'
    +
+ +
+
+ + to_string (tbl) +
+
+ Returns a table in a form able to be read as a table + + +

Parameters:

+
    +
  • tbl + table + table to convert +
  • +
+ +

Returns:

+
    + + string + the converted table +
+ + + +

Usage:

+
    +
    local a = {k1='foo',k2='bar'}
    + table.tostring(a) -- return '{["k1"]="foo",["k2"]="bar"}'
    +
+ +
+
+ + json (lua_table) +
+
+ Simmilar to table.to_string but converts a lua table to a json one + + +

Parameters:

+
    +
  • lua_table + table + the table to convert +
  • +
+ +

Returns:

+
    + + string + the table in a json format +
+ + + +

Usage:

+
    +
    local a = {k1='foo',k2='bar'}
    + talbe.json(a) -- return '{"k1":"foo","k2":"bar"}'
    +
+ +
+
+ + autokey (tbl, str) +
+
+ Returns the closest match to a key + + +

Parameters:

+
    +
  • tbl + +
  • +
  • str + +
  • +
+ + + + +

Usage:

+
    +
    tbl = {foo=1,bar=2}
    + table.autokey(tbl,'f') -- return 1
    +
+ +
+
+ + alphanumsort (tbl) +
+
+ Returns the list is a sorted way that would be expected by people (this is by key) + + +

Parameters:

+
    +
  • tbl + table + the table to be sorted +
  • +
+ +

Returns:

+
    + + table + the sorted table +
+ + + +

Usage:

+
    +
    tbl = table.alphanumsort(tbl)
    +
+ +
+
+ + keysort (tbl) +
+
+ Returns the list is a sorted way that would be expected by people (this is by key) (faster alterative than above) + + +

Parameters:

+
    +
  • tbl + table + the table to be sorted +
  • +
+ +

Returns:

+
    + + table + the sorted table +
+ + + +

Usage:

+
    +
    tbl = table.alphanumsort(tbl)
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/scripts/control.lua.html b/doc/scripts/control.lua.html new file mode 100644 index 00000000..ad99953a --- /dev/null +++ b/doc/scripts/control.lua.html @@ -0,0 +1,85 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Script control.lua

+

Root Script File

+

+ + + +
+
+ + + + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/doc/scripts/index.lua.html b/doc/scripts/index.lua.html new file mode 100644 index 00000000..888d05bc --- /dev/null +++ b/doc/scripts/index.lua.html @@ -0,0 +1,85 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Script index.lua

+

Used to index the files to be loaded

+

+ + + +
+
+ + + + +
+
+
+generated by LDoc 1.4.6 +Last updated 2018-05-29 20:15:05 +
+
+ + diff --git a/modules/ExpGamingLib/control.lua b/modules/ExpGamingLib/control.lua index bc691e93..8be5f427 100644 --- a/modules/ExpGamingLib/control.lua +++ b/modules/ExpGamingLib/control.lua @@ -7,12 +7,16 @@ Any changes that you may make to the code are yours but that does not make the s Discord: https://discord.gg/r6dC2uK ]] --Please Only Edit Below This Line----------------------------------------------------------- +--- Adds some common functions used though out all ExpGaming modules +-- @module ExpGamingLib +-- @alias ExpLib +-- @author Cooldude2606 local module_verbose = false -- there is no verbose in this file so true will do nothing local ExpLib = {} --- Loads a table into _G even when sandboxed; will not overwrite values or append to tables; will not work during runtime to avoid desyncs -- @usage unpack_to_G{key1='foo',key2='bar'} --- @tparam table tbl -- table to be unpacked +-- @tparam table tbl table to be unpacked function ExpLib.unpack_to_G(tbl) if not type(tbl) == 'table' or game then return end for key,value in pairs(tbl) do @@ -21,8 +25,8 @@ function ExpLib.unpack_to_G(tbl) end --- Used to get the current ENV with all _G keys removed; useful when saving function to global --- @usage get_env() -- returns current ENV with _G keys removed --- @treturn table -- the env table with _G keys removed +-- @usage get_env() returns current ENV with _G keys removed +-- @treturn table the env table with _G keys removed function ExpLib.get_env() local level = 2 local env = setmetatable({},{__index=_G}) @@ -43,9 +47,9 @@ end --- Compear types faster for faster valadation of prams -- @usage is_type('foo','string') -- return true -- @usage is_type('foo') -- return false --- @param v -- the value to be tested --- @tparam[opt=nil] string test_type -- the type to test for if not given then it tests for nil --- @treturn bolean -- is v of type test_type +-- @param v the value to be tested +-- @tparam[opt=nil] string test_type the type to test for if not given then it tests for nil +-- @treturn bolean is v of type test_type function ExpLib.is_type(v,test_type) return test_type and v and type(v) == test_type or not test_type and not v or false end @@ -54,9 +58,9 @@ end -- @usage player_return('Hello, World!') -- returns 'Hello, World!' to game.player or server console -- @usage player_return('Hello, World!','green') -- returns 'Hello, World!' to game.player with colour green or server console -- @usage player_return('Hello, World!',nil,player) -- returns 'Hello, World!' to the given player --- @param rtn -- any value of any type that will be returned to the player or console --- @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 +-- @param rtn any value of any type that will be returned to the player or console +-- @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.color[colour] local player = player or game.player @@ -84,8 +88,8 @@ end --- Convert ticks to hours -- @usage tick_to_hour(216001) -- return 1 --- @tparam number tick -- tick to convert to hours --- @treturn number -- the number of whole hours from this tick +-- @tparam number tick tick to convert to hours +-- @treturn number the number of whole hours from this tick function ExpLib.tick_to_hour(tick) if not ExpLib.is_type(tick,'number') then return 0 end return math.floor(tick/(216000*game.speed)) @@ -93,8 +97,8 @@ end --- Convert ticks to minutes -- @usage tick_to_hour(3601) -- return 1 --- @tparam number tick -- tick to convert to minutes --- @treturn number -- the number of whole minutes from this tick +-- @tparam number tick tick to convert to minutes +-- @treturn number the number of whole minutes from this tick function ExpLib.tick_to_min (tick) if not ExpLib.is_type(tick,'number') then return 0 end return math.floor(tick/(3600*game.speed)) @@ -103,8 +107,8 @@ end --- Converts a tick into a clean format for end user -- @usage tick_to_display_format(3600) -- return '1.00 M' -- @usage tick_to_display_format(234000) -- return '1 H 5 M' --- @tparam number tick -- the tick to convert --- @treturn string -- the formated string +-- @tparam number tick the tick to convert +-- @treturn string the formated string function ExpLib.tick_to_display_format(tick) if not ExpLib.is_type(tick,'number') then return '0H 0M' end if ExpLib.tick_to_min(tick) < 10 then @@ -118,9 +122,9 @@ function ExpLib.tick_to_display_format(tick) end --- Used as a way to view the structure of a gui, used for debuging --- @usage Gui_tree(root) -- returns all children of gui recusivly --- @tparam LuaGuiElement root -- the root to start the tree from --- @treturn table -- the table that describes the gui +-- @usage Gui_tree(root) returns all children of gui recusivly +-- @tparam LuaGuiElement root the root to start the tree from +-- @treturn table the table that describes the gui function ExpLib.gui_tree(root) if not ExpLib.is_type(root,'table') or not root.valid then error('Invalid Gui Element given to gui_tree',2) end local tree = {} diff --git a/StdLib/LICENSE b/modules/FactorioStdLib/LICENSE similarity index 100% rename from StdLib/LICENSE rename to modules/FactorioStdLib/LICENSE diff --git a/StdLib/color.lua b/modules/FactorioStdLib/color.lua similarity index 97% rename from StdLib/color.lua rename to modules/FactorioStdLib/color.lua index 54aa9376..6daa0d1b 100644 --- a/StdLib/color.lua +++ b/modules/FactorioStdLib/color.lua @@ -2,7 +2,6 @@ -- Extends the Factorio defines table. -- @usage require('stdlib/defines/color') -- @module defines.color --- @see Concepts.Color -- defines table is automatically required in all mod loading stages. -- luacheck: ignore 122/defines @@ -210,10 +209,6 @@ setmetatable(defines.anticolor, _mt.anticolor) setmetatable(defines.text_color, _mt.text_color) setmetatable(defines.lightcolor, _mt.lightcolor) ---- For playing with colors. --- @module Color --- @usage local Color = require('stdlib/color/color') - local Color = {} --luacheck: allow defined top --- Set a value for the alpha channel in the given color table. @@ -234,7 +229,7 @@ function Color.set(color, alpha) end --- Converts a color in the array format to a color in the table format. --- @tparam array c_arr the color to convert — { [1] = @{float}, [2] = @{float}, [3] = @{float}, [4] = @{float} } +-- @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] } function Color.to_table(c_arr) if #c_arr > 0 then diff --git a/StdLib/game.lua b/modules/FactorioStdLib/game.lua similarity index 100% rename from StdLib/game.lua rename to modules/FactorioStdLib/game.lua diff --git a/StdLib/load.lua b/modules/FactorioStdLib/load.lua similarity index 100% rename from StdLib/load.lua rename to modules/FactorioStdLib/load.lua diff --git a/modules/FactorioStdLib/softmod.json b/modules/FactorioStdLib/softmod.json new file mode 100644 index 00000000..db47a8a3 --- /dev/null +++ b/modules/FactorioStdLib/softmod.json @@ -0,0 +1,14 @@ +{ + "name": "FactorioStdLib", + "module": "StdLib", + "description": "Factorio Standard Library Projects", + "keywords": ["Standard Library","Lib","StdLib"], + "version": "0.8.0", + "location": "nil", + "submodules": { + + }, + "author": "Afforess", + "contact": "https://github.com/Afforess/Factorio-Stdlib/issues", + "license": "https://github.com/Afforess/Factorio-Stdlib/blob/master/LICENSE" +} \ No newline at end of file diff --git a/StdLib/string.lua b/modules/FactorioStdLib/string.lua similarity index 100% rename from StdLib/string.lua rename to modules/FactorioStdLib/string.lua diff --git a/StdLib/table.lua b/modules/FactorioStdLib/table.lua similarity index 99% rename from StdLib/table.lua rename to modules/FactorioStdLib/table.lua index 783507b6..958cb21b 100644 --- a/StdLib/table.lua +++ b/modules/FactorioStdLib/table.lua @@ -498,7 +498,7 @@ end --- Returns the list is a sorted way that would be expected by people (this is by key) -- @usage tbl = table.alphanumsort(tbl) --- @tparam tbl table the table to be sorted +-- @tparam table tbl the table to be sorted -- @treturn table the sorted table function table.alphanumsort(tbl) local o = table.keys(tbl) @@ -514,7 +514,7 @@ end --- Returns the list is a sorted way that would be expected by people (this is by key) (faster alterative than above) -- @usage tbl = table.alphanumsort(tbl) --- @tparam tbl table the table to be sorted +-- @tparam table tbl the table to be sorted -- @treturn table the sorted table function table.keysort(tbl) local o = table.keys(tbl,true) diff --git a/StdLib/time.lua b/modules/FactorioStdLib/time.lua similarity index 100% rename from StdLib/time.lua rename to modules/FactorioStdLib/time.lua diff --git a/modules/index.lua b/modules/index.lua index da98a4a0..2dabc4dc 100644 --- a/modules/index.lua +++ b/modules/index.lua @@ -1,3 +1,5 @@ +--- Used to index the files to be loaded +-- @script index.lua return { ['ExpLib']='/modules/ExpGamingLib/control', } \ No newline at end of file