Module ExpGamingLib
Adds some common functions used though out all ExpGaming modules
Info:
- Author: Cooldude2606
Functions
| unpack_to_G (tbl) | Loads a table into _G even when sandboxed; will not overwrite values or append to tables; will not work during runtime to avoid desyncs |
| get_env () | Used to get the current ENV with all _G keys removed; useful when saving function to global |
| is_type (v[, test_type=nil]) | Compear types faster for faster valadation of prams |
| 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 |
| tick_to_hour (tick) | Convert ticks to hours |
| tick_to_min (tick) | Convert ticks to minutes |
| tick_to_display_format (tick) | Converts a tick into a clean format for end user |
| gui_tree (root) | Used as a way to view the structure of a gui, used for debuging |
Functions
- unpack_to_G (tbl)
-
Loads a table into _G even when sandboxed; will not overwrite values or append to tables; will not work during runtime to avoid desyncs
Parameters:
- tbl table table to be unpacked
Usage:
unpack_to_G{key1='foo',key2='bar'} - 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
- 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
- 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
- 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
- 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
- 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'
- 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