From d640b2d56c8f75760873f2bfdad5c5169590d323 Mon Sep 17 00:00:00 2001 From: AlmTech Software Date: Sat, 25 Jan 2020 02:23:50 +0100 Subject: [PATCH] Station mounting fix --- gamemode/engine/derma/menus/menu_crafting.lua | 1 + gamemode/engine/lib/sh_station.lua | 27 ++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/gamemode/engine/derma/menus/menu_crafting.lua b/gamemode/engine/derma/menus/menu_crafting.lua index d2efb37..fd042ff 100644 --- a/gamemode/engine/derma/menus/menu_crafting.lua +++ b/gamemode/engine/derma/menus/menu_crafting.lua @@ -264,6 +264,7 @@ function menu.open( dt ) end overlay.DoClick = function( self ) + surface.PlaySound( "UI/buttonclick.wav" ) selectedBar = resBars[resID] end overlay.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end diff --git a/gamemode/engine/lib/sh_station.lua b/gamemode/engine/lib/sh_station.lua index 8b76e53..877169e 100644 --- a/gamemode/engine/lib/sh_station.lua +++ b/gamemode/engine/lib/sh_station.lua @@ -32,8 +32,13 @@ function Quantum.Station.GetRecipes( id ) end if SERVER then - Quantum.Server.Station = {} - Quantum.Server.StationsPos = {} + Quantum.Server.Station = {} + + + if( Stations == nil ) then + Stations = {} + Stations.Locations = {} + end function Quantum.Server.Station.Spawn( stationid, pos, ang ) -- internal function local ent = ents.Create( "q_crafting_station" ) @@ -48,11 +53,16 @@ if SERVER then end 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, pos = vec, ang = angle } + print(Stations.Locations[#Stations.Locations]) end function Quantum.Server.Station.Create( id, tbl ) @@ -64,7 +74,8 @@ if SERVER then end 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 } ) end end @@ -81,12 +92,16 @@ if SERVER then 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 end + print("##############") + PrintTable( Stations.Locations ) + print("##############") + hook.Add( "PlayerInitialSpawn", "Quantum_Init_Stations_Load", function() Quantum.Debug( "Spawning registered crafting stations..." )