parent
8afcd62e75
commit
1c5f30ed06
@ -0,0 +1,12 @@ |
||||
-- __ _ _______ _ __ |
||||
-- / / /\ | | |__ __| | | \ \ |
||||
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ |
||||
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > |
||||
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / |
||||
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ |
||||
|
||||
include( "shared.lua" ) |
||||
|
||||
function ENT:Draw() |
||||
self:DrawModel() |
||||
end |
@ -0,0 +1,50 @@ |
||||
-- __ _ _______ _ __ |
||||
-- / / /\ | | |__ __| | | \ \ |
||||
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ |
||||
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > |
||||
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / |
||||
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ |
||||
|
||||
AddCSLuaFile( "cl_init.lua" ) |
||||
AddCSLuaFile( "shared.lua" ) |
||||
|
||||
include( "shared.lua" ) |
||||
|
||||
function ENT:Initialize() |
||||
|
||||
self:PhysicsInit( SOLID_BSP ) |
||||
self:SetMoveType( MOVETYPE_VPHYSICS ) |
||||
self:SetSolid( SOLID_VPHYSICS ) |
||||
self:SetCollisionGroup( COLLISION_GROUP_NONE ) |
||||
|
||||
local physObj = self:GetPhysicsObject() |
||||
if( IsValid( physObj ) ) then |
||||
physObj:EnableMotion( false ) -- dont want it to move |
||||
end |
||||
|
||||
end |
||||
|
||||
function ENT:Use( activator, caller ) |
||||
if( activator:IsPlayer() ) then |
||||
|
||||
end |
||||
end |
||||
|
||||
function ENT:InitializeStation( stationid, pos, ang ) |
||||
if( pos == nil || ang == nil ) then return end |
||||
|
||||
local stationTbl = Quantum.Station.Get( stationid ) |
||||
|
||||
if( stationTbl != nil ) then |
||||
self:SetModel( stationTbl.model ) |
||||
self.stationid = stationid |
||||
|
||||
self:SetNWString( "q_station_id", stationid ) |
||||
|
||||
self:SetPos( pos ) |
||||
self:SetAngles( ang ) |
||||
else |
||||
Quantum.Error( "Station Table could not be found '" .. stationid .. "'!" ) |
||||
self:Remove() |
||||
end |
||||
end |
@ -0,0 +1,15 @@ |
||||
-- __ _ _______ _ __ |
||||
-- / / /\ | | |__ __| | | \ \ |
||||
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ |
||||
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > |
||||
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / |
||||
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ |
||||
|
||||
ENT.Type = "anim" |
||||
ENT.Base = "base_entity" |
||||
|
||||
ENT.PrintName = "Quantum Item" |
||||
ENT.Author = "AlmTech" |
||||
ENT.Contact = "elias@almtech.se" |
||||
ENT.Spawnable = false |
||||
ENT.AdminSpawnable = false |
@ -0,0 +1,66 @@ |
||||
-- __ _ _______ _ __ |
||||
-- / / /\ | | |__ __| | | \ \ |
||||
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ |
||||
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > |
||||
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / |
||||
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ |
||||
|
||||
Quantum.Station = {} |
||||
|
||||
Quantum.Stations = {} |
||||
|
||||
function Quantum.Station.Add( id, tbl ) |
||||
|
||||
local returnTbl = { |
||||
stationid = id, |
||||
name = tbl.name || "Crafting Station", -- name of the station |
||||
model = tbl.model || "models/props_phx/facepunch_barrel.mdl", |
||||
recipes = tbl.recipes || {} |
||||
} |
||||
|
||||
Quantum.Stations[ id ] = returnTbl |
||||
|
||||
return returnTbl |
||||
end |
||||
|
||||
function Quantum.Station.Get( id ) |
||||
return Quantum.Stations[id] |
||||
end |
||||
|
||||
if SERVER then |
||||
Quantum.Server.Station = {} |
||||
|
||||
function Quantum.Server.Station.Spawn( stationid, pos, ang ) -- internal function |
||||
local ent = ents.Create( "q_crafting_station" ) |
||||
if( IsValid( ent ) ) then |
||||
ent:InitializeStation( stationid, pos, ang ) |
||||
ent:Spawn() |
||||
end |
||||
end |
||||
|
||||
local function floorVectorString( vec ) |
||||
return tostring(math.floor( vec.x )) .. ", " .. tostring(math.floor( vec.y )) .. ", " .. tostring(math.floor( vec.z )) |
||||
end |
||||
|
||||
function Quantum.Server.Station.Create( id, tbl ) |
||||
local stationTbl = Quantum.Station.Get( id ) |
||||
|
||||
if( stationTbl != nil ) then |
||||
Quantum.Server.Station.Spawn( id, tbl.pos, tbl.ang ) |
||||
end |
||||
end |
||||
|
||||
function Quantum.Server.Station.Remove( station ) |
||||
if( IsValid( station ) ) then |
||||
station:Remove() |
||||
end |
||||
end |
||||
|
||||
function Quantum.Server.Station.RemoveAll() |
||||
for i, station in pairs( ents.FindByClass( "q_crafting_station" ) ) do |
||||
Quantum.Server.Station.Remove( station ) |
||||
end |
||||
end |
||||
|
||||
Quantum.Server.Station.RemoveAll() -- remove all stations on lua refresh |
||||
end |
@ -0,0 +1,12 @@ |
||||
-- __ _ _______ _ __ |
||||
-- / / /\ | | |__ __| | | \ \ |
||||
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ |
||||
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > |
||||
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / |
||||
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ |
||||
|
||||
-- Add all of the station "categories" here -- |
||||
Quantum.Station.Add( "barrel", { |
||||
name = "Crafting Barrel", |
||||
model = "models/props_phx/facepunch_barrel.mdl" |
||||
}) |
@ -0,0 +1,11 @@ |
||||
-- __ _ _______ _ __ |
||||
-- / / /\ | | |__ __| | | \ \ |
||||
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ |
||||
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > |
||||
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / |
||||
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ |
||||
|
||||
Quantum.Server.Station.Create( "barrel", { |
||||
pos = Vector( 10, 0, 0 ), |
||||
ang = Angle( 0, 0, 0 ) |
||||
}) |
Loading…
Reference in new issue