So far I've been working on a prop mirroring tool, to mirror whatever prop you click on across the x axis, but I've ran into a problem with the tool menu or whatever you call it. Basically, I wanted 3 check boxes that can turn Pitch/Yaw/Roll flipping on and off. I got the flipping sorted, but I'm totally lost on how to make the check boxes turn it on and off. The tutorial on the wiki does not help at all. Here's my code:
[lua]
TOOL.Category = "Construction"
TOOL.Name = "#Mirror Prop"
TOOL.Command = nil
TOOL.ConfigName = "" --Setting this means that you do not have to create external configuration files to define the layout of the tool config-hud
--ToDo: add, spawn prop nocollide all'd
--local Default="0"
--local Default1="0"
--local Default2="0"
TOOL.ClientConVar[ "Mirror_Mirror_Pitch" ] = 0
TOOL.ClientConVar[ "Mirror_Mirror_Yaw" ] = 0
TOOL.ClientConVar[ "Mirror_Mirror_Roll" ] = 0
if ( CLIENT ) then
language.Add( "Tool_mirror_name", "Mirror" )
language.Add( "Tool_mirror_desc", "Mirror Props Easily" )
language.Add( "Tool_mirror_0", "Click To Mirror The Prop You Are Pointing At Across The X Axis." )
language.Add( "Undone_mirror", "Undone Mirror" )
--CreateClientConVar("Mirror_Mirror_Pitch", Default , true, false)
--CreateClientConVar("Mirror_Mirror_Yaw", Default1 , true, false)
--CreateClientConVar("Mirror_Mirror_Roll", Default2 , true, false)
end
function TOOL:LeftClick( trace )
if ( trace.Entity:IsValid() ) then
if(!SERVER) then
return
end;
local Mirror_MirrorPitchServer = self:GetClientNumber( "Mirror_Mirror_Pitch" )
local Mirror_MirrorYawServer = self:GetClientNumber( "Mirror_Mirror_Yaw" )
local Mirror_MirrorRollServer = self:GetClientNumber( "Mirror_Mirror_Roll" )
print( "Variable Mirror_MirrorPitch is a: " ..type(Mirror_MirrorPitchServer).. " and set to: " ..Mirror_MirrorPitchServer..".")
print( "Variable Mirror_MirrorYaw is a: " ..type(Mirror_MirrorYawServer).. " and set to: " ..Mirror_MirrorYawServer..".")
print( "Variable Mirror_MirrorRoll is a: " ..type(Mirror_MirrorRollServer).. " and set to: " ..Mirror_MirrorRollServer..".")
print("Server Mirror_MirrorPitch "..Mirror_MirrorPitchServer..".")
print("Server Mirror_MirrorYaw "..Mirror_MirrorYawServer..".")
print("Server Mirror_MirrorRoll "..Mirror_MirrorRollServer..".")
local MP=0
local MY=0
local MR=0
if( Mirror_MirrorPitchServer == 1) then
MP = -1
print("MP = "..MP)
elseif ( Mirror_MirrorPitchServer == 0) then
MP = 1
print("MP = "..MP)
end
if( Mirror_MirrorYawServer == 1) then
MY = -1
elseif ( Mirror_MirrorYawServer == 0) then
MY = 1
end
if( Mirror_MirrorRollServer == 1) then
MR = -1
elseif ( Mirror_MirrorRollServer == 0) then
MR = 1
end
local TRE=trace.Entity
print("We hit an entity") --Will Be Deleted
local AVec=Vector(-1,1,1)
print(AVec) --Will Be Deleted
local EntPos=trace.Entity:GetPos()
print(EntPos) --Will Be Deleted
local TZP=EntPos:DotProduct(AVec)
print(TZP) --Will Be Deleted
local Prop=ents.Create("prop_physics")
Prop:SetModel(trace.Entity:GetModel())
Prop:PhysicsInit( SOLID_VPHYSICS ) -- Make us work with physics,
Prop:SetMoveType( MOVETYPE_VPHYSICS ) -- after all, gmod is a physics
Prop:SetSolid( SOLID_VPHYSICS ) -- Toolbox
Prop:SetPos(TZP)
Prop:Spawn()
local Pitch = TRE:GetAngles().p*MP
local Yaw = TRE:GetAngles().y*MY
local Roll = TRE:GetAngles().r*MR
Prop:SetAngles(Angle(Pitch,Yaw,Roll))
Prop:GetPhysicsObject():EnableMotion( false )
cleanup.Add(self.Owner, "props", Prop);
undo.Create("Mirrored Prop");
undo.AddEntity(Prop);
undo.SetPlayer(self.Owner);
undo.Finish();
end
end
function TOOL:RightClick( trace )
end
function TOOL.BuildCPanel(panel)
panel:AddControl("Header", { Text = "Mirror Tool", Description = "Mirror Props With This" })
panel:AddControl("CheckBox", {
Label = "Mirror Pitch",
MirrorPitch = "Mirror_Mirror_Pitch"
})
print(MirrorPitch)
panel:AddControl("CheckBox", {
Label = "Mirror Yaw",
MirrorYaw = "Mirror_Mirror_Yaw"
})
print(MirrorYaw)
panel:AddControl("CheckBox", {
Label = "Mirror Roll",
MirrorRoll = "Mirror_Mirror_Roll"
})
print(MirrorRoll)
end
[/lua]
Replace where you have, for example, MirrorPitch = "Mirror_Mirror_Pitch", with Command = "Mirror_Mirror_Pitch".
[QUOTE=_Undefined;19730544]Replace where you have, for example, MirrorPitch = "Mirror_Mirror_Pitch", with Command = "Mirror_Mirror_Pitch".[/QUOTE]
Yeah.
[lua]
TOOL.Category = "Construction"
TOOL.Name = "#Mirror Prop"
TOOL.Command = nil
TOOL.ConfigName = "" --Setting this means that you do not have to create external configuration files to define the layout of the tool config-hud
--ToDo: add, spawn prop nocollide all'd
--local Default="0"
--local Default1="0"
--local Default2="0"
TOOL.ClientConVar[ "Mirror_Mirror_Pitch" ] = 0
TOOL.ClientConVar[ "Mirror_Mirror_Yaw" ] = 0
TOOL.ClientConVar[ "Mirror_Mirror_Roll" ] = 0
if ( CLIENT ) then
language.Add( "Tool_mirror_name", "Mirror" )
language.Add( "Tool_mirror_desc", "Mirror Props Easily" )
language.Add( "Tool_mirror_0", "Click To Mirror The Prop You Are Pointing At Across The X Axis." )
language.Add( "Undone_mirror", "Undone Mirror" )
--CreateClientConVar("Mirror_Mirror_Pitch", Default , true, false)
--CreateClientConVar("Mirror_Mirror_Yaw", Default1 , true, false)
--CreateClientConVar("Mirror_Mirror_Roll", Default2 , true, false)
end
function TOOL:LeftClick( trace )
if ( trace.Entity:IsValid() ) then
if(CLIENT) then
print("Client Side: "..Mirror_Mirror_Pitch.." "..Mirror_Mirror_Yaw.." "..Mirror_Mirror_Roll)
end
if(!SERVER) then
return
end;
local Mirror_MirrorPitchServer = self:GetClientNumber( "Mirror_Mirror_Pitch" )
local Mirror_MirrorYawServer = self:GetClientNumber( "Mirror_Mirror_Yaw" )
local Mirror_MirrorRollServer = self:GetClientNumber( "Mirror_Mirror_Roll" )
print( "Variable Mirror_MirrorPitch is a: " ..type(Mirror_MirrorPitchServer).. " and set to: " ..Mirror_MirrorPitchServer..".")
print( "Variable Mirror_MirrorYaw is a: " ..type(Mirror_MirrorYawServer).. " and set to: " ..Mirror_MirrorYawServer..".")
print( "Variable Mirror_MirrorRoll is a: " ..type(Mirror_MirrorRollServer).. " and set to: " ..Mirror_MirrorRollServer..".")
print("Server Mirror_MirrorPitch "..Mirror_MirrorPitchServer..".")
print("Server Mirror_MirrorYaw "..Mirror_MirrorYawServer..".")
print("Server Mirror_MirrorRoll "..Mirror_MirrorRollServer..".")
local MP=0
local MY=0
local MR=0
if( Mirror_MirrorPitchServer == 1) then
MP = -1
print("MP = "..MP)
elseif ( Mirror_MirrorPitchServer == 0) then
MP = 1
print("MP = "..MP)
end
if( Mirror_MirrorYawServer == 1) then
MY = -1
print("MY = "..MY)
elseif ( Mirror_MirrorYawServer == 0) then
MY = 1
print("MY = "..MY)
end
if( Mirror_MirrorRollServer == 1) then
MR = -1
print("MR = "..MR)
elseif ( Mirror_MirrorRollServer == 0) then
MR = 1
print("MR = "..MR)
end
local TRE=trace.Entity
print("We hit an entity") --Will Be Deleted
local AVec=Vector(-1,1,1)
print(AVec) --Will Be Deleted
local EntPos=trace.Entity:GetPos()
print(EntPos) --Will Be Deleted
local TZP=Vector(EntPos.x*AVec.x,EntPos.y*AVec.y,EntPos.z*AVec.z)
print(TZP) --Will Be Deleted
local Prop=ents.Create("prop_physics")
Prop:SetModel(trace.Entity:GetModel())
Prop:PhysicsInit( SOLID_VPHYSICS ) -- Make us work with physics,
Prop:SetMoveType( MOVETYPE_VPHYSICS ) -- after all, gmod is a physics
Prop:SetSolid( SOLID_VPHYSICS ) -- Toolbox
Prop:SetPos(TZP)
Prop:Spawn()
local Pitch = TRE:GetAngles().p*MP
local Yaw = TRE:GetAngles().y*MY
local Roll = TRE:GetAngles().r*MR
Prop:SetAngles(Angle(Pitch,Yaw,Roll))
Prop:GetPhysicsObject():EnableMotion( false )
cleanup.Add(self.Owner, "props", Prop);
undo.Create("Mirrored Prop");
undo.AddEntity(Prop);
undo.SetPlayer(self.Owner);
undo.Finish();
end
end
function TOOL:RightClick( trace )
end
function TOOL.BuildCPanel(panel)
panel:AddControl("Header", { Text = "Mirror Tool", Description = "Mirror Props With This" })
panel:AddControl("CheckBox", {
Label = "Mirror Pitch?",
Command = "mirror_Mirror_Mirror_Pitch"
})
print(MirrorPitch)
panel:AddControl("CheckBox", {
Label = "Mirror Yaw?",
Command = "mirror_Mirror_Mirror_Yaw"
})
print(MirrorYaw)
panel:AddControl("CheckBox", {
Label = "Mirror Roll?",
Command = "mirror_Mirror_Mirror_Roll" -- looked at duplicator stool for this, apparently in duplicator the inner tool command or whatever is prefaced by the name of the tool's lua file.
})
print(MirrorRoll)
end
[/lua]
Nothing. Oh and I changed some other stuff.
Sorry, you need to Log In to post a reply to this thread.