Module FSM
Factorio Softmod Manager
Usage:
Manager = require("FactorioSoftmodManager")
Info:
global |
Used to avoid conflicts in the global table |
-
_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!')
-
setVerbose (settings)
-
Main logic for allowing verbose at different stages though out the script
Parameters:
- settings
newTbl
the table that will be searched for settings to be updated
Usage:
Manager.setVerbose{output=log}
Manager.setVerbose[setting]
tostring(Manager.setVerbose)
-
sandbox (callback[, env])
-
Creates a sand box envorment and runs a callback in that sand box; provents global pollution
Parameters:
- callback
function
the function that will be ran in the sandbox
- env
any other params that the function will use
(optional)
Usage:
-
loadModules ()
-
Loads the modules that are present in the index list
Usage:
-
error (err, callback)
-
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
Parameters:
- err
string or fucntion
the string to be passed to handlers; if a function it will register a handler
- callback
function
if given the err param will be used to given the handler a name
Usage:
-
event (event_name, callback)
-
Event handler that modules can use, each module can register one function per event
Parameters:
- event_name
int or string
that referes to an event
- callback
function
the function that will be set for that event
Usage:
Manager.event[event_name] = callback
Manager.event[event_name] = nil
Manager.event(event_name,callback)
Manager.event[event_name]
Manager.event(event_name)
Manager.event()
#Manager.event
pairs(Manager.events)
-
verboseSettings
-
Different verbose settings used for setVerbose
Fields:
- selfInit
boolean
called while the manager is being set up
- moduleLoad
boolean
when a module is required by the manager
- moduleInit
boolean
when and within the initation of a module
- moduleEnv
boolean
during module runtime, this is a global option set within each module(module_verbose=true ln:1) for fine control
- eventRegistered
boolean
when a module registers its event handlers
- errorCaught
boolean
when an error is caught during runtime
- output
function
can be: print || log || or other function
- _output
a constant value that can used to store output data
-
Manager.event.names
-
Sub set to Manger.event and acts as a coverter between event_name and event_id
Usage:
Manager.event[event_name]
-
global
-
Used to avoid conflicts in the global table
- if
table, string or true
table then the default for the global, if a string then the module to get the global of, if true then reset the global to default
(default {})
Usage:
global[key]
global{'foo','bar'}
global(true)
global(mopdule_name)