[changed] moved some I/O tools to single file (adv input, adv pod, button)
[changed] wire material select (works better in gmod 2007) [fixed] error with gate tool in gmod 2007 [changed] wire version output [changed] moved sound emitter sounds defines to modplug file
This commit is contained in:
parent
16ded1c921
commit
2d55b88a90
@ -14,7 +14,7 @@ for _,filename in pairs( file.Find("WireModelPacks/*.txt") ) do
|
|||||||
list.Set( "Wire_"..cat.."_Models", entry.model, {} )
|
list.Set( "Wire_"..cat.."_Models", entry.model, {} )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Msg("= Loaded Pack : filename =\n")
|
Msg("= Loaded Pack : "..filename.." =\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -23,12 +23,39 @@ end
|
|||||||
// Add some more options to the stools
|
// Add some more options to the stools
|
||||||
//
|
//
|
||||||
|
|
||||||
|
//screens
|
||||||
list.Set( "WireScreenModels", "models/props_lab/monitor01b.mdl", {} )
|
list.Set( "WireScreenModels", "models/props_lab/monitor01b.mdl", {} )
|
||||||
list.Set( "WireScreenModels", "models/props/cs_office/TV_plasma.mdl", {} )
|
list.Set( "WireScreenModels", "models/props/cs_office/TV_plasma.mdl", {} )
|
||||||
list.Set( "WireScreenModels", "models/props/cs_office/computer_monitor.mdl", {} )
|
list.Set( "WireScreenModels", "models/props/cs_office/computer_monitor.mdl", {} )
|
||||||
list.Set( "WireScreenModels", "models/kobilica/wiremonitorbig.mdl", {} )
|
list.Set( "WireScreenModels", "models/kobilica/wiremonitorbig.mdl", {} )
|
||||||
list.Set( "WireScreenModels", "models/kobilica/wiremonitorsmall.mdl", {} )
|
list.Set( "WireScreenModels", "models/kobilica/wiremonitorsmall.mdl", {} )
|
||||||
|
|
||||||
|
//sounds
|
||||||
|
local WireSounds = {
|
||||||
|
Warning = "common/warning.wav",
|
||||||
|
Talk = "common/talk.wav",
|
||||||
|
Button = "buttons/button15.wav",
|
||||||
|
Denied = "buttons/weapon_cant_buy.wav",
|
||||||
|
Zap = "ambient/energy/zap2.wav",
|
||||||
|
["Oh No"] = "vo/npc/male01/ohno.wav",
|
||||||
|
Yeah = "vo/npc/male01/yeah02.wav",
|
||||||
|
["apc alarm"] = "ambient/alarms/apc_alarm_loop1.wav",
|
||||||
|
["Coast Siren"] = "coast.siren_citizen",
|
||||||
|
["Bunker Siren"] = "coast.bunker_siren1",
|
||||||
|
["Alarm Bell"] = "d1_canals.Floodgate_AlarmBellLoop",
|
||||||
|
["Engine Start"] = "ATV_engine_start",
|
||||||
|
["Engine Stop"] = "ATV_engine_stop",
|
||||||
|
["Zombie Breathe"] = "NPC_PoisonZombie.Moan1",
|
||||||
|
["Idle Zombies"] = "Zombie.Idle",
|
||||||
|
["Turret Alert"] = "NPC_FloorTurret.Alert",
|
||||||
|
["Helicopter Rotor"] = "NPC_CombineGunship.RotorSound",
|
||||||
|
Heartbeat = "k_lab.teleport_heartbeat",
|
||||||
|
Breathing = "k_lab.teleport_breathing",
|
||||||
|
}
|
||||||
|
for k,v in pairs(WireSounds) do
|
||||||
|
list.Set("WireSounds",k,{wire_soundemitter_sound=v});
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
//some extra wheels that wired wheels have
|
//some extra wheels that wired wheels have
|
||||||
list.Set( "WheelModels", "models/props_wasteland/wheel01a.mdl", { wheel_rx = 90, wheel_ry = 0, wheel_rz = 90} )
|
list.Set( "WheelModels", "models/props_wasteland/wheel01a.mdl", { wheel_rx = 90, wheel_ry = 0, wheel_rz = 90} )
|
||||||
|
@ -7,16 +7,16 @@ WireAddon = 1
|
|||||||
|
|
||||||
if file.Exists("../lua/wire/.svn/entries") then
|
if file.Exists("../lua/wire/.svn/entries") then
|
||||||
WireVersion = tonumber( string.Explode( "\n", file.Read( "../lua/wire/.svn/entries" ) )[ 4 ] ) --get svn revision, stolen from ULX
|
WireVersion = tonumber( string.Explode( "\n", file.Read( "../lua/wire/.svn/entries" ) )[ 4 ] ) --get svn revision, stolen from ULX
|
||||||
Msg("===== Wire SVN revision: ",WireVersion," ====\n")
|
else
|
||||||
local function initplayer(ply)
|
WireVersion = 552 --change this value to the current revision number when making a general release
|
||||||
|
end
|
||||||
|
local function initplayer(ply)
|
||||||
umsg.Start( "wire_initplayer", ply )
|
umsg.Start( "wire_initplayer", ply )
|
||||||
umsg.Short( WireVersion or 0 )
|
umsg.Short( WireVersion or 0 )
|
||||||
umsg.End()
|
umsg.End()
|
||||||
end
|
|
||||||
hook.Add( "PlayerInitialSpawn", "WirePlayerInitSpawn", initplayer )
|
|
||||||
else
|
|
||||||
WireVersion = 552 --change this value to the current revision number when making a general relase
|
|
||||||
end
|
end
|
||||||
|
hook.Add( "PlayerInitialSpawn", "WirePlayerInitSpawn", initplayer )
|
||||||
|
|
||||||
|
|
||||||
WireLib.Version = WireVersion
|
WireLib.Version = WireVersion
|
||||||
|
|
||||||
|
@ -96,3 +96,44 @@ local function Off( pl, ent, mul )
|
|||||||
end
|
end
|
||||||
numpad.Register( "WireAdvInput_On",On)
|
numpad.Register( "WireAdvInput_On",On)
|
||||||
numpad.Register( "WireAdvInput_Off",Off)
|
numpad.Register( "WireAdvInput_Off",Off)
|
||||||
|
|
||||||
|
|
||||||
|
function MakeWireAdvInput( pl, Pos, Ang, keymore, keyless, toggle, value_min, value_max, value_start, speed, Vel, aVel, frozen )
|
||||||
|
|
||||||
|
if ( !pl:CheckLimit( "wire_adv_inputs" ) ) then return false end
|
||||||
|
|
||||||
|
local wire_adv_input = ents.Create( "gmod_wire_adv_input" )
|
||||||
|
if (!wire_adv_input:IsValid()) then return false end
|
||||||
|
|
||||||
|
wire_adv_input:SetAngles( Ang )
|
||||||
|
wire_adv_input:SetPos( Pos )
|
||||||
|
wire_adv_input:SetModel( Model("models/jaanus/wiretool/wiretool_input.mdl") )
|
||||||
|
wire_adv_input:Spawn()
|
||||||
|
|
||||||
|
wire_adv_input:Setup( keymore, keyless, toggle, value_min, value_max, value_start, speed )
|
||||||
|
wire_adv_input:SetPlayer( pl )
|
||||||
|
|
||||||
|
numpad.OnDown( pl, keymore, "WireAdvInput_On", wire_adv_input, 1 )
|
||||||
|
numpad.OnUp( pl, keymore, "WireAdvInput_Off", wire_adv_input, 1 )
|
||||||
|
|
||||||
|
numpad.OnDown( pl, keyless, "WireAdvInput_On", wire_adv_input, -1 )
|
||||||
|
numpad.OnUp( pl, keyless, "WireAdvInput_Off", wire_adv_input, -1 )
|
||||||
|
|
||||||
|
local ttable = {
|
||||||
|
keymore = keymore,
|
||||||
|
keyless = keyless,
|
||||||
|
toggle = toggle,
|
||||||
|
value_min = value_min,
|
||||||
|
value_max = value_max,
|
||||||
|
value_start = value_start,
|
||||||
|
speed = speed,
|
||||||
|
pl = pl
|
||||||
|
}
|
||||||
|
table.Merge(wire_adv_input:GetTable(), ttable )
|
||||||
|
|
||||||
|
pl:AddCount( "wire_adv_inputs", wire_adv_input )
|
||||||
|
|
||||||
|
return wire_adv_input
|
||||||
|
end
|
||||||
|
|
||||||
|
duplicator.RegisterEntityClass("gmod_wire_adv_input", MakeWireAdvInput, "Pos", "Ang", "keymore", "keyless", "toggle", "value_min", "value_max", "value_start", "speed", "Vel", "aVel", "frozen")
|
||||||
|
@ -230,3 +230,22 @@ function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function MakeWireAdvPod(pl, Pos, Ang)
|
||||||
|
if not pl:CheckLimit("wire_pods") then return false end
|
||||||
|
|
||||||
|
local wire_pod = ents.Create("gmod_wire_adv_pod")
|
||||||
|
if not wire_pod:IsValid() then return false end
|
||||||
|
|
||||||
|
wire_pod:SetAngles(Ang)
|
||||||
|
wire_pod:SetPos(Pos)
|
||||||
|
wire_pod:Spawn()
|
||||||
|
wire_pod:SetPlayer(pl)
|
||||||
|
wire_pod.pl = pl
|
||||||
|
|
||||||
|
pl:AddCount("wire_pods", wire_pod)
|
||||||
|
|
||||||
|
return wire_pod
|
||||||
|
end
|
||||||
|
duplicator.RegisterEntityClass("gmod_wire_adv_pod", MakeWireAdvPod, "Pos", "Ang", "Vel", "aVel", "frozen")
|
||||||
|
@ -78,3 +78,33 @@ end
|
|||||||
function ENT:ShowOutput(value)
|
function ENT:ShowOutput(value)
|
||||||
self:SetOverlayText( "(" .. self.ValueOff .. " - " .. self.ValueOn .. ") = " .. value )
|
self:SetOverlayText( "(" .. self.ValueOff .. " - " .. self.ValueOn .. ") = " .. value )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function MakeWireButton( pl, Model, Pos, Ang, toggle, value_off, value_on, description, Vel, aVel, frozen )
|
||||||
|
if ( !pl:CheckLimit( "wire_buttons" ) ) then return false end
|
||||||
|
|
||||||
|
local wire_button = ents.Create( "gmod_wire_button" )
|
||||||
|
if (!wire_button:IsValid()) then return false end
|
||||||
|
|
||||||
|
wire_button:SetModel( Model )
|
||||||
|
wire_button:SetAngles( Ang )
|
||||||
|
wire_button:SetPos( Pos )
|
||||||
|
wire_button:Spawn()
|
||||||
|
|
||||||
|
wire_button:Setup(toggle, value_off, value_on )
|
||||||
|
wire_button:SetPlayer( pl )
|
||||||
|
|
||||||
|
local ttable = {
|
||||||
|
toggle = toggle,
|
||||||
|
value_off = value_off,
|
||||||
|
value_on = value_on,
|
||||||
|
pl = pl
|
||||||
|
}
|
||||||
|
table.Merge(wire_button:GetTable(), ttable )
|
||||||
|
|
||||||
|
pl:AddCount( "wire_buttons", wire_button )
|
||||||
|
|
||||||
|
return wire_button
|
||||||
|
end
|
||||||
|
|
||||||
|
duplicator.RegisterEntityClass("gmod_wire_button", MakeWireButton, "Model", "Pos", "Ang", "toggle", "value_off", "value_on", "description", "Vel", "aVel", "frozen" )
|
||||||
|
@ -307,12 +307,12 @@ function TOOL.BuildCPanel(panel)
|
|||||||
Command = "wire_width"
|
Command = "wire_width"
|
||||||
})
|
})
|
||||||
|
|
||||||
panel:AddControl("MaterialGallery", {
|
/*panel:AddControl("MaterialGallery", {
|
||||||
Label = "#WireTool_material",
|
Label = "#WireTool_material",
|
||||||
Height = "64",
|
Height = 64,
|
||||||
Width = "24",
|
Width = 24,
|
||||||
Rows = "1",
|
Rows = 1,
|
||||||
Stretch = "1",
|
Stretch = 1,
|
||||||
|
|
||||||
Options = {
|
Options = {
|
||||||
["Wire"] = { Material = "cable/rope_icon", wire_material = "cable/rope" },
|
["Wire"] = { Material = "cable/rope_icon", wire_material = "cable/rope" },
|
||||||
@ -331,7 +331,16 @@ function TOOL.BuildCPanel(panel)
|
|||||||
CVars = {
|
CVars = {
|
||||||
[0] = "wire_material"
|
[0] = "wire_material"
|
||||||
}
|
}
|
||||||
})
|
})*/
|
||||||
|
|
||||||
|
panel:AddControl( "MatSelect", {
|
||||||
|
Height = "1",
|
||||||
|
Label = "#WireTool_material",
|
||||||
|
ItemWidth = 24,
|
||||||
|
ItemHeight = 64,
|
||||||
|
ConVar = "wire_material",
|
||||||
|
Options = list.Get( "WireMaterials" )
|
||||||
|
} )
|
||||||
|
|
||||||
panel:AddControl("Color", {
|
panel:AddControl("Color", {
|
||||||
Label = "#WireTool_colour",
|
Label = "#WireTool_colour",
|
||||||
@ -407,3 +416,14 @@ function TOOL:SelectComponent(ent)
|
|||||||
self.CurrentComponent:SetNetworkedBeamString("BlinkWire", self.CurrentInput)
|
self.CurrentComponent:SetNetworkedBeamString("BlinkWire", self.CurrentInput)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
list.Add( "WireMaterials", "cable/rope_icon" )
|
||||||
|
list.Add( "WireMaterials", "cable/cable2" )
|
||||||
|
list.Add( "WireMaterials", "cable/xbeam" )
|
||||||
|
list.Add( "WireMaterials", "cable/redlaser" )
|
||||||
|
list.Add( "WireMaterials", "cable/blue_elec" )
|
||||||
|
list.Add( "WireMaterials", "cable/physbeam" )
|
||||||
|
list.Add( "WireMaterials", "cable/hydra" )
|
||||||
|
//new wire materials by Acegikmo
|
||||||
|
list.Add( "WireMaterials", "arrowire/arrowire" )
|
||||||
|
list.Add( "WireMaterials", "arrowire/arrowire2" )
|
||||||
|
@ -1,210 +0,0 @@
|
|||||||
TOOL.Category = "Wire - I/O"
|
|
||||||
TOOL.Name = "Adv. Input"
|
|
||||||
TOOL.Command = nil
|
|
||||||
TOOL.ConfigName = ""
|
|
||||||
|
|
||||||
if ( CLIENT ) then
|
|
||||||
language.Add( "Tool_wire_adv_input_name", "Adv. Input Tool (Wire)" )
|
|
||||||
language.Add( "Tool_wire_adv_input_desc", "Spawns a adv. input for use with the wire system." )
|
|
||||||
language.Add( "Tool_wire_adv_input_0", "Primary: Create/Update Adv. Input" )
|
|
||||||
language.Add( "WireAdvInputTool_keymore", "Increase:" )
|
|
||||||
language.Add( "WireAdvInputTool_keyless", "Decrease:" )
|
|
||||||
language.Add( "WireAdvInputTool_toggle", "Toggle:" )
|
|
||||||
language.Add( "WireAdvInputTool_value_min", "Minimum:" )
|
|
||||||
language.Add( "WireAdvInputTool_value_max", "Maximum:" )
|
|
||||||
language.Add( "WireAdvInputTool_value_start", "Start at:" )
|
|
||||||
language.Add( "WireAdvInputTool_speed", "Change per second:" )
|
|
||||||
language.Add( "sboxlimit_wire_adv_inputs", "You've hit adv_inputs limit!" )
|
|
||||||
language.Add( "undone_wireadv_input", "Undone Wire Adv. Input" )
|
|
||||||
end
|
|
||||||
|
|
||||||
if (SERVER) then
|
|
||||||
CreateConVar('sbox_maxwire_adv_inputs',20)
|
|
||||||
end
|
|
||||||
|
|
||||||
TOOL.ClientConVar[ "keymore" ] = "3"
|
|
||||||
TOOL.ClientConVar[ "keyless" ] = "1"
|
|
||||||
TOOL.ClientConVar[ "toggle" ] = "0"
|
|
||||||
TOOL.ClientConVar[ "value_min" ] = "0"
|
|
||||||
TOOL.ClientConVar[ "value_max" ] = "10"
|
|
||||||
TOOL.ClientConVar[ "value_start" ] = "5"
|
|
||||||
TOOL.ClientConVar[ "speed" ] = "1"
|
|
||||||
|
|
||||||
TOOL.Model = "models/jaanus/wiretool/wiretool_input.mdl"
|
|
||||||
|
|
||||||
cleanup.Register( "wire_adv_inputs" )
|
|
||||||
|
|
||||||
function TOOL:LeftClick( trace )
|
|
||||||
|
|
||||||
if (!trace.HitPos) then return false end
|
|
||||||
if (trace.Entity:IsPlayer()) then return false end
|
|
||||||
if ( CLIENT ) then return true end
|
|
||||||
|
|
||||||
local ply = self:GetOwner()
|
|
||||||
|
|
||||||
// Get client's CVars
|
|
||||||
local _keymore = self:GetClientNumber( "keymore" )
|
|
||||||
local _keyless = self:GetClientNumber( "keyless" )
|
|
||||||
local _toggle = self:GetClientNumber( "toggle" )
|
|
||||||
local _value_min = self:GetClientNumber( "value_min" )
|
|
||||||
local _value_max = self:GetClientNumber( "value_max" )
|
|
||||||
local _value_start = self:GetClientNumber( "value_start" )
|
|
||||||
local _speed = self:GetClientNumber( "speed" )
|
|
||||||
|
|
||||||
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_adv_input" && trace.Entity.pl == ply ) then
|
|
||||||
trace.Entity:Setup( _keymore, _keyless, _toggle, _value_min, _value_max, _value_start, _speed )
|
|
||||||
trace.Entity.keymore = _keymore
|
|
||||||
trace.Entity.keyless = _keyless
|
|
||||||
trace.Entity.toggle = _toggle
|
|
||||||
trace.Entity.value_min = _value_min
|
|
||||||
trace.Entity.value_max = _value_max
|
|
||||||
trace.Entity.value_start = _value_start
|
|
||||||
trace.Entity.speed = _speed
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if ( !self:GetSWEP():CheckLimit( "wire_adv_inputs" ) ) then return false end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local wire_adv_input = MakeWireAdvInput( ply, trace.HitPos, Ang, _keymore, _keyless, _toggle, _value_min, _value_max, _value_start, _speed )
|
|
||||||
|
|
||||||
local min = wire_adv_input:OBBMins()
|
|
||||||
wire_adv_input:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
|
|
||||||
local const = WireLib.Weld(wire_adv_input, trace.Entity, trace.PhysicsBone, true)
|
|
||||||
|
|
||||||
undo.Create("WireInput")
|
|
||||||
undo.AddEntity( wire_adv_input )
|
|
||||||
undo.AddEntity( const )
|
|
||||||
undo.SetPlayer( ply )
|
|
||||||
undo.Finish()
|
|
||||||
|
|
||||||
ply:AddCleanup( "wire_adv_inputs", wire_adv_input )
|
|
||||||
|
|
||||||
return true
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
if (SERVER) then
|
|
||||||
|
|
||||||
function MakeWireAdvInput( pl, Pos, Ang, keymore, keyless, toggle, value_min, value_max, value_start, speed, Vel, aVel, frozen )
|
|
||||||
|
|
||||||
if ( !pl:CheckLimit( "wire_adv_inputs" ) ) then return false end
|
|
||||||
|
|
||||||
local wire_adv_input = ents.Create( "gmod_wire_adv_input" )
|
|
||||||
if (!wire_adv_input:IsValid()) then return false end
|
|
||||||
|
|
||||||
wire_adv_input:SetAngles( Ang )
|
|
||||||
wire_adv_input:SetPos( Pos )
|
|
||||||
wire_adv_input:SetModel( Model("models/jaanus/wiretool/wiretool_input.mdl") )
|
|
||||||
wire_adv_input:Spawn()
|
|
||||||
|
|
||||||
wire_adv_input:Setup( keymore, keyless, toggle, value_min, value_max, value_start, speed )
|
|
||||||
wire_adv_input:SetPlayer( pl )
|
|
||||||
|
|
||||||
numpad.OnDown( pl, keymore, "WireAdvInput_On", wire_adv_input, 1 )
|
|
||||||
numpad.OnUp( pl, keymore, "WireAdvInput_Off", wire_adv_input, 1 )
|
|
||||||
|
|
||||||
numpad.OnDown( pl, keyless, "WireAdvInput_On", wire_adv_input, -1 )
|
|
||||||
numpad.OnUp( pl, keyless, "WireAdvInput_Off", wire_adv_input, -1 )
|
|
||||||
|
|
||||||
local ttable = {
|
|
||||||
keymore = keymore,
|
|
||||||
keyless = keyless,
|
|
||||||
toggle = toggle,
|
|
||||||
value_min = value_min,
|
|
||||||
value_max = value_max,
|
|
||||||
value_start = value_start,
|
|
||||||
speed = speed,
|
|
||||||
pl = pl
|
|
||||||
}
|
|
||||||
table.Merge(wire_adv_input:GetTable(), ttable )
|
|
||||||
|
|
||||||
pl:AddCount( "wire_adv_inputs", wire_adv_input )
|
|
||||||
|
|
||||||
return wire_adv_input
|
|
||||||
end
|
|
||||||
|
|
||||||
duplicator.RegisterEntityClass("gmod_wire_adv_input", MakeWireAdvInput, "Pos", "Ang", "keymore", "keyless", "toggle", "value_min", "value_max", "value_start", "speed", "Vel", "aVel", "frozen")
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function TOOL:UpdateGhostWireInput( ent, player )
|
|
||||||
|
|
||||||
if ( !ent || !ent:IsValid() ) then return end
|
|
||||||
|
|
||||||
local tr = utilx.GetPlayerTrace( player, player:GetCursorAimVector() )
|
|
||||||
local trace = util.TraceLine( tr )
|
|
||||||
|
|
||||||
if (!trace.Hit || trace.Entity:IsPlayer() || trace.Entity:GetClass() == "gmod_wire_adv_input" ) then
|
|
||||||
ent:SetNoDraw( true )
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local min = ent:OBBMins()
|
|
||||||
ent:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
ent:SetAngles( Ang )
|
|
||||||
|
|
||||||
ent:SetNoDraw( false )
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function TOOL:Think()
|
|
||||||
|
|
||||||
if (!self.GhostEntity || !self.GhostEntity:IsValid() || self.GhostEntity:GetModel() != self.Model ) then
|
|
||||||
self:MakeGhostEntity( self.Model, Vector(0,0,0), Angle(0,0,0) )
|
|
||||||
end
|
|
||||||
|
|
||||||
self:UpdateGhostWireInput( self.GhostEntity, self:GetOwner() )
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function TOOL.BuildCPanel( CPanel )
|
|
||||||
// HEADER
|
|
||||||
CPanel:AddControl( "Header", { Text = "#Tool_wire_adv_input_name", Description = "#Tool_wire_adv_input_desc" } )
|
|
||||||
// Change Togglers
|
|
||||||
CPanel:AddControl( "Numpad", { Label = "#WireAdvInputTool_keymore",
|
|
||||||
Command = "wire_adv_input_keymore",
|
|
||||||
ButtonSize = 22 }
|
|
||||||
)
|
|
||||||
CPanel:AddControl( "Numpad", { Label = "#WireAdvInputTool_keyless",
|
|
||||||
Command = "wire_adv_input_keyless",
|
|
||||||
ButtonSize = 22 }
|
|
||||||
)
|
|
||||||
CPanel:AddControl( "CheckBox", { Label = "#WireAdvInputTool_toggle",
|
|
||||||
Command = "wire_adv_input_toggle" }
|
|
||||||
)
|
|
||||||
CPanel:AddControl( "Slider", { Label = "#WireAdvInputTool_value_min",
|
|
||||||
Type = "Float",
|
|
||||||
Min = -50,
|
|
||||||
Max = 50,
|
|
||||||
Command = "wire_adv_input_value_min"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
CPanel:AddControl( "Slider", { Label = "#WireAdvInputTool_value_max",
|
|
||||||
Type = "Float",
|
|
||||||
Min = -50,
|
|
||||||
Max = 50,
|
|
||||||
Command = "wire_adv_input_value_max"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
CPanel:AddControl( "Slider", { Label = "#WireAdvInputTool_value_start",
|
|
||||||
Type = "Float",
|
|
||||||
Min = -50,
|
|
||||||
Max = 50,
|
|
||||||
Command = "wire_adv_input_value_start"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
CPanel:AddControl( "Slider", { Label = "#WireAdvInputTool_speed",
|
|
||||||
Type = "Float",
|
|
||||||
Min = 0.1,
|
|
||||||
Max = 50,
|
|
||||||
Command = "wire_adv_input_speed"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
end
|
|
@ -1,123 +0,0 @@
|
|||||||
TOOL.Category = "Wire - I/O"
|
|
||||||
TOOL.Name = "Advanced Pod Controller"
|
|
||||||
TOOL.Command = nil -- What is this for?
|
|
||||||
TOOL.ConfigName = ""
|
|
||||||
|
|
||||||
if CLIENT then
|
|
||||||
language.Add("Tool_wire_adv_pod_name", "Advanced Pod Controller Tool (Wire)")
|
|
||||||
language.Add("Tool_wire_adv_pod_desc", "Spawn/link a Wire Advanced Pod controller.")
|
|
||||||
language.Add("Tool_wire_adv_pod_0", "Primary: Create Advanced Pod controller. Secondary: Link Advanced controller.")
|
|
||||||
language.Add("Tool_wire_adv_pod_1", "Now select the pod to link to.")
|
|
||||||
language.Add("sboxlimit_wire_pods", "You've hit your Pod Controller limit!")
|
|
||||||
language.Add("Undone_Advanced Wire Pod", "Undone Wire Advanced Pod Controller")
|
|
||||||
end
|
|
||||||
|
|
||||||
if SERVER then
|
|
||||||
CreateConVar('sbox_maxwire_pods', 20)
|
|
||||||
end
|
|
||||||
|
|
||||||
TOOL.Model = "models/jaanus/wiretool/wiretool_siren.mdl"
|
|
||||||
|
|
||||||
cleanup.Register("wire_pods")
|
|
||||||
|
|
||||||
function TOOL:LeftClick(trace)
|
|
||||||
if not trace.HitPos then return false end
|
|
||||||
if trace.Entity:IsPlayer() then return false end
|
|
||||||
if CLIENT then return true end
|
|
||||||
|
|
||||||
local ply = self:GetOwner()
|
|
||||||
|
|
||||||
if not self:GetSWEP():CheckLimit("wire_pods") then return false end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local wire_pod = MakeWireAdvPod(ply, trace.HitPos, Ang)
|
|
||||||
|
|
||||||
wire_pod:SetPos(trace.HitPos - trace.HitNormal * wire_pod:OBBMins().z)
|
|
||||||
|
|
||||||
local const = WireLib.Weld(wire_pod, trace.Entity, trace.PhysicsBone, true)
|
|
||||||
|
|
||||||
undo.Create("Advanced Wire Pod")
|
|
||||||
undo.AddEntity(wire_pod)
|
|
||||||
undo.AddEntity(const)
|
|
||||||
undo.SetPlayer(ply)
|
|
||||||
undo.Finish()
|
|
||||||
|
|
||||||
ply:AddCleanup("wire_pods", wire_pod)
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function TOOL:RightClick(trace)
|
|
||||||
if (self:GetStage() == 0) and trace.Entity:GetClass() == "gmod_wire_adv_pod" then
|
|
||||||
self.PodCont = trace.Entity
|
|
||||||
self:SetStage(1)
|
|
||||||
return true
|
|
||||||
elseif self:GetStage() == 1 and trace.Entity.GetPassenger then
|
|
||||||
self.PodCont:Setup(trace.Entity)
|
|
||||||
self:SetStage(0)
|
|
||||||
self.PodCont = nil
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function TOOL:Reload(trace)
|
|
||||||
self:SetStage(0)
|
|
||||||
self.PodCont = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
if SERVER then
|
|
||||||
|
|
||||||
function MakeWireAdvPod(pl, Pos, Ang)
|
|
||||||
if not pl:CheckLimit("wire_pods") then return false end
|
|
||||||
|
|
||||||
local wire_pod = ents.Create("gmod_wire_adv_pod")
|
|
||||||
if not wire_pod:IsValid() then return false end
|
|
||||||
|
|
||||||
wire_pod:SetAngles(Ang)
|
|
||||||
wire_pod:SetPos(Pos)
|
|
||||||
wire_pod:Spawn()
|
|
||||||
wire_pod:SetPlayer(pl)
|
|
||||||
wire_pod.pl = pl
|
|
||||||
|
|
||||||
pl:AddCount("wire_pods", wire_pod)
|
|
||||||
|
|
||||||
return wire_pod
|
|
||||||
end
|
|
||||||
duplicator.RegisterEntityClass("gmod_wire_adv_pod", MakeWireAdvPod, "Pos", "Ang", "Vel", "aVel", "frozen")
|
|
||||||
end
|
|
||||||
|
|
||||||
function TOOL:UpdateGhostWirePod(ent, player)
|
|
||||||
if not ent or not ent:IsValid() then return end
|
|
||||||
|
|
||||||
local tr = utilx.GetPlayerTrace(player, player:GetCursorAimVector())
|
|
||||||
local trace = util.TraceLine(tr)
|
|
||||||
|
|
||||||
if not trace.Hit or trace.Entity:IsPlayer() or trace.Entity:GetClass() == "gmod_wire_adv_pod" then
|
|
||||||
ent:SetNoDraw(true)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
ent:SetPos(trace.HitPos - trace.HitNormal * ent:OBBMins().z)
|
|
||||||
ent:SetAngles(Ang)
|
|
||||||
|
|
||||||
ent:SetNoDraw(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TOOL:Think()
|
|
||||||
if not self.GhostEntity or not self.GhostEntity:IsValid() or self.GhostEntity:GetModel() ~= self.Model then
|
|
||||||
self:MakeGhostEntity(self.Model, Vector(0,0,0), Angle(0,0,0))
|
|
||||||
end
|
|
||||||
|
|
||||||
self:UpdateGhostWirePod(self.GhostEntity, self:GetOwner())
|
|
||||||
end
|
|
||||||
|
|
||||||
function TOOL.BuildCPanel(panel)
|
|
||||||
panel:AddControl("Header", { Text = "#Tool_wire_pod_name", Description = "#Tool_wire_pod_desc" })
|
|
||||||
end
|
|
@ -1,185 +0,0 @@
|
|||||||
TOOL.Category = "Wire - I/O"
|
|
||||||
TOOL.Name = "Button"
|
|
||||||
TOOL.Command = nil
|
|
||||||
TOOL.ConfigName = ""
|
|
||||||
|
|
||||||
if ( CLIENT ) then
|
|
||||||
language.Add( "Tool_wire_button_name", "Button Tool (Wire)" )
|
|
||||||
language.Add( "Tool_wire_button_desc", "Spawns a button for use with the wire system." )
|
|
||||||
language.Add( "Tool_wire_button_0", "Primary: Create/Update Button" )
|
|
||||||
language.Add( "WireButtonTool_toggle", "Toggle:" )
|
|
||||||
language.Add( "WireButtonTool_value_on", "Value On:" )
|
|
||||||
language.Add( "WireButtonTool_value_off", "Value Off:" )
|
|
||||||
language.Add( "sboxlimit_wire_buttons", "You've hit buttons limit!" )
|
|
||||||
language.Add( "undone_wirebutton", "Undone Wire Button" )
|
|
||||||
end
|
|
||||||
|
|
||||||
if (SERVER) then
|
|
||||||
CreateConVar('sbox_maxwire_buttons', 20)
|
|
||||||
end
|
|
||||||
|
|
||||||
TOOL.ClientConVar[ "model" ] = "models/props_c17/clock01.mdl"
|
|
||||||
TOOL.ClientConVar[ "toggle" ] = "0"
|
|
||||||
TOOL.ClientConVar[ "value_off" ] = "0"
|
|
||||||
TOOL.ClientConVar[ "value_on" ] = "1"
|
|
||||||
TOOL.ClientConVar[ "description" ] = ""
|
|
||||||
|
|
||||||
if (SERVER) then
|
|
||||||
ModelPlug_Register("button")
|
|
||||||
end
|
|
||||||
|
|
||||||
cleanup.Register( "wire_buttons" )
|
|
||||||
|
|
||||||
function TOOL:LeftClick( trace )
|
|
||||||
|
|
||||||
if (!trace.HitPos) then return false end
|
|
||||||
if (trace.Entity:IsPlayer()) then return false end
|
|
||||||
if ( CLIENT ) then return true end
|
|
||||||
|
|
||||||
local ply = self:GetOwner()
|
|
||||||
|
|
||||||
// Get client's CVars
|
|
||||||
local _model = self:GetClientInfo( "model" )
|
|
||||||
local _toggle = (self:GetClientNumber( "toggle" ) ~= 0)
|
|
||||||
local _value_off = self:GetClientNumber( "value_off" )
|
|
||||||
local _value_on = self:GetClientNumber( "value_on" )
|
|
||||||
local _description = self:GetClientInfo( "description" )
|
|
||||||
|
|
||||||
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_button" && trace.Entity.pl == ply ) then
|
|
||||||
trace.Entity:Setup(_toggle, _value_off, _value_on)
|
|
||||||
trace.Entity.toggle = _toggle
|
|
||||||
trace.Entity.value_off = _value_off
|
|
||||||
trace.Entity.value_on = _value_on
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if ( !self:GetSWEP():CheckLimit( "wire_buttons" ) ) then return false end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local wire_button = MakeWireButton( ply, _model, trace.HitPos, Ang, _toggle, _value_off, _value_on, _description )
|
|
||||||
|
|
||||||
local min = wire_button:OBBMins()
|
|
||||||
wire_button:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
|
|
||||||
local const = WireLib.Weld(wire_button, trace.Entity, trace.PhysicsBone, true)
|
|
||||||
|
|
||||||
undo.Create("WireButton")
|
|
||||||
undo.AddEntity( wire_button )
|
|
||||||
undo.AddEntity( const )
|
|
||||||
undo.SetPlayer( ply )
|
|
||||||
undo.Finish()
|
|
||||||
|
|
||||||
ply:AddCleanup( "wire_buttons", wire_button )
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if (SERVER) then
|
|
||||||
|
|
||||||
function MakeWireButton( pl, Model, Pos, Ang, toggle, value_off, value_on, description, Vel, aVel, frozen )
|
|
||||||
if ( !pl:CheckLimit( "wire_buttons" ) ) then return false end
|
|
||||||
|
|
||||||
local wire_button = ents.Create( "gmod_wire_button" )
|
|
||||||
if (!wire_button:IsValid()) then return false end
|
|
||||||
|
|
||||||
wire_button:SetModel( Model )
|
|
||||||
wire_button:SetAngles( Ang )
|
|
||||||
wire_button:SetPos( Pos )
|
|
||||||
wire_button:Spawn()
|
|
||||||
|
|
||||||
wire_button:Setup(toggle, value_off, value_on )
|
|
||||||
wire_button:SetPlayer( pl )
|
|
||||||
|
|
||||||
local ttable = {
|
|
||||||
toggle = toggle,
|
|
||||||
value_off = value_off,
|
|
||||||
value_on = value_on,
|
|
||||||
pl = pl
|
|
||||||
}
|
|
||||||
table.Merge(wire_button:GetTable(), ttable )
|
|
||||||
|
|
||||||
pl:AddCount( "wire_buttons", wire_button )
|
|
||||||
|
|
||||||
return wire_button
|
|
||||||
end
|
|
||||||
|
|
||||||
duplicator.RegisterEntityClass("gmod_wire_button", MakeWireButton, "Model", "Pos", "Ang", "toggle", "value_off", "value_on", "description", "Vel", "aVel", "frozen" )
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function TOOL:UpdateGhostWireButton( ent, player )
|
|
||||||
if ( !ent || !ent:IsValid() ) then return end
|
|
||||||
|
|
||||||
local tr = utilx.GetPlayerTrace( player, player:GetCursorAimVector() )
|
|
||||||
local trace = util.TraceLine( tr )
|
|
||||||
|
|
||||||
if (!trace.Hit || trace.Entity:IsPlayer() || trace.Entity:GetClass() == "gmod_wire_button" ) then
|
|
||||||
ent:SetNoDraw( true )
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local min = ent:OBBMins()
|
|
||||||
ent:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
ent:SetAngles( Ang )
|
|
||||||
|
|
||||||
ent:SetNoDraw( false )
|
|
||||||
end
|
|
||||||
|
|
||||||
function TOOL:Think()
|
|
||||||
if (!self.GhostEntity || !self.GhostEntity:IsValid() || self.GhostEntity:GetModel() != self:GetClientInfo( "model" ) ) then
|
|
||||||
self:MakeGhostEntity( self:GetClientInfo( "model" ), Vector(0,0,0), Angle(0,0,0) )
|
|
||||||
end
|
|
||||||
|
|
||||||
self:UpdateGhostWireButton( self.GhostEntity, self:GetOwner() )
|
|
||||||
end
|
|
||||||
|
|
||||||
function TOOL.BuildCPanel(panel)
|
|
||||||
panel:AddControl("Header", { Text = "#Tool_wire_button_name", Description = "#Tool_wire_button_desc" })
|
|
||||||
|
|
||||||
panel:AddControl("ComboBox", {
|
|
||||||
Label = "#Presets",
|
|
||||||
MenuButton = "1",
|
|
||||||
Folder = "wire_button",
|
|
||||||
|
|
||||||
Options = {
|
|
||||||
Default = {
|
|
||||||
wire_button_toggle = "0",
|
|
||||||
wire_button_value_on = "1",
|
|
||||||
wire_button_value_off = "0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
CVars = {
|
|
||||||
[0] = "wire_button_toggle",
|
|
||||||
[1] = "wire_button_value_on",
|
|
||||||
[2] = "wire_button_value_off"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
ModelPlug_AddToCPanel(panel, "button", "wire_button", "#Button_Model", nil, "#Button_Model")
|
|
||||||
|
|
||||||
panel:AddControl("CheckBox", {
|
|
||||||
Label = "#WireButtonTool_toggle",
|
|
||||||
Command = "wire_button_toggle"
|
|
||||||
})
|
|
||||||
|
|
||||||
panel:AddControl("Slider", {
|
|
||||||
Label = "#WireButtonTool_value_on",
|
|
||||||
Type = "Float",
|
|
||||||
Min = "-10",
|
|
||||||
Max = "10",
|
|
||||||
Command = "wire_button_value_on"
|
|
||||||
})
|
|
||||||
panel:AddControl("Slider", {
|
|
||||||
Label = "#WireButtonTool_value_off",
|
|
||||||
Type = "Float",
|
|
||||||
Min = "-10",
|
|
||||||
Max = "10",
|
|
||||||
Command = "wire_button_value_off"
|
|
||||||
})
|
|
||||||
end
|
|
@ -779,32 +779,6 @@ function TOOL.BuildCPanel(panel)
|
|||||||
ModelPlug_AddToCPanel(panel, "speaker", "wire_soundemitter", "#WireEmitterTool_model", nil, "#WireEmitterTool_model")
|
ModelPlug_AddToCPanel(panel, "speaker", "wire_soundemitter", "#WireEmitterTool_model", nil, "#WireEmitterTool_model")
|
||||||
end
|
end
|
||||||
|
|
||||||
local WireSounds = {
|
|
||||||
Warning = "common/warning.wav",
|
|
||||||
Talk = "common/talk.wav",
|
|
||||||
Button = "buttons/button15.wav",
|
|
||||||
Denied = "buttons/weapon_cant_buy.wav",
|
|
||||||
Zap = "ambient/energy/zap2.wav",
|
|
||||||
["Oh No"] = "vo/npc/male01/ohno.wav",
|
|
||||||
Yeah = "vo/npc/male01/yeah02.wav",
|
|
||||||
["apc alarm"] = "ambient/alarms/apc_alarm_loop1.wav",
|
|
||||||
["Coast Siren"] = "coast.siren_citizen",
|
|
||||||
["Bunker Siren"] = "coast.bunker_siren1",
|
|
||||||
["Alarm Bell"] = "d1_canals.Floodgate_AlarmBellLoop",
|
|
||||||
["Engine Start"] = "ATV_engine_start",
|
|
||||||
["Engine Stop"] = "ATV_engine_stop",
|
|
||||||
["Zombie Breathe"] = "NPC_PoisonZombie.Moan1",
|
|
||||||
["Idle Zombies"] = "Zombie.Idle",
|
|
||||||
["Turret Alert"] = "NPC_FloorTurret.Alert",
|
|
||||||
["Helicopter Rotor"] = "NPC_CombineGunship.RotorSound",
|
|
||||||
Heartbeat = "k_lab.teleport_heartbeat",
|
|
||||||
Breathing = "k_lab.teleport_breathing",
|
|
||||||
}
|
|
||||||
|
|
||||||
for k,v in pairs(WireSounds) do
|
|
||||||
list.Set("WireSounds",k,{wire_soundemitter_sound=v});
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,13 +167,13 @@ function TOOL.BuildCPanel(panel)
|
|||||||
|
|
||||||
for gatetype, gatefuncs in pairs(WireGatesSorted) do
|
for gatetype, gatefuncs in pairs(WireGatesSorted) do
|
||||||
local node = tree:AddNode( gatetype.." Gates" )
|
local node = tree:AddNode( gatetype.." Gates" )
|
||||||
table.SortByMember( gatefuncs, "name", true ) --doesn't work, fix
|
table.SortByMember( gatefuncs, "name", true )
|
||||||
for k,v in pairs(gatefuncs) do
|
for k,v in pairs(gatefuncs) do
|
||||||
local cnode = node:AddNode( v.name or "No Name" )
|
local cnode = node:AddNode( v.name or "No Name" )
|
||||||
cnode.myname = v.name
|
cnode.myname = v.name
|
||||||
cnode.myaction = k
|
cnode.myaction = k
|
||||||
function cnode:DoClick()
|
function cnode:DoClick()
|
||||||
RunConsoleCommand( "wire_gates_action "..self.myaction )
|
RunConsoleCommand( "wire_gates_action", self.myaction )
|
||||||
end
|
end
|
||||||
cnode.Icon:SetImage( "gui/silkicons/newspaper" )
|
cnode.Icon:SetImage( "gui/silkicons/newspaper" )
|
||||||
end
|
end
|
||||||
|
212
wire/lua/wire/stools/io.lua
Normal file
212
wire/lua/wire/stools/io.lua
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
AddCSLuaFile( "io.lua" )
|
||||||
|
|
||||||
|
|
||||||
|
--wire_adv_input
|
||||||
|
WireToolSetup.open( "adv_input", "I/O", "Adv. Input", "gmod_wire_adv_input", WireToolMakeAdvInput )
|
||||||
|
|
||||||
|
if ( CLIENT ) then
|
||||||
|
language.Add( "Tool_wire_adv_input_name", "Adv. Input Tool (Wire)" )
|
||||||
|
language.Add( "Tool_wire_adv_input_desc", "Spawns a adv. input for use with the wire system." )
|
||||||
|
language.Add( "Tool_wire_adv_input_0", "Primary: Create/Update Adv. Input" )
|
||||||
|
language.Add( "WireAdvInputTool_keymore", "Increase:" )
|
||||||
|
language.Add( "WireAdvInputTool_keyless", "Decrease:" )
|
||||||
|
language.Add( "WireAdvInputTool_toggle", "Toggle:" )
|
||||||
|
language.Add( "WireAdvInputTool_value_min", "Minimum:" )
|
||||||
|
language.Add( "WireAdvInputTool_value_max", "Maximum:" )
|
||||||
|
language.Add( "WireAdvInputTool_value_start", "Start at:" )
|
||||||
|
language.Add( "WireAdvInputTool_speed", "Change per second:" )
|
||||||
|
language.Add( "sboxlimit_wire_adv_inputs", "You've hit wired adv input limit!" )
|
||||||
|
language.Add( "undone_gmod_wire_adv_input", "Undone Wire Adv. Input" )
|
||||||
|
language.Add( "Cleanup_gmod_wire_adv_input", "Wire Adv. Inputs" )
|
||||||
|
language.Add( "Cleaned_gmod_wire_adv_input", "Cleaned Up Wire Adv. Inputs" )
|
||||||
|
end
|
||||||
|
|
||||||
|
cleanup.Register( "gmod_wire_adv_input" )
|
||||||
|
|
||||||
|
if (SERVER) then
|
||||||
|
CreateConVar('sbox_maxwire_adv_inputs',20)
|
||||||
|
end
|
||||||
|
|
||||||
|
TOOL.Model = "models/jaanus/wiretool/wiretool_input.mdl"
|
||||||
|
TOOL.ClientConVar = {
|
||||||
|
keymore = "3",
|
||||||
|
keyless = "1",
|
||||||
|
toggle = "0",
|
||||||
|
value_min = "0",
|
||||||
|
value_max = "10",
|
||||||
|
value_start = "5",
|
||||||
|
spee = "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function TOOL.BuildCPanel( CPanel )
|
||||||
|
CPanel:AddControl( "Header", { Text = "#Tool_wire_adv_input_name", Description = "#Tool_wire_adv_input_desc" } )
|
||||||
|
CPanel:AddControl( "Numpad", { Label = "#WireAdvInputTool_keymore",
|
||||||
|
Command = "wire_adv_input_keymore",
|
||||||
|
ButtonSize = 22 }
|
||||||
|
)
|
||||||
|
CPanel:AddControl( "Numpad", { Label = "#WireAdvInputTool_keyless",
|
||||||
|
Command = "wire_adv_input_keyless",
|
||||||
|
ButtonSize = 22 }
|
||||||
|
)
|
||||||
|
CPanel:AddControl( "CheckBox", { Label = "#WireAdvInputTool_toggle",
|
||||||
|
Command = "wire_adv_input_toggle" }
|
||||||
|
)
|
||||||
|
CPanel:AddControl( "Slider", { Label = "#WireAdvInputTool_value_min",
|
||||||
|
Type = "Float",
|
||||||
|
Min = -50,
|
||||||
|
Max = 50,
|
||||||
|
Command = "wire_adv_input_value_min"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
CPanel:AddControl( "Slider", { Label = "#WireAdvInputTool_value_max",
|
||||||
|
Type = "Float",
|
||||||
|
Min = -50,
|
||||||
|
Max = 50,
|
||||||
|
Command = "wire_adv_input_value_max"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
CPanel:AddControl( "Slider", { Label = "#WireAdvInputTool_value_start",
|
||||||
|
Type = "Float",
|
||||||
|
Min = -50,
|
||||||
|
Max = 50,
|
||||||
|
Command = "wire_adv_input_value_start"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
CPanel:AddControl( "Slider", { Label = "#WireAdvInputTool_speed",
|
||||||
|
Type = "Float",
|
||||||
|
Min = 0.1,
|
||||||
|
Max = 50,
|
||||||
|
Command = "wire_adv_input_speed"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--wire_adv_pod
|
||||||
|
WireToolSetup.open( "adv_pod", "I/O", "Advanced Pod Controller", "gmod_wire_adv_pod", WireToolMakeAdvPod )
|
||||||
|
|
||||||
|
if CLIENT then
|
||||||
|
language.Add("Tool_wire_adv_pod_name", "Advanced Pod Controller Tool (Wire)")
|
||||||
|
language.Add("Tool_wire_adv_pod_desc", "Spawn/link a Wire Advanced Pod controller.")
|
||||||
|
language.Add("Tool_wire_adv_pod_0", "Primary: Create Advanced Pod controller. Secondary: Link Advanced controller.")
|
||||||
|
language.Add("Tool_wire_adv_pod_1", "Now select the pod to link to.")
|
||||||
|
language.Add("undone_gmod_wire_adv_pod", "Undone Wire Advanced Pod Controller")
|
||||||
|
language.Add("Cleanup_gmod_wire_adv_pod", "Wire Advanced Pod Controllers")
|
||||||
|
language.Add("Cleaned_gmod_wire_adv_pod", "Cleaned Up Wire Advanced Pod Controllers")
|
||||||
|
end
|
||||||
|
|
||||||
|
cleanup.Register("gmod_wire_adv_pod")
|
||||||
|
|
||||||
|
TOOL.Model = "models/jaanus/wiretool/wiretool_siren.mdl"
|
||||||
|
TOOL.NoLeftOnClass = true
|
||||||
|
|
||||||
|
function TOOL:RightClick(trace)
|
||||||
|
if (self:GetStage() == 0) and trace.Entity:GetClass() == "gmod_wire_adv_pod" then
|
||||||
|
self.PodCont = trace.Entity
|
||||||
|
self:SetStage(1)
|
||||||
|
return true
|
||||||
|
elseif self:GetStage() == 1 and trace.Entity.GetPassenger then
|
||||||
|
self.PodCont:Setup(trace.Entity)
|
||||||
|
self:SetStage(0)
|
||||||
|
self.PodCont = nil
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function TOOL:Reload(trace)
|
||||||
|
self:SetStage(0)
|
||||||
|
self.PodCont = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function TOOL.BuildCPanel(panel)
|
||||||
|
panel:AddControl("Header", { Text = "#Tool_wire_pod_name", Description = "#Tool_wire_pod_desc" })
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--wire_button
|
||||||
|
WireToolSetup.open( "button", "I/O", "Button", "gmod_wire_button", WireToolMakeButton )
|
||||||
|
|
||||||
|
if ( CLIENT ) then
|
||||||
|
language.Add( "Tool_wire_button_name", "Button Tool (Wire)" )
|
||||||
|
language.Add( "Tool_wire_button_desc", "Spawns a button for use with the wire system." )
|
||||||
|
language.Add( "Tool_wire_button_0", "Primary: Create/Update Button" )
|
||||||
|
language.Add( "WireButtonTool_toggle", "Toggle:" )
|
||||||
|
language.Add( "WireButtonTool_value_on", "Value On:" )
|
||||||
|
language.Add( "WireButtonTool_value_off", "Value Off:" )
|
||||||
|
language.Add( "sboxlimit_wire_buttons", "You've hit wired buttons limit!" )
|
||||||
|
language.Add( "undone_gmod_wire_button", "Undone Wire Button" )
|
||||||
|
language.Add( "Cleanup_gmod_wire_button", "Wire Buttons" )
|
||||||
|
language.Add( "Cleaned_gmod_wire_button", "Cleaned Up Wire Buttons" )
|
||||||
|
end
|
||||||
|
|
||||||
|
cleanup.Register( "gmod_wire_button" )
|
||||||
|
|
||||||
|
if (SERVER) then
|
||||||
|
CreateConVar('sbox_maxwire_buttons', 20)
|
||||||
|
ModelPlug_Register("button")
|
||||||
|
end
|
||||||
|
|
||||||
|
TOOL.ClientConVar = {
|
||||||
|
model = "models/props_c17/clock01.mdl",
|
||||||
|
toggle = "0",
|
||||||
|
value_off = "0",
|
||||||
|
value_on = "1",
|
||||||
|
description = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
function TOOL.BuildCPanel(panel)
|
||||||
|
panel:AddControl("Header", { Text = "#Tool_wire_button_name", Description = "#Tool_wire_button_desc" })
|
||||||
|
|
||||||
|
panel:AddControl("ComboBox", {
|
||||||
|
Label = "#Presets",
|
||||||
|
MenuButton = "1",
|
||||||
|
Folder = "wire_button",
|
||||||
|
|
||||||
|
Options = {
|
||||||
|
Default = {
|
||||||
|
wire_button_toggle = "0",
|
||||||
|
wire_button_value_on = "1",
|
||||||
|
wire_button_value_off = "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
CVars = {
|
||||||
|
[0] = "wire_button_toggle",
|
||||||
|
[1] = "wire_button_value_on",
|
||||||
|
[2] = "wire_button_value_off"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
ModelPlug_AddToCPanel(panel, "button", "wire_button", "#Button_Model", nil, "#Button_Model", 6)
|
||||||
|
|
||||||
|
panel:AddControl("CheckBox", {
|
||||||
|
Label = "#WireButtonTool_toggle",
|
||||||
|
Command = "wire_button_toggle"
|
||||||
|
})
|
||||||
|
|
||||||
|
panel:AddControl("Slider", {
|
||||||
|
Label = "#WireButtonTool_value_on",
|
||||||
|
Type = "Float",
|
||||||
|
Min = "-10",
|
||||||
|
Max = "10",
|
||||||
|
Command = "wire_button_value_on"
|
||||||
|
})
|
||||||
|
panel:AddControl("Slider", {
|
||||||
|
Label = "#WireButtonTool_value_off",
|
||||||
|
Type = "Float",
|
||||||
|
Min = "-10",
|
||||||
|
Max = "10",
|
||||||
|
Command = "wire_button_value_off"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -12,6 +12,7 @@ if (SERVER) then include( "sv_wirestools.lua" ) end
|
|||||||
|
|
||||||
include( "gates.lua" )
|
include( "gates.lua" )
|
||||||
include( "display.lua" )
|
include( "display.lua" )
|
||||||
|
include( "io.lua" )
|
||||||
|
|
||||||
--include( ".lua" )
|
--include( ".lua" )
|
||||||
|
|
||||||
|
516
wire/lua/wire/stools/sv_display.lua
Normal file
516
wire/lua/wire/stools/sv_display.lua
Normal file
@ -0,0 +1,516 @@
|
|||||||
|
|
||||||
|
function WireToolMake7Seg( self, trace, ply )
|
||||||
|
|
||||||
|
local model = self:GetClientInfo( "model" )
|
||||||
|
local ar = math.min(self:GetClientNumber("ar"), 255)
|
||||||
|
local ag = math.min(self:GetClientNumber("ag"), 255)
|
||||||
|
local ab = math.min(self:GetClientNumber("ab"), 255)
|
||||||
|
local aa = math.min(self:GetClientNumber("aa"), 255)
|
||||||
|
local br = math.min(self:GetClientNumber("br"), 255)
|
||||||
|
local bg = math.min(self:GetClientNumber("bg"), 255)
|
||||||
|
local bb = math.min(self:GetClientNumber("bb"), 255)
|
||||||
|
local ba = math.min(self:GetClientNumber("ba"), 255)
|
||||||
|
local worldweld = self:GetClientNumber("worldweld") == 1
|
||||||
|
|
||||||
|
-- If we shot a wire_indicator change its force
|
||||||
|
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_indicator" && trace.Entity.pl == ply ) then
|
||||||
|
trace.Entity:Setup(0, ar, ag, ab, aa, 1, br, bg, bb, ba)
|
||||||
|
trace.Entity.a = 0
|
||||||
|
trace.Entity.ar = ar
|
||||||
|
trace.Entity.ag = ag
|
||||||
|
trace.Entity.ab = ab
|
||||||
|
trace.Entity.aa = aa
|
||||||
|
trace.Entity.b = 1
|
||||||
|
trace.Entity.br = br
|
||||||
|
trace.Entity.bg = bg
|
||||||
|
trace.Entity.bb = bb
|
||||||
|
trace.Entity.ba = ba
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( !self:GetSWEP():CheckLimit( "wire_indicators" ) ) then return false end
|
||||||
|
|
||||||
|
if (not util.IsValidModel(model)) then return false end
|
||||||
|
if (not util.IsValidProp(model)) then return false end -- Allow ragdolls to be used?
|
||||||
|
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
|
||||||
|
local wire_indicators = MakeWire7Seg( ply, model, Ang, trace.HitPos, trace.HitNormal, 0, ar, ag, ab, aa, 1, br, bg, bb, ba )
|
||||||
|
|
||||||
|
undo.Create("Wire7Seg")
|
||||||
|
for x=1, 7 do
|
||||||
|
--make welds
|
||||||
|
local const = WireLib.Weld(wire_indicators[x], trace.Entity, trace.PhysicsBone, true, false, worldweld)
|
||||||
|
undo.AddEntity( wire_indicators[x] )
|
||||||
|
undo.AddEntity( const )
|
||||||
|
ply:AddCleanup( "wire_indicators", wire_indicators[x] )
|
||||||
|
ply:AddCleanup( "wire_indicators", const)
|
||||||
|
end
|
||||||
|
undo.SetPlayer( ply )
|
||||||
|
undo.Finish()
|
||||||
|
|
||||||
|
return true --return true so leftclick helper skips making undo/cleanup/weld
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeIndicator( self, trace, ply )
|
||||||
|
|
||||||
|
local noclip = self:GetClientNumber( "noclip" ) == 1
|
||||||
|
local model = self:GetClientInfo( "model" )
|
||||||
|
local a = self:GetClientNumber("a")
|
||||||
|
local ar = math.min(self:GetClientNumber("ar"), 255)
|
||||||
|
local ag = math.min(self:GetClientNumber("ag"), 255)
|
||||||
|
local ab = math.min(self:GetClientNumber("ab"), 255)
|
||||||
|
local aa = math.min(self:GetClientNumber("aa"), 255)
|
||||||
|
local b = self:GetClientNumber("b")
|
||||||
|
local br = math.min(self:GetClientNumber("br"), 255)
|
||||||
|
local bg = math.min(self:GetClientNumber("bg"), 255)
|
||||||
|
local bb = math.min(self:GetClientNumber("bb"), 255)
|
||||||
|
local ba = math.min(self:GetClientNumber("ba"), 255)
|
||||||
|
local material = self:GetClientInfo( "material" )
|
||||||
|
|
||||||
|
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_indicator" && trace.Entity.pl == ply ) then
|
||||||
|
trace.Entity:Setup(a, ar, ag, ab, aa, b, br, bg, bb, ba)
|
||||||
|
trace.Entity:SetMaterial( material )
|
||||||
|
trace.Entity.a = a
|
||||||
|
trace.Entity.ar = ar
|
||||||
|
trace.Entity.ag = ag
|
||||||
|
trace.Entity.ab = ab
|
||||||
|
trace.Entity.aa = aa
|
||||||
|
trace.Entity.b = b
|
||||||
|
trace.Entity.br = br
|
||||||
|
trace.Entity.bg = bg
|
||||||
|
trace.Entity.bb = bb
|
||||||
|
trace.Entity.ba = ba
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( !self:GetSWEP():CheckLimit( "wire_indicators" ) ) then return false end
|
||||||
|
|
||||||
|
if (not util.IsValidModel(model)) then return false end
|
||||||
|
if (not util.IsValidProp(model)) then return false end -- Allow ragdolls to be used?
|
||||||
|
|
||||||
|
local Ang = self:GetGhostAngle(trace.HitNormal:Angle())
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
|
||||||
|
local wire_indicator = MakeWireIndicator( ply, model, Ang, trace.HitPos, a, ar, ag, ab, aa, b, br, bg, bb, ba, material, noclip )
|
||||||
|
|
||||||
|
local min = wire_indicator:OBBMins()
|
||||||
|
wire_indicator:SetPos( trace.HitPos - trace.HitNormal * self:GetGhostMin(min) )
|
||||||
|
|
||||||
|
return wire_indicator
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeConsoleScreen( self, trace, ply )
|
||||||
|
|
||||||
|
if ( !self:GetSWEP():CheckLimit( "wire_consolescreens" ) ) then return false end
|
||||||
|
|
||||||
|
local model = self:GetClientInfo( "model" )
|
||||||
|
|
||||||
|
if (not util.IsValidModel(model)) then return false end
|
||||||
|
if (not util.IsValidProp(model)) then return false end
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
|
||||||
|
local wire_consolescreen = MakeWireconsoleScreen( ply, Ang, trace.HitPos, model )
|
||||||
|
local min = wire_consolescreen:OBBMins()
|
||||||
|
wire_consolescreen:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
||||||
|
|
||||||
|
return wire_consolescreen
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeDigitalScreen( self, trace, ply )
|
||||||
|
|
||||||
|
if ( !self:GetSWEP():CheckLimit( "wire_digitalscreens" ) ) then return false end
|
||||||
|
|
||||||
|
local model = self:GetClientInfo( "model" )
|
||||||
|
|
||||||
|
if (not util.IsValidModel(model)) then return false end
|
||||||
|
if (not util.IsValidProp(model)) then return false end
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
|
||||||
|
local wire_digitalscreen = MakeWireDigitalScreen( ply, Ang, trace.HitPos, model )
|
||||||
|
local min = wire_digitalscreen:OBBMins()
|
||||||
|
wire_digitalscreen:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
||||||
|
|
||||||
|
return wire_digitalscreen
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeLamp( self, trace, ply )
|
||||||
|
|
||||||
|
local pos, ang = trace.HitPos + trace.HitNormal * 10, trace.HitNormal:Angle() - Angle( 90, 0, 0 )
|
||||||
|
|
||||||
|
local r = math.Clamp( self:GetClientNumber( "r" ), 0, 255 )
|
||||||
|
local g = math.Clamp( self:GetClientNumber( "g" ), 0, 255 )
|
||||||
|
local b = math.Clamp( self:GetClientNumber( "b" ), 0, 255 )
|
||||||
|
local const = self:GetClientInfo( "const" )
|
||||||
|
|
||||||
|
if trace.Entity:IsValid() and
|
||||||
|
trace.Entity:GetClass() == "gmod_wire_lamp" and
|
||||||
|
trace.Entity:GetPlayer() == ply
|
||||||
|
then
|
||||||
|
trace.Entity:SetLightColor( r, g, b )
|
||||||
|
trace.Entity.r = r
|
||||||
|
trace.Entity.g = g
|
||||||
|
trace.Entity.b = b
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( !self:GetSWEP():CheckLimit( "wire_lamps" ) ) then return false end
|
||||||
|
|
||||||
|
local wire_lamp = MakeWireLamp( ply, pos, ang, r, g, b )
|
||||||
|
|
||||||
|
ply:AddCleanup( "gmod_wire_lamp", wire_lamp )
|
||||||
|
|
||||||
|
if (const == "weld") then
|
||||||
|
|
||||||
|
return wire_lamp --helper left click will handel weld
|
||||||
|
|
||||||
|
elseif (const == "rope") then
|
||||||
|
|
||||||
|
local length = self:GetClientNumber( "ropelength" )
|
||||||
|
local material = self:GetClientInfo( "ropematerial" )
|
||||||
|
|
||||||
|
local LPos1 = Vector( 0, 0, 5 )
|
||||||
|
local LPos2 = trace.Entity:WorldToLocal( trace.HitPos )
|
||||||
|
|
||||||
|
if (trace.Entity:IsValid()) then
|
||||||
|
local phys = trace.Entity:GetPhysicsObjectNum( trace.PhysicsBone )
|
||||||
|
if (phys:IsValid()) then
|
||||||
|
LPos2 = phys:WorldToLocal( trace.HitPos )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local constraint, rope = constraint.Rope( wire_lamp, trace.Entity,
|
||||||
|
0, trace.PhysicsBone,
|
||||||
|
LPos1, LPos2,
|
||||||
|
0, length,
|
||||||
|
0,
|
||||||
|
1.5,
|
||||||
|
material,
|
||||||
|
nil )
|
||||||
|
|
||||||
|
undo.Create("gmod_wire_lamp")
|
||||||
|
undo.AddEntity( wire_lamp )
|
||||||
|
undo.AddEntity( rope )
|
||||||
|
undo.AddEntity( constraint )
|
||||||
|
undo.SetPlayer( ply )
|
||||||
|
undo.Finish()
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
else --none
|
||||||
|
|
||||||
|
undo.Create("gmod_wire_lamp")
|
||||||
|
undo.AddEntity( wire_lamp )
|
||||||
|
undo.SetPlayer( ply )
|
||||||
|
undo.Finish()
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeLight( self, trace, ply )
|
||||||
|
|
||||||
|
local directional = (self:GetClientNumber("directional") ~= 0)
|
||||||
|
local radiant = (self:GetClientNumber("radiant") ~= 0)
|
||||||
|
|
||||||
|
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_light" && trace.Entity.pl == ply ) then
|
||||||
|
trace.Entity:Setup(directional, radiant)
|
||||||
|
trace.Entity.directional = directional
|
||||||
|
trace.Entity.radiant = radiant
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( !self:GetSWEP():CheckLimit( "wire_lights" ) ) then return false end
|
||||||
|
|
||||||
|
if (not util.IsValidModel(self.Model)) then return false end
|
||||||
|
if (not util.IsValidProp(self.Model)) then return false end // Allow ragdolls to be used?
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
|
||||||
|
local wire_light = MakeWireLight( ply, Ang, trace.HitPos, directional, radiant )
|
||||||
|
|
||||||
|
local min = wire_light:OBBMins()
|
||||||
|
wire_light:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
||||||
|
|
||||||
|
return wire_light
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeOscilloscope( self, trace, ply )
|
||||||
|
|
||||||
|
local model = self:GetClientInfo( "model" )
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
|
||||||
|
local wire_oscilloscope = MakeWireOscilloscope( ply, Ang, trace.HitPos, model )
|
||||||
|
|
||||||
|
local min = wire_oscilloscope:OBBMins()
|
||||||
|
wire_oscilloscope:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
||||||
|
|
||||||
|
return wire_oscilloscope
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakePanel( self, trace, ply )
|
||||||
|
|
||||||
|
local model = self:GetClientInfo( "model" )
|
||||||
|
local CreateFlat = self:GetClientNumber( "createflat" )
|
||||||
|
local weld = self:GetClientNumber( "createflat" ) == 1
|
||||||
|
|
||||||
|
if (not util.IsValidModel(model)) then return false end
|
||||||
|
if (not util.IsValidProp(model)) then return false end
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
if (CreateFlat == 0) then --Weld panel flat to surface shot instead of perpendicular to it? (TheApathetic)
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
end
|
||||||
|
|
||||||
|
local wire_panel = MakeWirePanel( ply, Ang, trace.HitPos, model )
|
||||||
|
|
||||||
|
local min = wire_panel:OBBMins()
|
||||||
|
wire_panel:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
||||||
|
|
||||||
|
return wire_panel
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakePixel( self, trace, ply )
|
||||||
|
|
||||||
|
local nocollide = self:GetClientNumber( "noclip" ) == 1
|
||||||
|
local model = self:GetClientInfo( "model" )
|
||||||
|
|
||||||
|
if (not util.IsValidModel(model)) then return false end
|
||||||
|
if (not util.IsValidProp(model)) then return false end
|
||||||
|
|
||||||
|
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_pixel" && trace.Entity:GetTable().pl == ply ) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( !self:GetSWEP():CheckLimit( "wire_pixels" ) ) then return false end
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
|
||||||
|
local wire_pixel = MakeWirePixel( ply, Ang, trace.HitPos, model, nocollide )
|
||||||
|
|
||||||
|
local min = wire_pixel:OBBMins()
|
||||||
|
wire_pixel:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
||||||
|
|
||||||
|
return wire_pixel
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeScreen( self, trace, ply )
|
||||||
|
|
||||||
|
local Smodel = self:GetClientInfo( "model" )
|
||||||
|
|
||||||
|
if (not util.IsValidModel(Smodel)) then return false end
|
||||||
|
if (not util.IsValidProp(Smodel)) then return false end
|
||||||
|
|
||||||
|
// Extra stuff for Wire Screen (TheApathetic)
|
||||||
|
local SingleValue = self:GetClientNumber("singlevalue") == 1
|
||||||
|
local SingleBigFont = self:GetClientNumber("singlebigfont") == 1
|
||||||
|
local TextA = self:GetClientInfo("texta")
|
||||||
|
local TextB = self:GetClientInfo("textb")
|
||||||
|
local LeftAlign = self:GetClientNumber("leftalign") == 1
|
||||||
|
local Floor = self:GetClientNumber("floor") == 1
|
||||||
|
local CreateFlat = self:GetClientNumber("createflat")
|
||||||
|
|
||||||
|
if (trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_screen" && trace.Entity.pl == ply) then
|
||||||
|
trace.Entity:Setup(SingleValue, SingleBigFont, TextA, TextB, LeftAlign, Floor)
|
||||||
|
|
||||||
|
trace.Entity.SingleValue = SingleValue
|
||||||
|
trace.Entity.SingleBigFont = SingleBigFont
|
||||||
|
trace.Entity.TextA = TextA
|
||||||
|
trace.Entity.TextB = TextB
|
||||||
|
trace.Entity.LeftAlign = LeftAlign
|
||||||
|
trace.Entity.Floor = Floor
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
if (CreateFlat == 0) then --Make screens spawn flat on props instead of perpendicular to them (TheApathetic)
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
end
|
||||||
|
|
||||||
|
local wire_screen = MakeWireScreen( ply, Ang, trace.HitPos, Smodel, SingleValue, SingleBigFont, TextA, TextB, LeftAlign, Floor )
|
||||||
|
|
||||||
|
local min = wire_screen:OBBMins()
|
||||||
|
wire_screen:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
||||||
|
|
||||||
|
return wire_screen
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeSoundEmitter( self, trace, ply )
|
||||||
|
|
||||||
|
local sound = Sound( self:GetClientInfo( "sound" ) )
|
||||||
|
local collision = (self:GetClientInfo( "collision" ) ~= 0)
|
||||||
|
local model = self:GetClientInfo( "model" )
|
||||||
|
|
||||||
|
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_soundemitter" && trace.Entity.pl == ply ) then
|
||||||
|
trace.Entity:SetSound( Sound(sound) )
|
||||||
|
trace.Entity.sound = sound
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( !self:GetSWEP():CheckLimit( "wire_emitters" ) ) then return false end
|
||||||
|
|
||||||
|
if (not util.IsValidModel(model)) then return false end
|
||||||
|
if (not util.IsValidProp(model)) then return false end
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
|
||||||
|
local wire_emitter = MakeWireEmitter( ply, model, Ang, trace.HitPos, sound )
|
||||||
|
|
||||||
|
local min = wire_emitter:OBBMins()
|
||||||
|
wire_emitter:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
||||||
|
|
||||||
|
return wire_emitter
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeTextScreen( self, trace, ply )
|
||||||
|
|
||||||
|
if ( !self:GetSWEP():CheckLimit( "wire_textscreens" ) ) then return false end
|
||||||
|
|
||||||
|
local Smodel = self.Model
|
||||||
|
if (not util.IsValidModel(Smodel)) then return false end
|
||||||
|
if (not util.IsValidProp(Smodel)) then return false end
|
||||||
|
|
||||||
|
local TextList = {}
|
||||||
|
for i = 1, 12 do
|
||||||
|
TextList[i] = self:GetClientInfo("text"..i)
|
||||||
|
end
|
||||||
|
local chrPerLine = 16 - tonumber(self:GetClientInfo("tsize"))
|
||||||
|
local textJust = self:GetClientInfo("tjust")
|
||||||
|
local tRed = math.min(self:GetClientNumber("tred"), 255)
|
||||||
|
local tGreen = math.min(self:GetClientNumber("tgreen"), 255)
|
||||||
|
local tBlue = math.min(self:GetClientNumber("tblue"), 255)
|
||||||
|
|
||||||
|
local numInputs = self:GetClientNumber("ninputs")
|
||||||
|
local CreateFlat = self:GetClientNumber("createflat")
|
||||||
|
local defaultOn = self:GetClientNumber("defaulton")
|
||||||
|
|
||||||
|
if (trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_textscreen" && trace.Entity.pl == ply) then
|
||||||
|
trace.Entity:Setup(TextList, chrPerLine, textJust, tRed, tGreen, tBlue, numInputs, defaultOn)
|
||||||
|
trace.Entity.TextList = TextList
|
||||||
|
trace.Entity.chrPerLine = chrPerLine
|
||||||
|
trace.Entity.textJust = textJust
|
||||||
|
trace.Entity.tRed = tRed
|
||||||
|
trace.Entity.tGreen = tGreen
|
||||||
|
trace.Entity.tBlue = tBlue
|
||||||
|
trace.Entity.numInputs = numInputs
|
||||||
|
trace.Entity.defaultOn = defaultOn
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
if (CreateFlat == 0) then
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
end
|
||||||
|
|
||||||
|
local wire_textscreen = MakeWireTextScreen( ply, Ang, trace.HitPos, Model(self.Model), TextList, chrPerLine, textJust, tRed, tGreen, tBlue, numInputs, defaultOn)
|
||||||
|
|
||||||
|
local min = wire_textscreen:OBBMins()
|
||||||
|
wire_textscreen:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
||||||
|
|
||||||
|
return wire_textscreen
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeEmitter( self, tr, pl )
|
||||||
|
|
||||||
|
local r = self:GetClientNumber( "r" );
|
||||||
|
local g = self:GetClientNumber( "g" );
|
||||||
|
local b = self:GetClientNumber( "b" );
|
||||||
|
local a = self:GetClientNumber( "a" );
|
||||||
|
local size = self:GetClientNumber( "size" );
|
||||||
|
local showbeams = util.tobool( self:GetClientNumber( "showbeams" ) );
|
||||||
|
|
||||||
|
// did we hit another holoemitter?
|
||||||
|
if( tr.HitNonWorld && tr.Entity:GetClass() == "gmod_wire_holoemitter" ) then
|
||||||
|
// update it.
|
||||||
|
tr.Entity:SetColor( r, g, b, a );
|
||||||
|
|
||||||
|
// update size and show states
|
||||||
|
tr.Entity:SetNetworkedBool( "ShowBeam", showbeams );
|
||||||
|
tr.Entity:SetNetworkedFloat( "PointSize", size );
|
||||||
|
|
||||||
|
tr.Entity.r = r
|
||||||
|
tr.Entity.g = g
|
||||||
|
tr.Entity.b = b
|
||||||
|
tr.Entity.a = a
|
||||||
|
tr.Entity.showbeams = showbeams
|
||||||
|
tr.Entity.size = size
|
||||||
|
|
||||||
|
return true;
|
||||||
|
end
|
||||||
|
|
||||||
|
// we linking?
|
||||||
|
if( tr.HitNonWorld && tr.Entity:IsValid() && tr.Entity:GetClass() == "gmod_wire_hologrid" ) then
|
||||||
|
// link to this point.
|
||||||
|
if( self.Emitter && self.Emitter:IsValid() ) then
|
||||||
|
// link.
|
||||||
|
self.Emitter:LinkToGrid( tr.Entity );
|
||||||
|
|
||||||
|
// reset selected emitter
|
||||||
|
self.Emitter = nil;
|
||||||
|
|
||||||
|
//
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
// prevent effects
|
||||||
|
return false;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
// create a holo emitter.
|
||||||
|
if( !self:GetSWEP():CheckLimit( "wire_holoemitters" ) ) then return false; end
|
||||||
|
|
||||||
|
// fix angle
|
||||||
|
local ang = tr.HitNormal:Angle();
|
||||||
|
ang.pitch = ang.pitch + 90;
|
||||||
|
|
||||||
|
// create emitter
|
||||||
|
local emitter = MakeWireHoloemitter( pl, tr.HitPos, ang, r, g, b, a, showbeams, size );
|
||||||
|
|
||||||
|
// pull it out of the spawn point
|
||||||
|
local mins = emitter:OBBMins();
|
||||||
|
emitter:SetPos( tr.HitPos - tr.HitNormal * mins.z );
|
||||||
|
|
||||||
|
return emitter
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeHoloGrid( self, tr, pl )
|
||||||
|
|
||||||
|
if( !self:GetSWEP():CheckLimit( "wire_hologrids" ) ) then return false end
|
||||||
|
|
||||||
|
local pl = self:GetOwner()
|
||||||
|
|
||||||
|
local ang = tr.HitNormal:Angle()
|
||||||
|
ang.p = ang.p + 90
|
||||||
|
|
||||||
|
local grid = MakeWireHologrid( pl, tr.HitPos, ang )
|
||||||
|
|
||||||
|
local mins = grid:OBBMins()
|
||||||
|
grid:SetPos( tr.HitPos - tr.HitNormal * mins.z )
|
||||||
|
|
||||||
|
return grid
|
||||||
|
end
|
82
wire/lua/wire/stools/sv_io.lua
Normal file
82
wire/lua/wire/stools/sv_io.lua
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
|
||||||
|
function WireToolMakeAdvInput( self, trace, ply )
|
||||||
|
|
||||||
|
local _keymore = self:GetClientNumber( "keymore" )
|
||||||
|
local _keyless = self:GetClientNumber( "keyless" )
|
||||||
|
local _toggle = self:GetClientNumber( "toggle" )
|
||||||
|
local _value_min = self:GetClientNumber( "value_min" )
|
||||||
|
local _value_max = self:GetClientNumber( "value_max" )
|
||||||
|
local _value_start = self:GetClientNumber( "value_start" )
|
||||||
|
local _speed = self:GetClientNumber( "speed" )
|
||||||
|
|
||||||
|
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_adv_input" && trace.Entity.pl == ply ) then
|
||||||
|
trace.Entity:Setup( _keymore, _keyless, _toggle, _value_min, _value_max, _value_start, _speed )
|
||||||
|
trace.Entity.keymore = _keymore
|
||||||
|
trace.Entity.keyless = _keyless
|
||||||
|
trace.Entity.toggle = _toggle
|
||||||
|
trace.Entity.value_min = _value_min
|
||||||
|
trace.Entity.value_max = _value_max
|
||||||
|
trace.Entity.value_start = _value_start
|
||||||
|
trace.Entity.speed = _speed
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( !self:GetSWEP():CheckLimit( "wire_adv_inputs" ) ) then return false end
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
|
||||||
|
local wire_adv_input = MakeWireAdvInput( ply, trace.HitPos, Ang, _keymore, _keyless, _toggle, _value_min, _value_max, _value_start, _speed )
|
||||||
|
|
||||||
|
local min = wire_adv_input:OBBMins()
|
||||||
|
wire_adv_input:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
||||||
|
|
||||||
|
return wire_adv_input
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeAdvPod( self, trace, ply )
|
||||||
|
|
||||||
|
if not self:GetSWEP():CheckLimit("wire_pods") then return false end
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
|
||||||
|
local wire_pod = MakeWireAdvPod(ply, trace.HitPos, Ang)
|
||||||
|
|
||||||
|
wire_pod:SetPos(trace.HitPos - trace.HitNormal * wire_pod:OBBMins().z)
|
||||||
|
|
||||||
|
return wire_pod
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function WireToolMakeButton( self, trace, ply )
|
||||||
|
|
||||||
|
local _model = self:GetClientInfo( "model" )
|
||||||
|
local _toggle = (self:GetClientNumber( "toggle" ) ~= 0)
|
||||||
|
local _value_off = self:GetClientNumber( "value_off" )
|
||||||
|
local _value_on = self:GetClientNumber( "value_on" )
|
||||||
|
local _description = self:GetClientInfo( "description" )
|
||||||
|
|
||||||
|
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_button" && trace.Entity.pl == ply ) then
|
||||||
|
trace.Entity:Setup(_toggle, _value_off, _value_on)
|
||||||
|
trace.Entity.toggle = _toggle
|
||||||
|
trace.Entity.value_off = _value_off
|
||||||
|
trace.Entity.value_on = _value_on
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( !self:GetSWEP():CheckLimit( "wire_buttons" ) ) then return false end
|
||||||
|
|
||||||
|
local Ang = trace.HitNormal:Angle()
|
||||||
|
Ang.pitch = Ang.pitch + 90
|
||||||
|
|
||||||
|
local wire_button = MakeWireButton( ply, _model, trace.HitPos, Ang, _toggle, _value_off, _value_on, _description )
|
||||||
|
|
||||||
|
local min = wire_button:OBBMins()
|
||||||
|
wire_button:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
||||||
|
|
||||||
|
return wire_button
|
||||||
|
end
|
||||||
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
--[[
|
--[[
|
||||||
This is stool code,
|
This is stool code,
|
||||||
These are used by the Wired tools' LeftClick to make/update an ent,
|
These are used by the Wired tools' LeftClick to make/update ents,
|
||||||
the part after trace check and before welding/undo/cleanup creation.
|
the part after trace check and before welding/undo/cleanup creation.
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
@ -42,520 +42,5 @@ function WireToolMakeGate( self, trace, ply )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function WireToolMake7Seg( self, trace, ply )
|
include( "sv_display.lua" )
|
||||||
|
include( "sv_io.lua" )
|
||||||
local model = self:GetClientInfo( "model" )
|
|
||||||
local ar = math.min(self:GetClientNumber("ar"), 255)
|
|
||||||
local ag = math.min(self:GetClientNumber("ag"), 255)
|
|
||||||
local ab = math.min(self:GetClientNumber("ab"), 255)
|
|
||||||
local aa = math.min(self:GetClientNumber("aa"), 255)
|
|
||||||
local br = math.min(self:GetClientNumber("br"), 255)
|
|
||||||
local bg = math.min(self:GetClientNumber("bg"), 255)
|
|
||||||
local bb = math.min(self:GetClientNumber("bb"), 255)
|
|
||||||
local ba = math.min(self:GetClientNumber("ba"), 255)
|
|
||||||
local worldweld = self:GetClientNumber("worldweld") == 1
|
|
||||||
|
|
||||||
-- If we shot a wire_indicator change its force
|
|
||||||
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_indicator" && trace.Entity.pl == ply ) then
|
|
||||||
trace.Entity:Setup(0, ar, ag, ab, aa, 1, br, bg, bb, ba)
|
|
||||||
trace.Entity.a = 0
|
|
||||||
trace.Entity.ar = ar
|
|
||||||
trace.Entity.ag = ag
|
|
||||||
trace.Entity.ab = ab
|
|
||||||
trace.Entity.aa = aa
|
|
||||||
trace.Entity.b = 1
|
|
||||||
trace.Entity.br = br
|
|
||||||
trace.Entity.bg = bg
|
|
||||||
trace.Entity.bb = bb
|
|
||||||
trace.Entity.ba = ba
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if ( !self:GetSWEP():CheckLimit( "wire_indicators" ) ) then return false end
|
|
||||||
|
|
||||||
if (not util.IsValidModel(model)) then return false end
|
|
||||||
if (not util.IsValidProp(model)) then return false end -- Allow ragdolls to be used?
|
|
||||||
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local wire_indicators = MakeWire7Seg( ply, model, Ang, trace.HitPos, trace.HitNormal, 0, ar, ag, ab, aa, 1, br, bg, bb, ba )
|
|
||||||
|
|
||||||
undo.Create("Wire7Seg")
|
|
||||||
for x=1, 7 do
|
|
||||||
--make welds
|
|
||||||
local const = WireLib.Weld(wire_indicators[x], trace.Entity, trace.PhysicsBone, true, false, worldweld)
|
|
||||||
undo.AddEntity( wire_indicators[x] )
|
|
||||||
undo.AddEntity( const )
|
|
||||||
ply:AddCleanup( "wire_indicators", wire_indicators[x] )
|
|
||||||
ply:AddCleanup( "wire_indicators", const)
|
|
||||||
end
|
|
||||||
undo.SetPlayer( ply )
|
|
||||||
undo.Finish()
|
|
||||||
|
|
||||||
return true --return true so leftclick helper skips making undo/cleanup/weld
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakeIndicator( self, trace, ply )
|
|
||||||
|
|
||||||
local noclip = self:GetClientNumber( "noclip" ) == 1
|
|
||||||
local model = self:GetClientInfo( "model" )
|
|
||||||
local a = self:GetClientNumber("a")
|
|
||||||
local ar = math.min(self:GetClientNumber("ar"), 255)
|
|
||||||
local ag = math.min(self:GetClientNumber("ag"), 255)
|
|
||||||
local ab = math.min(self:GetClientNumber("ab"), 255)
|
|
||||||
local aa = math.min(self:GetClientNumber("aa"), 255)
|
|
||||||
local b = self:GetClientNumber("b")
|
|
||||||
local br = math.min(self:GetClientNumber("br"), 255)
|
|
||||||
local bg = math.min(self:GetClientNumber("bg"), 255)
|
|
||||||
local bb = math.min(self:GetClientNumber("bb"), 255)
|
|
||||||
local ba = math.min(self:GetClientNumber("ba"), 255)
|
|
||||||
local material = self:GetClientInfo( "material" )
|
|
||||||
|
|
||||||
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_indicator" && trace.Entity.pl == ply ) then
|
|
||||||
trace.Entity:Setup(a, ar, ag, ab, aa, b, br, bg, bb, ba)
|
|
||||||
trace.Entity:SetMaterial( material )
|
|
||||||
trace.Entity.a = a
|
|
||||||
trace.Entity.ar = ar
|
|
||||||
trace.Entity.ag = ag
|
|
||||||
trace.Entity.ab = ab
|
|
||||||
trace.Entity.aa = aa
|
|
||||||
trace.Entity.b = b
|
|
||||||
trace.Entity.br = br
|
|
||||||
trace.Entity.bg = bg
|
|
||||||
trace.Entity.bb = bb
|
|
||||||
trace.Entity.ba = ba
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if ( !self:GetSWEP():CheckLimit( "wire_indicators" ) ) then return false end
|
|
||||||
|
|
||||||
if (not util.IsValidModel(model)) then return false end
|
|
||||||
if (not util.IsValidProp(model)) then return false end -- Allow ragdolls to be used?
|
|
||||||
|
|
||||||
local Ang = self:GetGhostAngle(trace.HitNormal:Angle())
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local wire_indicator = MakeWireIndicator( ply, model, Ang, trace.HitPos, a, ar, ag, ab, aa, b, br, bg, bb, ba, material, noclip )
|
|
||||||
|
|
||||||
local min = wire_indicator:OBBMins()
|
|
||||||
wire_indicator:SetPos( trace.HitPos - trace.HitNormal * self:GetGhostMin(min) )
|
|
||||||
|
|
||||||
return wire_indicator
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakeConsoleScreen( self, trace, ply )
|
|
||||||
|
|
||||||
if ( !self:GetSWEP():CheckLimit( "wire_consolescreens" ) ) then return false end
|
|
||||||
|
|
||||||
local model = self:GetClientInfo( "model" )
|
|
||||||
|
|
||||||
if (not util.IsValidModel(model)) then return false end
|
|
||||||
if (not util.IsValidProp(model)) then return false end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local wire_consolescreen = MakeWireconsoleScreen( ply, Ang, trace.HitPos, model )
|
|
||||||
local min = wire_consolescreen:OBBMins()
|
|
||||||
wire_consolescreen:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
|
|
||||||
return wire_consolescreen
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakeDigitalScreen( self, trace, ply )
|
|
||||||
|
|
||||||
if ( !self:GetSWEP():CheckLimit( "wire_digitalscreens" ) ) then return false end
|
|
||||||
|
|
||||||
local model = self:GetClientInfo( "model" )
|
|
||||||
|
|
||||||
if (not util.IsValidModel(model)) then return false end
|
|
||||||
if (not util.IsValidProp(model)) then return false end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local wire_digitalscreen = MakeWireDigitalScreen( ply, Ang, trace.HitPos, model )
|
|
||||||
local min = wire_digitalscreen:OBBMins()
|
|
||||||
wire_digitalscreen:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
|
|
||||||
return wire_digitalscreen
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakeLamp( self, trace, ply )
|
|
||||||
|
|
||||||
local pos, ang = trace.HitPos + trace.HitNormal * 10, trace.HitNormal:Angle() - Angle( 90, 0, 0 )
|
|
||||||
|
|
||||||
local r = math.Clamp( self:GetClientNumber( "r" ), 0, 255 )
|
|
||||||
local g = math.Clamp( self:GetClientNumber( "g" ), 0, 255 )
|
|
||||||
local b = math.Clamp( self:GetClientNumber( "b" ), 0, 255 )
|
|
||||||
local const = self:GetClientInfo( "const" )
|
|
||||||
|
|
||||||
if trace.Entity:IsValid() and
|
|
||||||
trace.Entity:GetClass() == "gmod_wire_lamp" and
|
|
||||||
trace.Entity:GetPlayer() == ply
|
|
||||||
then
|
|
||||||
trace.Entity:SetLightColor( r, g, b )
|
|
||||||
trace.Entity.r = r
|
|
||||||
trace.Entity.g = g
|
|
||||||
trace.Entity.b = b
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if ( !self:GetSWEP():CheckLimit( "wire_lamps" ) ) then return false end
|
|
||||||
|
|
||||||
local wire_lamp = MakeWireLamp( ply, pos, ang, r, g, b )
|
|
||||||
|
|
||||||
ply:AddCleanup( "gmod_wire_lamp", wire_lamp )
|
|
||||||
|
|
||||||
if (const == "weld") then
|
|
||||||
|
|
||||||
return wire_lamp --helper left click will handel weld
|
|
||||||
|
|
||||||
elseif (const == "rope") then
|
|
||||||
|
|
||||||
local length = self:GetClientNumber( "ropelength" )
|
|
||||||
local material = self:GetClientInfo( "ropematerial" )
|
|
||||||
|
|
||||||
local LPos1 = Vector( 0, 0, 5 )
|
|
||||||
local LPos2 = trace.Entity:WorldToLocal( trace.HitPos )
|
|
||||||
|
|
||||||
if (trace.Entity:IsValid()) then
|
|
||||||
local phys = trace.Entity:GetPhysicsObjectNum( trace.PhysicsBone )
|
|
||||||
if (phys:IsValid()) then
|
|
||||||
LPos2 = phys:WorldToLocal( trace.HitPos )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local constraint, rope = constraint.Rope( wire_lamp, trace.Entity,
|
|
||||||
0, trace.PhysicsBone,
|
|
||||||
LPos1, LPos2,
|
|
||||||
0, length,
|
|
||||||
0,
|
|
||||||
1.5,
|
|
||||||
material,
|
|
||||||
nil )
|
|
||||||
|
|
||||||
undo.Create("gmod_wire_lamp")
|
|
||||||
undo.AddEntity( wire_lamp )
|
|
||||||
undo.AddEntity( rope )
|
|
||||||
undo.AddEntity( constraint )
|
|
||||||
undo.SetPlayer( ply )
|
|
||||||
undo.Finish()
|
|
||||||
|
|
||||||
return true
|
|
||||||
|
|
||||||
else --none
|
|
||||||
|
|
||||||
undo.Create("gmod_wire_lamp")
|
|
||||||
undo.AddEntity( wire_lamp )
|
|
||||||
undo.SetPlayer( ply )
|
|
||||||
undo.Finish()
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakeLight( self, trace, ply )
|
|
||||||
|
|
||||||
local directional = (self:GetClientNumber("directional") ~= 0)
|
|
||||||
local radiant = (self:GetClientNumber("radiant") ~= 0)
|
|
||||||
|
|
||||||
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_light" && trace.Entity.pl == ply ) then
|
|
||||||
trace.Entity:Setup(directional, radiant)
|
|
||||||
trace.Entity.directional = directional
|
|
||||||
trace.Entity.radiant = radiant
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if ( !self:GetSWEP():CheckLimit( "wire_lights" ) ) then return false end
|
|
||||||
|
|
||||||
if (not util.IsValidModel(self.Model)) then return false end
|
|
||||||
if (not util.IsValidProp(self.Model)) then return false end // Allow ragdolls to be used?
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local wire_light = MakeWireLight( ply, Ang, trace.HitPos, directional, radiant )
|
|
||||||
|
|
||||||
local min = wire_light:OBBMins()
|
|
||||||
wire_light:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
|
|
||||||
return wire_light
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakeOscilloscope( self, trace, ply )
|
|
||||||
|
|
||||||
local model = self:GetClientInfo( "model" )
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local wire_oscilloscope = MakeWireOscilloscope( ply, Ang, trace.HitPos, model )
|
|
||||||
|
|
||||||
local min = wire_oscilloscope:OBBMins()
|
|
||||||
wire_oscilloscope:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
|
|
||||||
return wire_oscilloscope
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakePanel( self, trace, ply )
|
|
||||||
|
|
||||||
local model = self:GetClientInfo( "model" )
|
|
||||||
local CreateFlat = self:GetClientNumber( "createflat" )
|
|
||||||
local weld = self:GetClientNumber( "createflat" ) == 1
|
|
||||||
|
|
||||||
if (not util.IsValidModel(model)) then return false end
|
|
||||||
if (not util.IsValidProp(model)) then return false end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
if (CreateFlat == 0) then --Weld panel flat to surface shot instead of perpendicular to it? (TheApathetic)
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
end
|
|
||||||
|
|
||||||
local wire_panel = MakeWirePanel( ply, Ang, trace.HitPos, model )
|
|
||||||
|
|
||||||
local min = wire_panel:OBBMins()
|
|
||||||
wire_panel:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
|
|
||||||
return wire_panel
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakePixel( self, trace, ply )
|
|
||||||
|
|
||||||
local nocollide = self:GetClientNumber( "noclip" ) == 1
|
|
||||||
local model = self:GetClientInfo( "model" )
|
|
||||||
|
|
||||||
if (not util.IsValidModel(model)) then return false end
|
|
||||||
if (not util.IsValidProp(model)) then return false end
|
|
||||||
|
|
||||||
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_pixel" && trace.Entity:GetTable().pl == ply ) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if ( !self:GetSWEP():CheckLimit( "wire_pixels" ) ) then return false end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local wire_pixel = MakeWirePixel( ply, Ang, trace.HitPos, model, nocollide )
|
|
||||||
|
|
||||||
local min = wire_pixel:OBBMins()
|
|
||||||
wire_pixel:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
|
|
||||||
return wire_pixel
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakeScreen( self, trace, ply )
|
|
||||||
|
|
||||||
local Smodel = self:GetClientInfo( "model" )
|
|
||||||
|
|
||||||
if (not util.IsValidModel(Smodel)) then return false end
|
|
||||||
if (not util.IsValidProp(Smodel)) then return false end
|
|
||||||
|
|
||||||
// Extra stuff for Wire Screen (TheApathetic)
|
|
||||||
local SingleValue = self:GetClientNumber("singlevalue") == 1
|
|
||||||
local SingleBigFont = self:GetClientNumber("singlebigfont") == 1
|
|
||||||
local TextA = self:GetClientInfo("texta")
|
|
||||||
local TextB = self:GetClientInfo("textb")
|
|
||||||
local LeftAlign = self:GetClientNumber("leftalign") == 1
|
|
||||||
local Floor = self:GetClientNumber("floor") == 1
|
|
||||||
local CreateFlat = self:GetClientNumber("createflat")
|
|
||||||
|
|
||||||
if (trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_screen" && trace.Entity.pl == ply) then
|
|
||||||
trace.Entity:Setup(SingleValue, SingleBigFont, TextA, TextB, LeftAlign, Floor)
|
|
||||||
|
|
||||||
trace.Entity.SingleValue = SingleValue
|
|
||||||
trace.Entity.SingleBigFont = SingleBigFont
|
|
||||||
trace.Entity.TextA = TextA
|
|
||||||
trace.Entity.TextB = TextB
|
|
||||||
trace.Entity.LeftAlign = LeftAlign
|
|
||||||
trace.Entity.Floor = Floor
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
if (CreateFlat == 0) then --Make screens spawn flat on props instead of perpendicular to them (TheApathetic)
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
end
|
|
||||||
|
|
||||||
local wire_screen = MakeWireScreen( ply, Ang, trace.HitPos, Smodel, SingleValue, SingleBigFont, TextA, TextB, LeftAlign, Floor )
|
|
||||||
|
|
||||||
local min = wire_screen:OBBMins()
|
|
||||||
wire_screen:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
|
|
||||||
return wire_screen
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakeSoundEmitter( self, trace, ply )
|
|
||||||
|
|
||||||
local sound = Sound( self:GetClientInfo( "sound" ) )
|
|
||||||
local collision = (self:GetClientInfo( "collision" ) ~= 0)
|
|
||||||
local model = self:GetClientInfo( "model" )
|
|
||||||
|
|
||||||
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_soundemitter" && trace.Entity.pl == ply ) then
|
|
||||||
trace.Entity:SetSound( Sound(sound) )
|
|
||||||
trace.Entity.sound = sound
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if ( !self:GetSWEP():CheckLimit( "wire_emitters" ) ) then return false end
|
|
||||||
|
|
||||||
if (not util.IsValidModel(model)) then return false end
|
|
||||||
if (not util.IsValidProp(model)) then return false end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
|
|
||||||
local wire_emitter = MakeWireEmitter( ply, model, Ang, trace.HitPos, sound )
|
|
||||||
|
|
||||||
local min = wire_emitter:OBBMins()
|
|
||||||
wire_emitter:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
|
|
||||||
return wire_emitter
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakeTextScreen( self, trace, ply )
|
|
||||||
|
|
||||||
if ( !self:GetSWEP():CheckLimit( "wire_textscreens" ) ) then return false end
|
|
||||||
|
|
||||||
local Smodel = self.Model
|
|
||||||
if (not util.IsValidModel(Smodel)) then return false end
|
|
||||||
if (not util.IsValidProp(Smodel)) then return false end
|
|
||||||
|
|
||||||
local TextList = {}
|
|
||||||
for i = 1, 12 do
|
|
||||||
TextList[i] = self:GetClientInfo("text"..i)
|
|
||||||
end
|
|
||||||
local chrPerLine = 16 - tonumber(self:GetClientInfo("tsize"))
|
|
||||||
local textJust = self:GetClientInfo("tjust")
|
|
||||||
local tRed = math.min(self:GetClientNumber("tred"), 255)
|
|
||||||
local tGreen = math.min(self:GetClientNumber("tgreen"), 255)
|
|
||||||
local tBlue = math.min(self:GetClientNumber("tblue"), 255)
|
|
||||||
|
|
||||||
local numInputs = self:GetClientNumber("ninputs")
|
|
||||||
local CreateFlat = self:GetClientNumber("createflat")
|
|
||||||
local defaultOn = self:GetClientNumber("defaulton")
|
|
||||||
|
|
||||||
if (trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_textscreen" && trace.Entity.pl == ply) then
|
|
||||||
trace.Entity:Setup(TextList, chrPerLine, textJust, tRed, tGreen, tBlue, numInputs, defaultOn)
|
|
||||||
trace.Entity.TextList = TextList
|
|
||||||
trace.Entity.chrPerLine = chrPerLine
|
|
||||||
trace.Entity.textJust = textJust
|
|
||||||
trace.Entity.tRed = tRed
|
|
||||||
trace.Entity.tGreen = tGreen
|
|
||||||
trace.Entity.tBlue = tBlue
|
|
||||||
trace.Entity.numInputs = numInputs
|
|
||||||
trace.Entity.defaultOn = defaultOn
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
local Ang = trace.HitNormal:Angle()
|
|
||||||
if (CreateFlat == 0) then
|
|
||||||
Ang.pitch = Ang.pitch + 90
|
|
||||||
end
|
|
||||||
|
|
||||||
local wire_textscreen = MakeWireTextScreen( ply, Ang, trace.HitPos, Model(self.Model), TextList, chrPerLine, textJust, tRed, tGreen, tBlue, numInputs, defaultOn)
|
|
||||||
|
|
||||||
local min = wire_textscreen:OBBMins()
|
|
||||||
wire_textscreen:SetPos( trace.HitPos - trace.HitNormal * min.z )
|
|
||||||
|
|
||||||
return wire_textscreen
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakeEmitter( self, tr, pl )
|
|
||||||
|
|
||||||
local r = self:GetClientNumber( "r" );
|
|
||||||
local g = self:GetClientNumber( "g" );
|
|
||||||
local b = self:GetClientNumber( "b" );
|
|
||||||
local a = self:GetClientNumber( "a" );
|
|
||||||
local size = self:GetClientNumber( "size" );
|
|
||||||
local showbeams = util.tobool( self:GetClientNumber( "showbeams" ) );
|
|
||||||
|
|
||||||
// did we hit another holoemitter?
|
|
||||||
if( tr.HitNonWorld && tr.Entity:GetClass() == "gmod_wire_holoemitter" ) then
|
|
||||||
// update it.
|
|
||||||
tr.Entity:SetColor( r, g, b, a );
|
|
||||||
|
|
||||||
// update size and show states
|
|
||||||
tr.Entity:SetNetworkedBool( "ShowBeam", showbeams );
|
|
||||||
tr.Entity:SetNetworkedFloat( "PointSize", size );
|
|
||||||
|
|
||||||
tr.Entity.r = r
|
|
||||||
tr.Entity.g = g
|
|
||||||
tr.Entity.b = b
|
|
||||||
tr.Entity.a = a
|
|
||||||
tr.Entity.showbeams = showbeams
|
|
||||||
tr.Entity.size = size
|
|
||||||
|
|
||||||
return true;
|
|
||||||
end
|
|
||||||
|
|
||||||
// we linking?
|
|
||||||
if( tr.HitNonWorld && tr.Entity:IsValid() && tr.Entity:GetClass() == "gmod_wire_hologrid" ) then
|
|
||||||
// link to this point.
|
|
||||||
if( self.Emitter && self.Emitter:IsValid() ) then
|
|
||||||
// link.
|
|
||||||
self.Emitter:LinkToGrid( tr.Entity );
|
|
||||||
|
|
||||||
// reset selected emitter
|
|
||||||
self.Emitter = nil;
|
|
||||||
|
|
||||||
//
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
// prevent effects
|
|
||||||
return false;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
// create a holo emitter.
|
|
||||||
if( !self:GetSWEP():CheckLimit( "wire_holoemitters" ) ) then return false; end
|
|
||||||
|
|
||||||
// fix angle
|
|
||||||
local ang = tr.HitNormal:Angle();
|
|
||||||
ang.pitch = ang.pitch + 90;
|
|
||||||
|
|
||||||
// create emitter
|
|
||||||
local emitter = MakeWireHoloemitter( pl, tr.HitPos, ang, r, g, b, a, showbeams, size );
|
|
||||||
|
|
||||||
// pull it out of the spawn point
|
|
||||||
local mins = emitter:OBBMins();
|
|
||||||
emitter:SetPos( tr.HitPos - tr.HitNormal * mins.z );
|
|
||||||
|
|
||||||
return emitter
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function WireToolMakeHoloGrid( self, tr, pl )
|
|
||||||
|
|
||||||
if( !self:GetSWEP():CheckLimit( "wire_hologrids" ) ) then return false end
|
|
||||||
|
|
||||||
local pl = self:GetOwner()
|
|
||||||
|
|
||||||
local ang = tr.HitNormal:Angle()
|
|
||||||
ang.p = ang.p + 90
|
|
||||||
|
|
||||||
local grid = MakeWireHologrid( pl, tr.HitPos, ang )
|
|
||||||
|
|
||||||
local mins = grid:OBBMins()
|
|
||||||
grid:SetPos( tr.HitPos - tr.HitNormal * mins.z )
|
|
||||||
|
|
||||||
return grid
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user