Station mounting fix

master
AlmTech Software 5 years ago
parent ada8e98d4f
commit d640b2d56c
  1. 1
      gamemode/engine/derma/menus/menu_crafting.lua
  2. 27
      gamemode/engine/lib/sh_station.lua

@ -264,6 +264,7 @@ function menu.open( dt )
end end
overlay.DoClick = function( self ) overlay.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" )
selectedBar = resBars[resID] selectedBar = resBars[resID]
end end
overlay.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end overlay.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end

@ -32,8 +32,13 @@ function Quantum.Station.GetRecipes( id )
end end
if SERVER then if SERVER then
Quantum.Server.Station = {} Quantum.Server.Station = {}
Quantum.Server.StationsPos = {}
if( Stations == nil ) then
Stations = {}
Stations.Locations = {}
end
function Quantum.Server.Station.Spawn( stationid, pos, ang ) -- internal function function Quantum.Server.Station.Spawn( stationid, pos, ang ) -- internal function
local ent = ents.Create( "q_crafting_station" ) local ent = ents.Create( "q_crafting_station" )
@ -48,11 +53,16 @@ if SERVER then
end end
function Quantum.Server.Station.Register( stationid, vec, angle ) function Quantum.Server.Station.Register( stationid, vec, angle )
Quantum.Server.StationsPos[#Quantum.Server.StationsPos + 1] = { if( Stations.Locations == nil ) then
Quantum.Error( "Station tbl is nil" )
end
Quantum.Debug( "Registering station '" .. tostring( stationid ) .. "'." )
Stations.Locations[ #Stations.Locations + 1] = {
id = stationid, id = stationid,
pos = vec, pos = vec,
ang = angle ang = angle
} }
print(Stations.Locations[#Stations.Locations])
end end
function Quantum.Server.Station.Create( id, tbl ) function Quantum.Server.Station.Create( id, tbl )
@ -64,7 +74,8 @@ if SERVER then
end end
function Quantum.Server.Station.SpawnAllRegistered() function Quantum.Server.Station.SpawnAllRegistered()
for i, station in pairs( Quantum.Server.StationsPos ) do for i, station in pairs( Stations.Locations ) do
print("spawning")
Quantum.Server.Station.Create( station.id, { pos = station.pos, ang = station.ang } ) Quantum.Server.Station.Create( station.id, { pos = station.pos, ang = station.ang } )
end end
end end
@ -81,12 +92,16 @@ if SERVER then
end end
end end
Quantum.Server.Station.RemoveAll() -- remove all stations on lua refresh function Quantum.Server.Station.UpdateAll()
--Quantum.Server.Station.RemoveAll() -- remove all stations on lua refresh
if( Quantum.Server.StationsSpawned ) then
Quantum.Server.Station.SpawnAllRegistered() -- and create new ones Quantum.Server.Station.SpawnAllRegistered() -- and create new ones
end end
print("##############")
PrintTable( Stations.Locations )
print("##############")
hook.Add( "PlayerInitialSpawn", "Quantum_Init_Stations_Load", function() hook.Add( "PlayerInitialSpawn", "Quantum_Init_Stations_Load", function()
Quantum.Debug( "Spawning registered crafting stations..." ) Quantum.Debug( "Spawning registered crafting stations..." )

Loading…
Cancel
Save