Guest User

Untitled

a guest
Jun 1st, 2012
44
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TOOL.Category = "Tech"
  2. TOOL.Tab = "Ship"
  3. TOOL.Name = "#Cores"
  4. TOOL.Command = nil
  5. TOOL.ConfigName = "" --Setting this means that you do not have to create external configuration files to define the layout of the tool config-hud
  6. /*
  7. TOOL.Topic["name"] = "Cores";
  8. TOOL.Topic["desc"] = "Creates a Ship Core";
  9. TOOL.Topic[0] = "Left click, to spawn the selected Ship Core";
  10.  
  11. TOOL.ClientConVar["autolink"] = 1;
  12. TOOL.ClientConVar["autoweld"] = 1;
  13. TOOL.ClientConVar["coretype"] = 1;
  14.  
  15. TOOL.Language["Undone"] = "Core Generator removed";
  16. TOOL.Language["Cleanup"] = "Ship Cores";
  17. TOOL.Language["Cleaned"] = "Removed all Ship Cores";
  18. TOOL.Language["SBoxLimit"] = "Hit the Ship Core limit";
  19. */
  20. TOOL.coretype = nil
  21.  
  22. function TOOL:LeftClick( trace )
  23. if (CLIENT) then return true end
  24. if(self.coretype!=nil) then
  25. print("spawn")
  26. local entity = ents.Create(self.coretype)
  27. if not entity or not entity:IsValid() then return false end
  28. local pos = trace.HitPos
  29. local ang = trace.HitNormal:Angle()+Angle(90,0,0)
  30. entity:SetAngles(ang)
  31. entity:SetPos(pos)
  32. entity:Spawn()
  33. entity:Initialize()
  34. entity:SetPos(trace.HitPos - trace.HitNormal * entity:OBBMins().z)
  35. end
  36. end
  37.  
  38. function TOOL:RightClick( trace )
  39. end
  40.  
  41. function TOOL.BuildCPanel( panel )
  42. panel:AddControl("Header", { Text = "Example TOOL", Description = "Just an little example" })
  43.  
  44. panel:AddControl("CheckBox", {
  45. Label = "Weld",
  46. //Command = "example_bool"
  47. })
  48. panel:AddControl("CheckBox", {
  49. Label = "AutoFreeze",
  50. //Command = "example_bool"
  51. })
  52.  
  53. local ctrl = vgui.Create( "DTree", panel )
  54.  
  55. ctrl:SetPos( 5, 30 )
  56. ctrl:SetPadding( 5 )
  57. ctrl:SetSize( 300, 300 )
  58.  
  59. treeitems = {}
  60. ctrl.DoClick = function ()
  61. for i=1,table.Count(treeitems) do
  62. if(string.Explode("^", treeitems[i])[1]==tostring(ctrl:GetSelectedItem())) then
  63. local name = string.Explode("^", treeitems[i])[2]
  64. if(name!="dontspawn") then
  65. TOOL.coretype = name
  66. print(name)
  67. else
  68. TOOL.coretype = nil
  69. end
  70. break
  71. end
  72. end
  73. end
  74.  
  75. local node = ctrl:AddNode( "Ship Cores" ); treeitems[table.Count(treeitems)+1] = tostring(node).."^dontspawn"
  76. local ctnode = node:AddNode( "Large Core" ); treeitems[table.Count(treeitems)+1] = tostring(ctnode).."^sf_shipcore_large"
  77. ctnode.Icon:SetImage( "gui/silkicons/newspaper" )
  78. local ctnode = node:AddNode( "Small Core" ); treeitems[table.Count(treeitems)+1] = tostring(ctnode).."^sf_shipcore_small"
  79. ctnode.Icon:SetImage( "gui/silkicons/newspaper" )
  80. local node = ctrl:AddNode( "Station Cores" ); treeitems[table.Count(treeitems)+1] = tostring(node).."^dontspawn"
  81. local ctnode = node:AddNode( "Large Core" ); treeitems[table.Count(treeitems)+1] = tostring(ctnode).."^sf_stationcore_large"
  82. ctnode.Icon:SetImage( "gui/silkicons/newspaper" )
  83. local ctnode = node:AddNode( "Small Core" ); treeitems[table.Count(treeitems)+1] = tostring(ctnode).."^sf_stationcore_small"
  84. ctnode.Icon:SetImage( "gui/silkicons/newspaper" )
  85.  
  86. panel:AddPanel(ctrl)
  87.  
  88. end
RAW Paste Data