Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TOOL.Category = "Tech"
- TOOL.Tab = "Ship"
- TOOL.Name = "#Cores"
- TOOL.Command = nil
- TOOL.ConfigName = "" --Setting this means that you do not have to create external configuration files to define the layout of the tool config-hud
- /*
- TOOL.Topic["name"] = "Cores";
- TOOL.Topic["desc"] = "Creates a Ship Core";
- TOOL.Topic[0] = "Left click, to spawn the selected Ship Core";
- TOOL.ClientConVar["autolink"] = 1;
- TOOL.ClientConVar["autoweld"] = 1;
- TOOL.ClientConVar["coretype"] = 1;
- TOOL.Language["Undone"] = "Core Generator removed";
- TOOL.Language["Cleanup"] = "Ship Cores";
- TOOL.Language["Cleaned"] = "Removed all Ship Cores";
- TOOL.Language["SBoxLimit"] = "Hit the Ship Core limit";
- */
- TOOL.coretype = nil
- function TOOL:LeftClick( trace )
- if (CLIENT) then return true end
- if(self.coretype!=nil) then
- print("spawn")
- local entity = ents.Create(self.coretype)
- if not entity or not entity:IsValid() then return false end
- local pos = trace.HitPos
- local ang = trace.HitNormal:Angle()+Angle(90,0,0)
- entity:SetAngles(ang)
- entity:SetPos(pos)
- entity:Spawn()
- entity:Initialize()
- entity:SetPos(trace.HitPos - trace.HitNormal * entity:OBBMins().z)
- end
- end
- function TOOL:RightClick( trace )
- end
- function TOOL.BuildCPanel( panel )
- panel:AddControl("Header", { Text = "Example TOOL", Description = "Just an little example" })
- panel:AddControl("CheckBox", {
- Label = "Weld",
- //Command = "example_bool"
- })
- panel:AddControl("CheckBox", {
- Label = "AutoFreeze",
- //Command = "example_bool"
- })
- local ctrl = vgui.Create( "DTree", panel )
- ctrl:SetPos( 5, 30 )
- ctrl:SetPadding( 5 )
- ctrl:SetSize( 300, 300 )
- treeitems = {}
- ctrl.DoClick = function ()
- for i=1,table.Count(treeitems) do
- if(string.Explode("^", treeitems[i])[1]==tostring(ctrl:GetSelectedItem())) then
- local name = string.Explode("^", treeitems[i])[2]
- if(name!="dontspawn") then
- TOOL.coretype = name
- print(name)
- else
- TOOL.coretype = nil
- end
- break
- end
- end
- end
- local node = ctrl:AddNode( "Ship Cores" ); treeitems[table.Count(treeitems)+1] = tostring(node).."^dontspawn"
- local ctnode = node:AddNode( "Large Core" ); treeitems[table.Count(treeitems)+1] = tostring(ctnode).."^sf_shipcore_large"
- ctnode.Icon:SetImage( "gui/silkicons/newspaper" )
- local ctnode = node:AddNode( "Small Core" ); treeitems[table.Count(treeitems)+1] = tostring(ctnode).."^sf_shipcore_small"
- ctnode.Icon:SetImage( "gui/silkicons/newspaper" )
- local node = ctrl:AddNode( "Station Cores" ); treeitems[table.Count(treeitems)+1] = tostring(node).."^dontspawn"
- local ctnode = node:AddNode( "Large Core" ); treeitems[table.Count(treeitems)+1] = tostring(ctnode).."^sf_stationcore_large"
- ctnode.Icon:SetImage( "gui/silkicons/newspaper" )
- local ctnode = node:AddNode( "Small Core" ); treeitems[table.Count(treeitems)+1] = tostring(ctnode).."^sf_stationcore_small"
- ctnode.Icon:SetImage( "gui/silkicons/newspaper" )
- panel:AddPanel(ctrl)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement