-- Funcom LUA lib -- This is a library of utils/common lua methods that is automatically loaded when the LUA VM is created -- randomly rearrange the item sequence of the array/table t (in place) -- t: a table or array function fc_shuffle(t) local n = #t while n >= 2 do -- n is now the last pertinent index local k = math.random(n) -- 1 <= k <= n -- Quick swap t[n], t[k] = t[k], t[n] n = n - 1 end return t end -- return true if input string is null or empty function fc_empty(s) return not s or s == '' end -- round number to the given number of decimal places (optional) function fc_round( val, decimalPlaces ) local mult = 10 ^ ( decimalPlaces or 0) return math.floor( val * mult + 0.5 ) / mult end -- retrieve the value of a command line parameter function fc_get_cmdline_arg( arg_name, default_value ) val = engine.GetCmdlineArg( arg_name ) if fc_empty( val ) and default_value then val = default_value end return val end -- run a console command local function fc_run_cmd( cmd ) return DWEngine.ExecuteConsoleCommand( "/" .. cmd ) end