Permalink
Browse files

Clean up the rest of the tools

* Almost full consistency between tools
* Removed all semicolons, trailing whitespace, unnecessary whitespace,
unnecessary code
* Tweaked default values for some of the tools, tweaked limits in
context panels for some of the tools
* Added right click option for lamp tool to copy settings of another
lamp
* Deprecated settings/controls/* stuff, noone uses it, serves no
benefit.
  • Loading branch information...
1 parent 2f1fd73 commit 05d042939f462320277422563568860896a39143 @robotboy655 robotboy655 committed May 29, 2014
Showing with 1,317 additions and 1,936 deletions.
  1. +27 −27 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/axis.lua
  2. +47 −81 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/balloon.lua
  3. +9 −9 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/ballsocket.lua
  4. +58 −82 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/button.lua
  5. +29 −24 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/camera.lua
  6. +52 −10 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/colour.lua
  7. +21 −32 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/creator.lua
  8. +16 −24 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/duplicator.lua
  9. +39 −46 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/dynamite.lua
  10. +7 −7 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/editentity.lua
  11. +15 −15 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/elastic.lua
  12. +45 −86 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/emitter.lua
  13. +3 −4 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/example.lua
  14. +6 −3 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/eyeposer.lua
  15. +6 −6 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/faceposer.lua
  16. +2 −2 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/finger.lua
  17. +39 −46 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/hoverball.lua
  18. +39 −38 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/hydraulic.lua
  19. +2 −2 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/inflator.lua
  20. +80 −83 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/lamp.lua
  21. +17 −21 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/leafblower.lua
  22. +95 −147 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/light.lua
  23. +5 −9 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/material.lua
  24. +21 −21 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/motor.lua
  25. +36 −36 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/muscle.lua
  26. +15 −17 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/nocollide.lua
  27. +18 −19 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/paint.lua
  28. +37 −12 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/physprop.lua
  29. +10 −10 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/pulley.lua
  30. +19 −29 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/remover.lua
  31. +28 −28 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/rope.lua
  32. +21 −21 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/slider.lua
  33. +87 −133 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/thruster.lua
  34. +53 −95 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/trails.lua
  35. +7 −7 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua
  36. +253 −299 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/wheel.lua
  37. +34 −34 garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/winch.lua
  38. +19 −79 garrysmod/gamemodes/sandbox/gamemode/spawnmenu/controlpanel.lua
  39. +0 −22 garrysmod/settings/controls/camera.txt
  40. +0 −166 garrysmod/settings/controls/colour.txt
  41. +0 −104 garrysmod/settings/controls/physprop.txt
@@ -1,6 +1,6 @@
-TOOL.Category = "Constraints"
-TOOL.Name = "#tool.axis.name"
+TOOL.Category = "Constraints"
+TOOL.Name = "#tool.axis.name"
TOOL.ClientConVar[ "forcelimit" ] = 0
TOOL.ClientConVar[ "torquelimit" ] = 0
@@ -43,15 +43,15 @@ function TOOL:LeftClick( trace )
end
-- Get client's CVars
- local nocollide = self:GetClientNumber( "nocollide", 0 )
- local forcelimit = self:GetClientNumber( "forcelimit", 0 )
- local torquelimit = self:GetClientNumber( "torquelimit", 0 )
- local friction = self:GetClientNumber( "hingefriction", 0 )
-
- local Ent1, Ent2 = self:GetEnt( 1 ), self:GetEnt( 2 )
- local Bone1, Bone2 = self:GetBone( 1 ), self:GetBone( 2 )
- local Norm1, Norm2 = self:GetNormal( 1 ), self:GetNormal( 2 )
- local LPos1, LPos2 = self:GetLocalPos( 1 ), self:GetLocalPos( 2 )
+ local nocollide = self:GetClientNumber( "nocollide", 0 )
+ local forcelimit = self:GetClientNumber( "forcelimit", 0 )
+ local torquelimit = self:GetClientNumber( "torquelimit", 0 )
+ local friction = self:GetClientNumber( "hingefriction", 0 )
+
+ local Ent1, Ent2 = self:GetEnt( 1 ), self:GetEnt( 2 )
+ local Bone1, Bone2 = self:GetBone( 1 ), self:GetBone( 2 )
+ local Norm1, Norm2 = self:GetNormal( 1 ), self:GetNormal( 2 )
+ local LPos1, LPos2 = self:GetLocalPos( 1 ), self:GetLocalPos( 2 )
local Phys1 = self:GetPhys( 1 )
local WPos2 = self:GetPos( 2 )
@@ -77,8 +77,8 @@ function TOOL:LeftClick( trace )
local constraint = constraint.Axis( Ent1, Ent2, Bone1, Bone2, LPos1, LPos2, forcelimit, torquelimit, friction, nocollide )
undo.Create( "Axis" )
- undo.AddEntity( constraint )
- undo.SetPlayer( self:GetOwner() )
+ undo.AddEntity( constraint )
+ undo.SetPlayer( self:GetOwner() )
undo.Finish()
self:GetOwner():AddCleanup( "constraints", constraint )
@@ -125,15 +125,15 @@ function TOOL:RightClick( trace )
end
-- Get client's CVars
- local nocollide = self:GetClientNumber( "nocollide", 0 )
- local forcelimit = self:GetClientNumber( "forcelimit", 0 )
- local torquelimit = self:GetClientNumber( "torquelimit", 0 )
- local friction = self:GetClientNumber( "hingefriction", 0 )
-
- local Ent1, Ent2 = self:GetEnt( 1 ), self:GetEnt( 2 )
- local Bone1, Bone2 = self:GetBone( 1 ), self:GetBone( 2 )
- local Norm1, Norm2 = self:GetNormal( 1 ), self:GetNormal( 2 )
- local LPos1, LPos2 = self:GetLocalPos( 1 ), self:GetLocalPos( 2 )
+ local nocollide = self:GetClientNumber( "nocollide", 0 )
+ local forcelimit = self:GetClientNumber( "forcelimit", 0 )
+ local torquelimit = self:GetClientNumber( "torquelimit", 0 )
+ local friction = self:GetClientNumber( "hingefriction", 0 )
+
+ local Ent1, Ent2 = self:GetEnt( 1 ), self:GetEnt( 2 )
+ local Bone1, Bone2 = self:GetBone( 1 ), self:GetBone( 2 )
+ local Norm1, Norm2 = self:GetNormal( 1 ), self:GetNormal( 2 )
+ local LPos1, LPos2 = self:GetLocalPos( 1 ), self:GetLocalPos( 2 )
local Phys1 = self:GetPhys( 1 )
local WPos2 = self:GetPos( 2 )
@@ -153,8 +153,8 @@ function TOOL:RightClick( trace )
local constraint = constraint.Axis( Ent1, Ent2, Bone1, Bone2, LPos1, LPos2, forcelimit, torquelimit, friction, nocollide )
undo.Create( "Axis" )
- undo.AddEntity( constraint )
- undo.SetPlayer( self:GetOwner() )
+ undo.AddEntity( constraint )
+ undo.SetPlayer( self:GetOwner() )
undo.Finish()
self:GetOwner():AddCleanup( "constraints", constraint )
@@ -204,9 +204,9 @@ function TOOL.BuildCPanel( CPanel )
CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "axis", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
- CPanel:AddControl( "Slider", { Label = "#tool.forcelimit", Command = "axis_forcelimit", Type = "Float", Min = "0", Max = "50000", Help = true } )
- CPanel:AddControl( "Slider", { Label = "#tool.torquelimit", Command = "axis_torquelimit", Type = "Float", Min = "0", Max = "50000", Help = true } )
- CPanel:AddControl( "Slider", { Label = "#tool.hingefriction", Command = "axis_hingefriction", Type = "Float", Min = "0", Max = "200", Help = true } )
+ CPanel:AddControl( "Slider", { Label = "#tool.forcelimit", Command = "axis_forcelimit", Type = "Float", Min = 0, Max = 50000, Help = true } )
+ CPanel:AddControl( "Slider", { Label = "#tool.torquelimit", Command = "axis_torquelimit", Type = "Float", Min = 0, Max = 50000, Help = true } )
+ CPanel:AddControl( "Slider", { Label = "#tool.hingefriction", Command = "axis_hingefriction", Type = "Float", Min = 0, Max = 200, Help = true } )
CPanel:AddControl( "CheckBox", { Label = "#tool.nocollide", Command = "axis_nocollide" } )
end
@@ -1,13 +1,13 @@
-TOOL.Category = "Construction"
-TOOL.Name = "#tool.balloon.name"
+TOOL.Category = "Construction"
+TOOL.Name = "#tool.balloon.name"
-TOOL.ClientConVar[ "ropelength" ] = "64"
-TOOL.ClientConVar[ "force" ] = "500"
-TOOL.ClientConVar[ "r" ] = "255"
-TOOL.ClientConVar[ "g" ] = "255"
-TOOL.ClientConVar[ "b" ] = "0"
-TOOL.ClientConVar[ "model" ] = "models/MaxOfS2D/balloon_classic.mdl"
+TOOL.ClientConVar[ "ropelength" ] = "64"
+TOOL.ClientConVar[ "force" ] = "500"
+TOOL.ClientConVar[ "r" ] = "255"
+TOOL.ClientConVar[ "g" ] = "255"
+TOOL.ClientConVar[ "b" ] = "0"
+TOOL.ClientConVar[ "model" ] = "models/maxofs2d/balloon_classic.mdl"
cleanup.Register( "balloons" )
@@ -19,25 +19,25 @@ function TOOL:LeftClick( trace, attach )
--
-- Right click calls this with attach = false
--
- if ( attach == nil ) then
- attach = true
+ if ( attach == nil ) then
+ attach = true
end
-- If there's no physics object then we can't constraint it!
- if ( SERVER && attach && !util.IsValidPhysicsObject( trace.Entity, trace.PhysicsBone ) ) then
- return false
+ if ( SERVER && attach && !util.IsValidPhysicsObject( trace.Entity, trace.PhysicsBone ) ) then
+ return false
end
- local ply = self:GetOwner()
- local length = self:GetClientNumber( "ropelength", 64 )
- local material = "cable/rope"
- local force = self:GetClientNumber( "force", 500 )
- local r = self:GetClientNumber( "r", 255 )
- local g = self:GetClientNumber( "g", 0 )
- local b = self:GetClientNumber( "b", 0 )
- local model = self:GetClientInfo( "model" )
+ local ply = self:GetOwner()
+ local material = "cable/rope"
+ local r = self:GetClientNumber( "r", 255 )
+ local g = self:GetClientNumber( "g", 0 )
+ local b = self:GetClientNumber( "b", 0 )
+ local model = self:GetClientInfo( "model" )
+ local force = self:GetClientNumber( "force", 500 )
+ local length = self:GetClientNumber( "ropelength", 64 )
- local modeltable = list.Get( "BalloonModels" )[ model ]
+ local modeltable = list.Get( "BalloonModels" )[ model ]
--
-- Model is a table index on BalloonModels
@@ -84,7 +84,7 @@ function TOOL:LeftClick( trace, attach )
balloon:SetPos( Pos )
undo.Create( "Balloon" )
- undo.AddEntity( balloon )
+ undo.AddEntity( balloon )
if ( attach ) then
@@ -110,7 +110,7 @@ function TOOL:LeftClick( trace, attach )
end
- undo.SetPlayer( ply )
+ undo.SetPlayer( ply )
undo.Finish()
ply:AddCleanup( "balloons", balloon )
@@ -133,7 +133,7 @@ if ( SERVER ) then
local balloon = ents.Create( "gmod_balloon" )
- if ( !balloon:IsValid() ) then return end
+ if ( !IsValid( balloon ) ) then return end
duplicator.DoGeneric( balloon, Data )
@@ -170,7 +170,7 @@ function TOOL:UpdateGhostBalloon( ent, ply )
if ( !IsValid( ent ) ) then return end
- local tr = util.GetPlayerTrace( ply )
+ local tr = util.GetPlayerTrace( ply )
local trace = util.TraceLine( tr )
if ( !trace.Hit ) then return end
@@ -212,64 +212,30 @@ function TOOL:Think()
end
+local ConVarsDefault = TOOL:BuildConVarList()
+
function TOOL.BuildCPanel( CPanel )
- CPanel:AddControl( "Header", { Description = "#tool.balloon.help" } )
+ CPanel:AddControl( "Header", { Description = "#tool.balloon.help" } )
- CPanel:AddControl( "ComboBox", { Label = "#tool.presets",
- MenuButton = 1,
- Folder = "balloon",
- CVars = { "balloon_ropelength", "balloon_force", "balloon_r", "balloon_g", "balloon_b", "balloon_skin" } } )
-
- CPanel:AddControl( "Slider", { Label = "#tool.balloon.ropelength", Type = "Float", Command = "balloon_ropelength", Min = "5", Max = "1000" } )
- CPanel:AddControl( "Slider", { Label = "#tool.balloon.force", Type = "Float", Command = "balloon_force", Min = "-1000", Max = "2000", Help = true } )
- CPanel:AddControl( "Color", { Label = "#tool.balloon.color", Red = "balloon_r", Green = "balloon_g", Blue = "balloon_b", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1" } )
-
- CPanel:AddControl( "PropSelect", { Label = "#tool.balloon.model",
- ConVar = "balloon_model",
- Height = 4,
- ModelsTable = list.Get( "BalloonModels" ) } )
-
+ CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "balloon", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
+
+ CPanel:AddControl( "Slider", { Label = "#tool.balloon.ropelength", Type = "Float", Command = "balloon_ropelength", Min = 5, Max = 1000 } )
+ CPanel:AddControl( "Slider", { Label = "#tool.balloon.force", Type = "Float", Command = "balloon_force", Min = -1000, Max = 2000, Help = true } )
+ CPanel:AddControl( "Color", { Label = "#tool.balloon.color", Red = "balloon_r", Green = "balloon_g", Blue = "balloon_b" } )
+
+ CPanel:AddControl( "PropSelect", { Label = "#tool.balloon.model", ConVar = "balloon_model", Height = 4, ModelsTable = list.Get( "BalloonModels" ) } )
+
end
-list.Set( "BalloonModels", "normal", {
- model = "models/MaxOfS2D/balloon_classic.mdl",
- skin = 0,
-})
-
-list.Set( "BalloonModels", "normal_skin1", {
- model = "models/MaxOfS2D/balloon_classic.mdl",
- skin = 1,
-})
-
-list.Set( "BalloonModels", "normal_skin2", {
- model = "models/MaxOfS2D/balloon_classic.mdl",
- skin = 2,
-})
-
-list.Set( "BalloonModels", "normal_skin3", {
- model = "models/MaxOfS2D/balloon_classic.mdl",
- skin = 3,
-})
-
-list.Set( "BalloonModels", "gman", {
- model = "models/MaxOfS2D/balloon_gman.mdl",
- nocolor = true,
-})
-
-list.Set( "BalloonModels", "mossman", {
- model = "models/MaxOfS2D/balloon_mossman.mdl",
- nocolor = true,
-})
-
-list.Set( "BalloonModels", "dog", {
- model = "models/balloons/balloon_dog.mdl"
-})
-
-list.Set( "BalloonModels", "heart", {
- model = "models/balloons/balloon_classicheart.mdl"
-})
-
-list.Set( "BalloonModels", "star", {
- model = "models/balloons/balloon_star.mdl"
-})
+list.Set( "BalloonModels", "normal", { model = "models/maxofs2d/balloon_classic.mdl", skin = 0 } )
+list.Set( "BalloonModels", "normal_skin1", { model = "models/maxofs2d/balloon_classic.mdl", skin = 1 } )
+list.Set( "BalloonModels", "normal_skin2", { model = "models/maxofs2d/balloon_classic.mdl", skin = 2 } )
+list.Set( "BalloonModels", "normal_skin3", { model = "models/maxofs2d/balloon_classic.mdl", skin = 3 } )
+
+list.Set( "BalloonModels", "gman", { model = "models/maxofs2d/balloon_gman.mdl", nocolor = true } )
+list.Set( "BalloonModels", "mossman", { model = "models/maxofs2d/balloon_mossman.mdl", nocolor = true } )
+
+list.Set( "BalloonModels", "dog", { model = "models/balloons/balloon_dog.mdl" } )
+list.Set( "BalloonModels", "heart", { model = "models/balloons/balloon_classicheart.mdl" } )
+list.Set( "BalloonModels", "star", { model = "models/balloons/balloon_star.mdl" } )
@@ -1,6 +1,6 @@
-TOOL.Category = "Constraints"
-TOOL.Name = "#tool.ballsocket.name"
+TOOL.Category = "Constraints"
+TOOL.Name = "#tool.ballsocket.name"
TOOL.ClientConVar[ "forcelimit" ] = "0"
TOOL.ClientConVar[ "torquelimit" ] = "0"
@@ -27,9 +27,9 @@ function TOOL:LeftClick( trace )
end
-- Get client's CVars
- local nocollide = self:GetClientNumber( "nocollide", 0 )
- local forcelimit = self:GetClientNumber( "forcelimit", 0 )
- local torquelimit = self:GetClientNumber( "torquelimit", 0 )
+ local nocollide = self:GetClientNumber( "nocollide", 0 )
+ local forcelimit = self:GetClientNumber( "forcelimit", 0 )
+ local torquelimit = self:GetClientNumber( "torquelimit", 0 )
-- Get information we're about to use
local Ent1, Ent2 = self:GetEnt( 1 ), self:GetEnt( 2 )
@@ -39,8 +39,8 @@ function TOOL:LeftClick( trace )
local constraint = constraint.Ballsocket( Ent1, Ent2, Bone1, Bone2, LPos, forcelimit, torquelimit, nocollide )
undo.Create( "BallSocket" )
- undo.AddEntity( constraint )
- undo.SetPlayer( self:GetOwner() )
+ undo.AddEntity( constraint )
+ undo.SetPlayer( self:GetOwner() )
undo.Finish()
self:GetOwner():AddCleanup( "constraints", constraint )
@@ -81,8 +81,8 @@ function TOOL.BuildCPanel( CPanel )
CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "ballsocket", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
- CPanel:AddControl( "Slider", { Label = "#tool.forcelimit", Command = "ballsocket_forcelimit", Type = "Float", Min = "0", Max = "50000", Help = true } )
- CPanel:AddControl( "Slider", { Label = "#tool.torquelimit", Command = "ballsocket_torquelimit", Type = "Float", Min = "0", Max = "50000", Help = true } )
+ CPanel:AddControl( "Slider", { Label = "#tool.forcelimit", Command = "ballsocket_forcelimit", Type = "Float", Min = 0, Max = 50000, Help = true } )
+ CPanel:AddControl( "Slider", { Label = "#tool.torquelimit", Command = "ballsocket_torquelimit", Type = "Float", Min = 0, Max = 50000, Help = true } )
CPanel:AddControl( "CheckBox", { Label = "#tool.nocollide", Command = "ballsocket_nocollide", Help = true } )
end
Oops, something went wrong.

0 comments on commit 05d0429

Please sign in to comment.