Fixed station spawning at lua refresh

master
AlmTech Software 5 years ago
parent d640b2d56c
commit 1def9f6672
  1. 38
      gamemode/engine/lib/sh_station.lua
  2. 2
      gamemode/init.lua
  3. 3
      gamemode/settings/sv_crafting_stations_locations.lua
  4. 3
      gamemode/settings/sv_settings.lua

@ -24,6 +24,7 @@ function Quantum.Station.Add( id, tbl )
end
function Quantum.Station.Get( id )
if( isnumber(id) ) then return nil end
return Quantum.Stations[id]
end
@ -33,12 +34,8 @@ end
if SERVER then
Quantum.Server.Station = {}
if( Stations == nil ) then
Stations = {}
Stations.Locations = {}
end
Quantum.Server.Stations = {}
Quantum.Server.Stations.Locations = {}
function Quantum.Server.Station.Spawn( stationid, pos, ang ) -- internal function
local ent = ents.Create( "q_crafting_station" )
@ -53,16 +50,20 @@ if SERVER then
end
function Quantum.Server.Station.Register( stationid, vec, angle )
if( Stations.Locations == nil ) then
if( Quantum.Server.Stations.Locations == nil ) then
Quantum.Error( "Station tbl is nil" )
end
Quantum.Debug( "Registering station '" .. tostring( stationid ) .. "'." )
Stations.Locations[ #Stations.Locations + 1] = {
if( Quantum.Station.Get( stationid ) == nil ) then
Quantum.Error( "The station id is not valid! (" .. tostring( #Quantum.Server.Stations.Locations + 1 ) .. ")" )
end
Quantum.Debug( "Registering station '" .. tostring( stationid ) .. "' (" .. tostring(#Quantum.Server.Stations.Locations + 1) .. ")" )
Quantum.Server.Stations.Locations[#Quantum.Server.Stations.Locations + 1] = {
id = stationid,
pos = vec,
ang = angle
}
print(Stations.Locations[#Stations.Locations])
end
function Quantum.Server.Station.Create( id, tbl )
@ -74,8 +75,7 @@ if SERVER then
end
function Quantum.Server.Station.SpawnAllRegistered()
for i, station in pairs( Stations.Locations ) do
print("spawning")
for i, station in pairs( Quantum.Server.Stations.Locations ) do
Quantum.Server.Station.Create( station.id, { pos = station.pos, ang = station.ang } )
end
end
@ -93,15 +93,11 @@ if SERVER then
end
function Quantum.Server.Station.UpdateAll()
--Quantum.Server.Station.RemoveAll() -- remove all stations on lua refresh
Quantum.Debug( "Updating station locations..." )
Quantum.Server.Station.RemoveAll() -- remove all stations on lua refresh
Quantum.Server.Station.SpawnAllRegistered() -- and create new ones
end
print("##############")
PrintTable( Stations.Locations )
print("##############")
hook.Add( "PlayerInitialSpawn", "Quantum_Init_Stations_Load", function()
Quantum.Debug( "Spawning registered crafting stations..." )
@ -116,8 +112,10 @@ if SERVER then
if( key == IN_USE ) then
local ent = pl:GetEyeTraceNoCursor().Entity
if( ent:GetClass() == "q_crafting_station" ) then
pl:SetLocalVelocity( Vector( 0, 0, 0 ) )
Quantum.Net.OpenMenu( pl, "crafting", { stationEnt = ent, station = ent.stationid } )
if( ent:GetPos():Distance( pl:GetPos() ) <= 100 ) then
pl:SetLocalVelocity( Vector( 0, 0, 0 ) )
Quantum.Net.OpenMenu( pl, "crafting", { stationEnt = ent, station = ent.stationid } )
end
end
end
end

@ -120,6 +120,8 @@ if SERVER then
include( "settings/sh_crafting_stations.lua" )
include( "settings/sh_recipes.lua" )
include( "settings/sv_crafting_stations_locations.lua" )
Quantum.Server.Station.UpdateAll()
end
local function loadPlugins()

@ -5,4 +5,5 @@
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.Server.Station.Register( "barrel", Vector( 747.13494873047, 10483.685546875, 7168.0317382813 ), Angle( 0, -118.23150634766, 0 ) )
Quantum.Server.Station.Register( "barrel", Vector( 747.13494873047, 10483.685546875, 7168.0317382813 ), Angle( 0, -118.23150634766, 0 ) )
Quantum.Server.Station.Register( "barrel", Vector( 885.861328125, 10542.946289063, 7168.03125 ), Angle( 0, -118.23150634766, 0 ) )

@ -113,8 +113,7 @@ Quantum.Server.Settings.IdlePainSounds.Female = {
--- Features to be added ---
Quantum.Server.Settings.MaxJobLevel = 250
Quantum.Server.Settings.MaxJobSlots = Vector( 12418.626953125, 9959.9345703125, 320.03125 )
Angle( 65.102394104004, -2.1179277896881, 0 )
Quantum.Server.Settings.MaxJobSlots = 2
Quantum.Server.Settings.MaxSkillLevel = 100

Loading…
Cancel
Save