Added crafting stations

master
AlmTech Software 5 years ago
parent 8afcd62e75
commit 1c5f30ed06
  1. 12
      entities/entities/q_crafting_station/cl_init.lua
  2. 50
      entities/entities/q_crafting_station/init.lua
  3. 15
      entities/entities/q_crafting_station/shared.lua
  4. 2
      gamemode/cl_init.lua
  5. 5
      gamemode/engine/lib/sh_recipe.lua
  6. 66
      gamemode/engine/lib/sh_station.lua
  7. 11
      gamemode/init.lua
  8. 12
      gamemode/settings/sh_crafting_stations.lua
  9. 11
      gamemode/settings/sv_crafting_stations_locations.lua
  10. 2
      gamemode/shared.lua

@ -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

@ -49,6 +49,8 @@ if CLIENT then
local function loadAllItemsAndEffects() local function loadAllItemsAndEffects()
include( "settings/sh_items.lua" ) include( "settings/sh_items.lua" )
include( "settings/sh_effects.lua" ) include( "settings/sh_effects.lua" )
include( "settings/sh_crafting_stations.lua" )
include( "settings/sh_recipes.lua" )
end end
local function loadPlugins() local function loadPlugins()

@ -24,6 +24,11 @@ function Quantum.Recipe.Add( itemid, station, tbl )
Quantum.Recipes[ itemid ] = returnTbl Quantum.Recipes[ itemid ] = returnTbl
Quantum.Recipes[ itemid ].delay = math.Clamp( Quantum.Recipes[ itemid ].delay, Quantum.MinCraftDelay, Quantum.MaxCraftDelay ) Quantum.Recipes[ itemid ].delay = math.Clamp( Quantum.Recipes[ itemid ].delay, Quantum.MinCraftDelay, Quantum.MaxCraftDelay )
-- add the recipe to the stations recipe list --
if( returnTbl.station != nil ) then
table.insert( Quantum.Stations[ returnTbl.station ].recipes, itemid )
end
return returnTbl return returnTbl
end end

@ -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

@ -15,6 +15,7 @@ if SERVER then
AddCSLuaFile( "settings/sh_items.lua" ) AddCSLuaFile( "settings/sh_items.lua" )
AddCSLuaFile( "settings/sh_effects.lua" ) AddCSLuaFile( "settings/sh_effects.lua" )
AddCSLuaFile( "settings/sh_recipes.lua" ) AddCSLuaFile( "settings/sh_recipes.lua" )
AddCSLuaFile( "settings/sh_crafting_stations.lua" )
AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" ) AddCSLuaFile( "shared.lua" )
@ -115,9 +116,18 @@ if SERVER then
local function loadAllItemsAndEffects() local function loadAllItemsAndEffects()
include( "settings/sh_items.lua" ) include( "settings/sh_items.lua" )
include( "settings/sh_effects.lua" ) include( "settings/sh_effects.lua" )
include( "settings/sh_crafting_stations.lua" )
include( "settings/sh_recipes.lua" ) include( "settings/sh_recipes.lua" )
end end
local function loadStations()
include( "settings/sv_crafting_stations_locations.lua" )
end
hook.Add( "PostGamemodeLoaded", "Quantum_Init_Stations_Load", function()
Quantum.Debug( "Spawning crafting stations..." )
loadStations()
end)
local function loadPlugins() local function loadPlugins()
@ -152,5 +162,6 @@ if SERVER then
end end
Quantum.Server.Load() Quantum.Server.Load()
loadStations()
MsgC( "\n" ) MsgC( "\n" )
end 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 )
})

@ -11,7 +11,7 @@ GM.Email = "elias@almtech.se"
GM.Website = "N/A" GM.Website = "N/A"
Quantum = {} Quantum = {}
Quantum.Version = "v0.3-alpha" Quantum.Version = "v0.4-alpha"
include( "engine/sh_debug.lua" ) -- add the debug functions and stuff include( "engine/sh_debug.lua" ) -- add the debug functions and stuff

Loading…
Cancel
Save