Skip to content

Commit

Permalink
Even more fixes for tools
Browse files Browse the repository at this point in the history
* Fixed Delay not updating on Dynamite tool
* Fixed Keys not updating on Dynamite, Emitter, Hoverball, Lamp, Light
and Thruster tools
  • Loading branch information
robotboy655 committed Oct 27, 2013
1 parent ee1dd98 commit 66ae385
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ function TOOL:LeftClick( trace )
if ( IsValid( trace.Entity ) && trace.Entity:GetClass() == "gmod_dynamite" && trace.Entity:GetPlayer() == ply ) then
trace.Entity:Setup( _damage )
trace.Entity:SetShouldRemove( _remove )
trace.Entity.delay = _delay

numpad.Remove( trace.Entity.NumDown )
trace.Entity.key = _group
trace.Entity.NumDown = numpad.OnDown( ply, _group, "DynamiteBlow", trace.Entity, _delay )
return true
end


if ( !self:GetSWEP():CheckLimit( "dynamite" ) ) then return false end

Expand Down Expand Up @@ -92,7 +96,7 @@ if ( SERVER ) then
}

table.Merge( dynamite:GetTable(), ttable )
numpad.OnDown( pl, key, "DynamiteBlow", dynamite, delay )
dynamite.NumDown = numpad.OnDown( pl, key, "DynamiteBlow", dynamite, delay )

if ( IsValid( pl ) ) then

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ function TOOL:LeftClick( trace, worldweld )
trace.Entity:SetEffect( effect )
trace.Entity:SetDelay( delay )
trace.Entity:SetToggle( toggle )

numpad.Remove( trace.Entity.NumDown )
numpad.Remove( trace.Entity.NumUp )

trace.Entity.NumDown = numpad.OnDown( ply, key, "Emitter_On", trace.Entity )
trace.Entity.NumUp = numpad.OnUp( ply, key, "Emitter_Off", trace.Entity )

trace.Entity.key = key

return true

Expand Down Expand Up @@ -95,8 +103,6 @@ if (SERVER) then
local emitter = ents.Create( "gmod_emitter" )
if ( !emitter:IsValid() ) then return false end



duplicator.DoGeneric( emitter, Data )
emitter:SetEffect( effect )
emitter:SetPlayer( ply )
Expand All @@ -107,11 +113,9 @@ if (SERVER) then
emitter:Spawn()

DoPropSpawnedEffect( emitter )



numpad.OnDown( ply, key, "Emitter_On", emitter )
numpad.OnUp( ply, key, "Emitter_Off", emitter )
emitter.NumDown = numpad.OnDown( ply, key, "Emitter_On", emitter )
emitter.NumUp = numpad.OnUp( ply, key, "Emitter_Off", emitter )

if ( nocollide == true ) then emitter:GetPhysicsObject():EnableCollisions( false ) end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ function TOOL:LeftClick( trace )
trace.Entity:SetAirResistance( resistance )
trace.Entity:SetStrength( strength )

numpad.Remove( trace.Entity.NumDown )
numpad.Remove( trace.Entity.NumUp )
numpad.Remove( trace.Entity.NumBackDown )
numpad.Remove( trace.Entity.NumBackUp )

trace.Entity.NumDown = numpad.OnDown( ply, key_u, "Hoverball_Up", trace.Entity, true )
trace.Entity.NumUp = numpad.OnUp( ply, key_u, "Hoverball_Up", trace.Entity, false )

trace.Entity.NumBackDown = numpad.OnDown( ply, key_d, "Hoverball_Down", trace.Entity, true )
trace.Entity.NumBackUp = numpad.OnUp( ply, key_d, "Hoverball_Down", trace.Entity, false )

trace.Entity.key_u = key_u
trace.Entity.key_d = key_d
trace.Entity.speed = speed
trace.Entity.strength = strength
trace.Entity.resistance = resistance
Expand Down Expand Up @@ -114,11 +127,11 @@ if (SERVER) then
ball:SetPlayer( ply )
end

numpad.OnDown( ply, key_u, "Hoverball_Up", ball, true )
numpad.OnUp( ply, key_u, "Hoverball_Up", ball, false )
ball.NumDown = numpad.OnDown( ply, key_u, "Hoverball_Up", ball, true )
ball.NumUp = numpad.OnUp( ply, key_u, "Hoverball_Up", ball, false )

numpad.OnDown( ply, key_d, "Hoverball_Down", ball, true )
numpad.OnUp( ply, key_d, "Hoverball_Down", ball, false )
ball.NumBackDown = numpad.OnDown( ply, key_d, "Hoverball_Down", ball, true )
ball.NumBackUp = numpad.OnUp( ply, key_d, "Hoverball_Down", ball, false )

if ( nocollide == true ) then ball:GetPhysicsObject():EnableCollisions( false ) end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ function TOOL:LeftClick( trace )
trace.Entity:SetToggle( !toggle )
trace.Entity:UpdateLight()

numpad.Remove( trace.Entity.NumDown )
numpad.Remove( trace.Entity.NumUp )

trace.Entity.NumDown = numpad.OnDown( ply, key, "LampToggle", trace.Entity, 1 )
trace.Entity.NumUp = numpad.OnUp( ply, key, "LampToggle", trace.Entity, 0 )

-- For duplicator
trace.Entity.Texture = texture
trace.Entity.fov = fov
trace.Entity.distance = distance
trace.Entity.r = r trace.Entity.g = g trace.Entity.b = b
trace.Entity.brightness = bright

trace.Entity.KeyDown = key

return true

end
Expand Down Expand Up @@ -130,8 +137,8 @@ if ( SERVER ) then
lamp.b = b
lamp.brightness = brightness

