Added crafting station USE functions

master
AlmTech Software 5 years ago
parent 791463cd61
commit 5af2943167
  1. 8
      entities/entities/q_crafting_station/init.lua
  2. 6
      entities/weapons/quantum_hands/shared.lua
  3. 18
      gamemode/engine/derma/menus/menu_crafting.lua
  4. 9
      gamemode/engine/lib/server/sv_networking.lua
  5. 12
      gamemode/engine/lib/sh_station.lua
  6. 5
      gamemode/settings/sv_crafting_stations_locations.lua

@ -25,9 +25,11 @@ function ENT:Initialize()
end end
function ENT:Use( activator, caller ) function ENT:Use( activator, caller )
if( activator:IsPlayer() ) then -- if( activator:IsPlayer() ) then
-- if( activator.isloaded ) then
end -- Quantum.Net.OpenMenu( activator, "crafting" )
-- end
-- end
end end
function ENT:InitializeStation( stationid, pos, ang ) function ENT:InitializeStation( stationid, pos, ang )

@ -14,7 +14,7 @@ if CLIENT then
SWEP.DrawCrosshair = false SWEP.DrawCrosshair = false
function SWEP:DrawHUD() function SWEP:DrawHUD()
if( self:GetOwner():IsSuperAdmin() ) then if( self:GetOwner():IsSuperAdmin() && !Quantum.Client.IsInMenu ) then
surface.SetTextPos( 10, 10 ) surface.SetTextPos( 10, 10 )
surface.SetTextColor( Color( 200, 200, 200, 200 ) ) surface.SetTextColor( Color( 200, 200, 200, 200 ) )
surface.SetFont( "Default" ) surface.SetFont( "Default" )
@ -31,13 +31,13 @@ if CLIENT then
local cubeMat = Material( "vgui/white" ) local cubeMat = Material( "vgui/white" )
hook.Add( "PostDrawOpaqueRenderables", "Quantum_Client_DeveloperHands_HitPos", function() hook.Add( "PostDrawOpaqueRenderables", "Quantum_Client_DeveloperHands_HitPos", function()
if( LocalPlayer():IsSuperAdmin() ) then if( LocalPlayer():IsSuperAdmin() && !Quantum.Client.IsInMenu ) then
if( LocalPlayer():GetActiveWeapon():GetClass() == "quantum_hands" ) then if( LocalPlayer():GetActiveWeapon():GetClass() == "quantum_hands" ) then
local trace = LocalPlayer():GetEyeTrace() local trace = LocalPlayer():GetEyeTrace()
local angle = trace.HitNormal:Angle() local angle = trace.HitNormal:Angle()
render.SetMaterial( cubeMat ) render.SetMaterial( cubeMat )
render.DrawBox( trace.HitPos, Angle( 0, 0, 0), Vector( 0, 0, 0 ), Vector( 2, 2, 2 ), Color( 255, 255, 255 ) ) render.DrawBox( trace.HitPos, Angle( 0, 0, 0), Vector( 0, 0, 0 ), Vector( 2, 2, 2 ), Color( 255, 25, 25, 100 ) )
render.DrawLine( trace.HitPos, trace.HitPos + 12 * angle:Forward(), Color( 255, 0, 0 ), true ) render.DrawLine( trace.HitPos, trace.HitPos + 12 * angle:Forward(), Color( 255, 0, 0 ), true )
render.DrawLine( trace.HitPos, trace.HitPos + 12 * -angle:Right(), Color( 0, 255, 0 ), true ) render.DrawLine( trace.HitPos, trace.HitPos + 12 * -angle:Right(), Color( 0, 255, 0 ), true )

@ -21,8 +21,12 @@ local itemWidth, itemHeight = 65 * resScale, 65 * resScale
function menu.open( dt ) function menu.open( dt )
local station local station
local stationEnt
if( dt != nil ) then if( dt != nil ) then
station = dt.cont.station if( dt.cont != nil ) then
station = dt.cont.station
stationEnt = dt.cont.stationEnt
end
end end
local items = Quantum.Client.Inventory local items = Quantum.Client.Inventory
@ -34,10 +38,11 @@ function menu.open( dt )
return return
end end
if( !f ) then if( !Quantum.Client.CurStationMenu ) then
Quantum.Client.IsInMenu = true Quantum.Client.IsInMenu = true
local f = vgui.Create( "DFrame" ) local f = vgui.Create( "DFrame" )
Quantum.Client.CurStationMenu = f
f:SetSize( sw, sh ) f:SetSize( sw, sh )
f.w, f.h = f:GetSize() f.w, f.h = f:GetSize()
f:SetTitle( "" ) f:SetTitle( "" )
@ -51,6 +56,7 @@ function menu.open( dt )
end end
function f:OnClose() function f:OnClose()
Quantum.Client.IsInMenu = false Quantum.Client.IsInMenu = false
Quantum.Client.CurStationMenu = nil
Quantum.Client.Cam.Stop() Quantum.Client.Cam.Stop()
end end
@ -65,6 +71,14 @@ function menu.open( dt )
end end
end end
function f:Think()
if( IsValid( stationEnt ) ) then
if( LocalPlayer():GetPos():Distance( stationEnt:GetPos() ) >= 100 ) then -- clientside security sucks but works in this case :P
self:Close()
end
end
end
Quantum.Client.CurMenu = f Quantum.Client.CurMenu = f
end end

@ -25,9 +25,13 @@ local function checkCacheTable( ply, cache_id, dt )
id = cache_id, id = cache_id,
cache = datatable cache = datatable
} }
if( ply.cache[cache_id] ~= nil && table.Count( ply.cache[cache_id] ) == 1 ) then if( ply.cache[cache_id] ~= nil && table.Count( ply.cache[cache_id] ) >= 1 ) then
Quantum.Debug( "Success! Created cache '" .. tostring(cache_id) .. "' for " .. tostring(ply) .. "." ) Quantum.Debug( "Success! Created cache '" .. tostring(cache_id) .. "' for " .. tostring(ply) .. "." )
if( ply.cache[id].count == nil ) then ply.cache[id].count = 1 else ply.cache[id].count = ply.cache[id].count + 1 end -- keep count if( ply.cache[cache_id].count == nil ) then
ply.cache[cache_id].count = 1
else
ply.cache[cache_id].count = ply.cache[cache_id].count + 1 -- keep count
end
else else
Quantum.Error( "Failed. Creation of cache '" .. tostring(cache_id) .. "' for " .. tostring(ply) .. " failed to validate or did not get created." ) Quantum.Error( "Failed. Creation of cache '" .. tostring(cache_id) .. "' for " .. tostring(ply) .. " failed to validate or did not get created." )
ply.cache[cache_id] = nil -- remove the cache since it is "broken" ply.cache[cache_id] = nil -- remove the cache since it is "broken"
@ -41,6 +45,7 @@ local function CacheDatatableMethod( id, datatable, ply )
ply.cache[id] = checkCacheTable( ply, id, datatable ) -- check caching tables etc ply.cache[id] = checkCacheTable( ply, id, datatable ) -- check caching tables etc
Quantum.Debug( "(" .. tostring(ply) .. " | " .. tostring(id) .. ") Removing known data in cache from datatable..." ) Quantum.Debug( "(" .. tostring(ply) .. " | " .. tostring(id) .. ") Removing known data in cache from datatable..." )
if( ply.cache[id] ~= nil ) then if( ply.cache[id] ~= nil ) then
PrintTable(ply.cache[id])
if( ply.cache[id].count > 1 ) then -- dont want to filter out data if this is the first time. if( ply.cache[id].count > 1 ) then -- dont want to filter out data if this is the first time.
for k, v in pairs( datatable ) do -- loop through the datatable for k, v in pairs( datatable ) do -- loop through the datatable
for k2, v2 in pairs( table.GetKeys( ply.cache[id].cache ) ) do -- check each key with each key from the record cache for k2, v2 in pairs( table.GetKeys( ply.cache[id].cache ) ) do -- check each key with each key from the record cache

@ -63,4 +63,16 @@ if SERVER then
end end
Quantum.Server.Station.RemoveAll() -- remove all stations on lua refresh Quantum.Server.Station.RemoveAll() -- remove all stations on lua refresh
hook.Add( "KeyRelease", "Quantum_Station_KeyRelease", function( pl, key )
if( pl.isloaded ) 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 } )
end
end
end
end)
end end

@ -8,4 +8,9 @@
Quantum.Server.Station.Create( "barrel", { Quantum.Server.Station.Create( "barrel", {
pos = Vector( 10, 0, 0 ), pos = Vector( 10, 0, 0 ),
ang = Angle( 0, 0, 0 ) ang = Angle( 0, 0, 0 )
})
Quantum.Server.Station.Create( "barrel", {
pos = Vector( 11972.8359375, 8478.060546875, 8.03125 ),
ang = Angle( 0, -166.42593383789, 0 )
}) })
Loading…
Cancel
Save