Permalink
Browse files

Even more fixes for tools

* Fixed Delay not updating on Dynamite tool
* Fixed Keys not updating on Dynamite, Emitter, Hoverball, Lamp, Light
and Thruster tools
  • Loading branch information...
1 parent ee1dd98 commit 66ae385323211746c34ea7f8aff4d48016412014 @robotboy655 robotboy655 committed Oct 27, 2013
@@ -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
@@ -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
@@ -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
@@ -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 )
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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()
@@ -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
@@ -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
@@ -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 )
@@ -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
@@ -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 )

0 comments on commit 66ae385

Please sign in to comment.