/*
     _      ____     _  _____ ____  _____  _  ____ 
    / \__/|/  _ \   / |/  __// ___\/__ __\/ \/   _\
    | |\/||| / \|   | ||  \  |    \  / \  | ||  /  
    | |  ||| |-||/\_| ||  /_ \___ |  | |  | ||  \_ 
    \_/  \|\_/ \|\____/\____\\____/  \_/  \_/\____/
    quality security script by paradox
*/


//--/~ Basic Data
local majestic = {  }

-- Copy Table
function majestic.CopyTable( t, lookup_table )
	if not t then return end -- Yeah this isn't my code, this is default Garry's Mod, wtf...

	local copy = { }
	setmetatable( copy, debug.getmetatable( t ) )

	for i, v in pairs( t ) do
		if ( !istable( v ) ) then
			copy[ i ] = v
		else
			lookup_table = lookup_table or {}
			lookup_table[ t ] = copy
            
			if ( lookup_table[ v ] ) then
				copy[ i ] = lookup_table[ v ]
			else
				copy[ i ] = majestic.CopyTable( v, lookup_table )
			end
		end
	end

	return copy
end 

-- Globals
local __G = majestic.CopyTable( _G )

-- Detours
    majestic.Detours = {  }

-- Enviroment
    majestic.enviroment = setmetatable( {
        majestic = majestic,
        
        _G = _G,
        __G = __G,
    }, {
        __index = __G,
    } )

-- Enviroment Loaders
    majestic.loadCode = function( Code )
        if Code then 
            local Func = __G.setfenv( __G.CompileString( Code ), majestic.enviroment ) 
        
            if isfunction( Func ) then 
                Func( )

                return true 
            end
        end

        return false 
    end

    majestic.loadFile = function( Dir ) 
        if __G.file.Exists( 'lua/' .. Dir, 'GAME' ) then 
            local Code = __G.file.Open( 'lua/' .. Dir, 'rb', 'GAME' )

            return majestic.loadCode( Code:Read( Code:Size( ) ) )
        end

        return false 
    end

//-/~ Includes
majestic.loadFile ( 'majestic/modules/includes.lua' )

//--/~ Sub-Module Booters
majestic.loadFile ( 'majestic/modules/utility.lua' ) 
majestic.loadFile ( 'majestic/modules/detours.lua' ) 