Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 6 additions & 21 deletions lua/glide/client/spawn_tab.lua
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
local function GetCategoryVehicles( category )
local type = type

local function Validate( t )
if type( t ) ~= "table" then return false end
if type( t.ClassName ) ~= "string" then return false end
if type( t.GlideCategory ) ~= "string" then return false end

return true
end

local filtered = {}
local i = 0

for class, data in pairs( scripted_ents.GetList() ) do
local t = data.t

if Validate( t ) and t.GlideCategory == category then
i = i + 1
filtered[i] = {
for class, data in pairs( list.Get( "GlideVehicles" ) or {} ) do
if data.Category == category then
filtered[#filtered + 1] = {
class = class,
name = t.PrintName,
icon = t.IconOverride or "entities/" .. class .. ".png",
adminOnly = t.AdminOnly
name = data.Name,
icon = data.IconOverride or "entities/" .. class .. ".png",
adminOnly = data.AdminOnly
}
end
end
Expand Down
48 changes: 23 additions & 25 deletions lua/glide/sh_lists.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,30 @@ list.Set( "GlideProjectileModels", "models/props_phx/misc/potato_launcher_explos
-- Find and register all entities that are children of `base_glide`
-- (or any of it's children classes) on the duplicator/entity limit system.
-- Also add them to a separate list, and make them spawnable on Starfall.
hook.Add( "InitPostEntity", "Glide.RegisterEntityClasses", function()
local IsBasedOn = scripted_ents.IsBasedOn
local RegisterEntityClass = duplicator.RegisterEntityClass
if SERVER then
hook.Add( "InitPostEntity", "Glide.RegisterEntityClasses", function()
if SF == nil then return end

local isStarfallAvailable = SF ~= nil
local starfallData = { {} }

for class, data in pairs( scripted_ents.GetList() ) do
if IsBasedOn( class, "base_glide" ) then
if SERVER then
RegisterEntityClass( class, Glide.VehicleFactory, "Data" )

if isStarfallAvailable then
list.Set( "starfall_creatable_sent", class, starfallData )
end
end
local starfallData = { {} }
for class, _ in pairs( list.Get( "GlideVehicles" ) ) do
list.Set( "starfall_creatable_sent", class, starfallData )
end
end )
end

local entTable = data["t"]
local RegisterEntityClass = duplicator.RegisterEntityClass
hook.Add( "PreRegisterSENT", "Glide.RegisterEntityClasses", function( tbl, class )
if not tbl or not class then return end
if not tbl.GlideCategory or tbl.GlideCategory == "" then return end

if entTable and entTable.GlideCategory then
list.Set( "GlideVehicles", class, {
Name = entTable.PrintName or class,
Category = entTable.GlideCategory or "Default",
Model = entTable.ChassisModel
} )
end
end
if SERVER then
RegisterEntityClass( class, Glide.VehicleFactory, "Data" )
end
end )

list.Set( "GlideVehicles", class, {
Name = tbl.PrintName or class,
Category = tbl.GlideCategory or "Default",
IconOverride = tbl.IconOverride,
Model = tbl.ChassisModel
} )
end )
Loading