numpad.OnDown( pl, KeyDown, "LampToggle", lamp, 1 )
numpad.OnUp( pl, KeyDown, "LampToggle", lamp, 0 )
lamp.NumDown = numpad.OnDown( pl, KeyDown, "LampToggle", lamp, 1 )
lamp.NumUp = numpad.OnUp( pl, KeyDown, "LampToggle", lamp, 0 )

return lamp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ function TOOL:LeftClick( trace, attach )
if ( IsValid( trace.Entity ) &&
trace.Entity:GetClass() == "gmod_light" &&
trace.Entity:GetPlayer() == ply ) then



trace.Entity:SetColor( Color( r, g, b, 255 ) )
trace.Entity.r = r
trace.Entity.g = g
Expand All @@ -60,6 +59,14 @@ function TOOL:LeftClick( trace, attach )
trace.Entity:SetLightSize( size )
trace.Entity:SetToggle( !toggle )

trace.Entity.KeyDown = key

numpad.Remove( trace.Entity.NumDown )
numpad.Remove( trace.Entity.NumUp )

trace.Entity.NumDown = numpad.OnDown( ply, key, "LightToggle", trace.Entity, 1 )
trace.Entity.NumUp = numpad.OnUp( ply, key, "LightToggle", trace.Entity, 0 )

return true

end
Expand Down Expand Up @@ -249,8 +256,8 @@ if ( SERVER ) then
lamp.KeyDown = KeyDown
lamp.on = on

numpad.OnDown( pl, KeyDown, "LightToggle", lamp, 1 )
numpad.OnUp( pl, KeyDown, "LightToggle", lamp, 0 )
lamp.NumDown = numpad.OnDown( pl, KeyDown, "LightToggle", lamp, 1 )
lamp.NumUp = numpad.OnUp( pl, KeyDown, "LightToggle", lamp, 0 )

return lamp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function TOOL:LeftClick( trace )
-- If there's no physics object then we can't constraint it!
if ( SERVER && !util.IsValidPhysicsObject( trace.Entity, trace.PhysicsBone ) ) then return false end

if (CLIENT) then return true end
if ( CLIENT ) then return true end

local ply = self:GetOwner()

Expand All @@ -45,7 +45,20 @@ function TOOL:LeftClick( trace )
trace.Entity:SetToggle( toggle == 1 )
trace.Entity.ActivateOnDamage = ( damageable == 1 )
trace.Entity:SetSound( soundname )

numpad.Remove( trace.Entity.NumDown )
numpad.Remove( trace.Entity.NumUp )
numpad.Remove( trace.Entity.NumBackDown )
numpad.Remove( trace.Entity.NumBackUp )

trace.Entity.NumDown = numpad.OnDown( ply, key, "Thruster_On", trace.Entity, 1 )
trace.Entity.NumUp = numpad.OnUp( ply, key, "Thruster_Off", trace.Entity, 1 )

trace.Entity.NumBackDown = numpad.OnDown( ply, key_bk, "Thruster_On", trace.Entity, -1 )
trace.Entity.NumBackUp = numpad.OnUp( ply, key_bk, "Thruster_Off", trace.Entity, -1 )

trace.Entity.key = key
trace.Entity.key_bk = key_bk
trace.Entity.force = force
trace.Entity.toggle = toggle
trace.Entity.effect = effect
Expand All @@ -56,8 +69,8 @@ function TOOL:LeftClick( trace )

if ( !self:GetSWEP():CheckLimit( "thrusters" ) ) then return false end

if (!util.IsValidModel(model)) then return false end
if (!util.IsValidProp(model)) then return false end -- Allow ragdolls to be used?
if ( !util.IsValidModel( model ) ) then return false end
if ( !util.IsValidProp( model ) ) then return false end -- Allow ragdolls to be used?

local Ang = trace.HitNormal:Angle()
Ang.pitch = Ang.pitch + 90
Expand Down Expand Up @@ -107,7 +120,7 @@ if (SERVER) then
end

local thruster = ents.Create( "gmod_thruster" )
if (!thruster:IsValid()) then return false end
if ( !thruster:IsValid() ) then return false end
thruster:SetModel( Model )

thruster:SetAngles( Ang )
Expand All @@ -121,11 +134,11 @@ if (SERVER) then
thruster:SetPlayer( pl )
thruster:SetSound( soundname )

numpad.OnDown( pl, key, "Thruster_On", thruster, 1 )
numpad.OnUp( pl, key, "Thruster_Off", thruster, 1 )
thruster.NumDown = numpad.OnDown( pl, key, "Thruster_On", thruster, 1 )
thruster.NumUp = numpad.OnUp( pl, key, "Thruster_Off", thruster, 1 )

numpad.OnDown( pl, key_bck, "Thruster_On", thruster, -1 )
numpad.OnUp( pl, key_bck, "Thruster_Off", thruster, -1 )
thruster.NumBackDown = numpad.OnDown( pl, key_bck, "Thruster_On", thruster, -1 )
thruster.NumBackUp = numpad.OnUp( pl, key_bck, "Thruster_Off", thruster, -1 )

if ( nocollide == true && IsValid( thruster:GetPhysicsObject() ) ) then thruster:GetPhysicsObject():EnableCollisions( false ) end

Expand All @@ -139,9 +152,9 @@ if (SERVER) then
nocollide = nocollide,
damageable = damageable,
soundname = soundname
}
}

table.Merge(thruster:GetTable(), ttable )
table.Merge( thruster:GetTable(), ttable )

if ( IsValid( pl ) ) then
pl:AddCount( "thrusters", thruster )
Expand Down

0 comments on commit 66ae385

Please sign in to comment.