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
self.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
self.coretype = name
print(name)
else
self.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