You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
5 years ago
|
-- __ _ _______ _ __
|
||
|
-- / / /\ | | |__ __| | | \ \
|
||
|
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
|
||
|
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
|
||
|
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
|
||
|
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
|
||
|
|
||
|
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
|