new post | browse code | authors | help | about

LuaBin 2.0

Viewing file root / lua / autorun / developer_functions.lua

  1.  
  2. local function FindInTable( tab, find, parents, depth )
  3.  
  4.         depth = depth or 0
  5.         parents = parents or ""
  6.        
  7.         if ( depth > 3 ) then return end
  8.         depth = depth + 1
  9.        
  10.         for k, v in pairs ( tab ) do
  11.        
  12.                 if ( type(k) == "string" ) then
  13.                
  14.                         if ( k && k:lower():find( find:lower() ) ) then
  15.  
  16.                                 Msg("\t", parents, k, " - (", type(v), " - ", v, ")\n")
  17.                        
  18.                         end
  19.                        
  20.                         // Recurse
  21.                         if ( type(v) == "table" &&
  22.                                 k != "_R" &&
  23.                                 k != "_E" &&
  24.                                 k != "_G" &&
  25.                                 k != "_M" &&
  26.                                 k != "_LOADED" &&
  27.                                 k != "__index" ) then
  28.                                
  29.                                 local NewParents = parents .. k .. ".";
  30.                                 FindInTable( v, find, NewParents, depth )
  31.                        
  32.                         end
  33.                
  34.                 end
  35.        
  36.         end
  37.  
  38. end
  39.  
  40.  
  41. /*---------------------------------------------------------
  42.    Name:        Find
  43. ---------------------------------------------------------*/  
  44. local function Find( ply, command, arguments )
  45.  
  46.         if ( ply && !ply:IsAdmin() ) then return end
  47.         if ( !arguments[1] ) then return end
  48.        
  49.         if ( SERVER ) then      Msg("Finding '", arguments[1], "' SERVERSIDE:\n\n") else
  50.                                                 Msg("Finding '", arguments[1], "' CLIENTSIDE:\n\n") end
  51.        
  52.         FindInTable( _G, arguments[1] )
  53.         FindInTable( _R, arguments[1] )
  54.        
  55.         Msg("\n\n")
  56.        
  57.         if ( SERVER && ply ) then
  58.                 RunConsoleCommand( "lua_find_cl", tostring(arguments[1]) );
  59.         end
  60.        
  61. end
  62.  
  63. if ( SERVER ) then
  64.         concommand.Add( "lua_find", Find )
  65. else
  66.         concommand.Add( "lua_find_cl", Find )
  67. end
  68.  
  69.  
  70. if ( CLIENT ) then
  71.  
  72.         local function EntInfo( player, command, arguments )
  73.        
  74.                 local tr = player:GetEyeTrace()
  75.                 if ( ValidEntity( tr.Entity ) ) then
  76.                
  77.                         Msg("Class: ", tr.Entity:GetClass(), "\n")
  78.                         Msg("Model: ", tr.Entity:GetModel(), "\n")
  79.                
  80.                 end
  81.        
  82.         end
  83.  
  84.         concommand.Add( "ent_printinfo", EntInfo )
  85.        
  86. end
  87.