updates in preparations for beta

changed deleteonremove to use new system in welds instead
massive updates to adv duplicator. now separate module and addon
include modified weight stool that support duplication
lots of other shit
This commit is contained in:
tad2020
2007-03-22 03:27:52 +00:00
parent 18addf9656
commit 19e831f08e
54 changed files with 247 additions and 3135 deletions

View File

@@ -1,11 +1,11 @@
"AddonInfo" "AddonInfo"
{ {
"name" "Wire" "name" "Wire"
"version" "0.9.5" "version" "0.9.6"
"up_date" "4th February 2007" "up_date" "24st March 2007"
"author_name" "Wire Team" "author_name" "Wire Team"
"author_email" "ErkleMad@gmail.com" "author_email" "ErkleMad@gmail.com"
"author_url" "http://www.gmodforge.com/projects/wire/" "author_url" "http://www.wiremod.com/"
"info" "A set of SEnts and STools that communicate through wires." "info" "A set of SEnts and STools that communicate through wires."
"override" "0" "override" "0"
} }

View File

@@ -1,252 +1 @@
if (CLIENT) then //this file left blank on purpose to overwrite existing file on upgrade
duplicatorclient={}
include( "autorun/shared/dupeshare.lua" )
function duplicatorclient.UpLoadFile( pl, filepath )
if (duplicatorclient.sending) then return end
if !file.Exists(filepath)then print("File not found") return end
local filename = dupeshare.GetFileFromFilename(filepath)
//load from file
local temp = file.Read(filepath)
//shitty string protection/compression
//duplicatorclient.temp2 = string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(temp,"\t\t\"__name\"\t\t","|mn"),"\t\t\"__type\"\t\t","|mt"),"\t\t\t\"V\"\t\t","|mv|"),"\t\t\t\"DupeInfo\"","|mD"),"\"Number\"\n","|mN"),"\"String\"\n","|mS"),"\"Angle\"\n","|mA"),"\"Vector\"\n","|mV"),"\"Bool\"\n","|mB"),"\"Class\"","|mC"),"\"material\"","|mm"),"\"prop_physics\"","|mp"),"\t\t\"VersionInfo\"\n\t\t\"FileVersion\"\n\t\t{\n","|VI"),"\"models","|wm"),"\n\t\t\t\"NoCollide\"\n\t\t\t{\n\t","|NC"),"\"nocollide\"\n","|nc"),"\"HeadEntID\"\n","|HE"),"\n\t}\n\t\"holdangle\"\n\t{\n","|ha"),"\t\t\"Y\"\t\t\"","|qY"),"\t\t\"z\"\t\t\"","|qz"),"\t\t\"x\"\t\t\"","|qx"),"\t\t\"A\"\t\t\"","|qA"),"\t\t\"B\"\t\t\"","|qB"),"\t\t\"g\"\t\t\"","|qg"),"\t\t\"r\"\t\t\"","|qr"),"\t\t\"p\"\t\t\"","|qp"),"\"HoldAngle\"\n","|HA"),"\n","|n"),"\t\t\t\t","|4t"),"\t\t\t","|3t"),"\t\t","|2t"),"\t","|t"),"name","|N"),"\"","|Q")
duplicatorclient.temp2 = dupeshare.Compress(temp, true)
//this is where we send the data to the serer
local len = string.len(duplicatorclient.temp2)
local last = math.ceil(len / 250)
pl:ConCommand("DupeRecieveFileContentStart "..tostring(last).." \""..string.gsub(filename,".txt","").."\"")
timer.Simple( 0.2, duplicatorclient.SendSaveDataToServer, len, 1, last )
duplicatorclient.sending = true
end
function duplicatorclient.SendSaveDataToServer(len, offset, last)
if (offset <= last) then
Msg("sending string: "..tostring(offset * 250).." / "..len.." piece: "..offset.." / "..last.."\n")
local str = ""
if (offset == last) then
local pos = (len - ((last - 1) * 250))
str = string.Right(duplicatorclient.temp2, pos)
Msg("last str len: "..tostring(string.len(str)).."\n")
else
str = string.Right(string.Left(duplicatorclient.temp2, (offset * 250)),250)
end
LocalPlayer():ConCommand("_DFC "..tostring(offset).." \""..str.."\"")
end
if (offset + 1) <= last then
//send slowly or the server will boot player or just crash
timer.Simple( 0.1, duplicatorclient.SendSaveDataToServer, len, (offset + 1), last )
else
timer.Simple( 0.5,
function()
LocalPlayer():ConCommand("DupeRecieveFileContentFinish")
duplicatorclient.temp2 = ""
end
)
end
end
local function SendFinished( um )
duplicatorclient.sending = false
end
usermessage.Hook("ClientSendFinished", SendFinished)
local function ClientRecieveSaveStart( um )
Msg("========= ClientRecieveSaveStart ==========\n")
duplicatorclient.temp = {}
duplicatorclient.temp.piece = {}
duplicatorclient.temp.numofpieces = um:ReadShort()
duplicatorclient.temp.filename = um:ReadString()
duplicatorclient.temp.dir = um:ReadString()
duplicatorclient.temp.recievedpieces = 0
Msg("NumToRecieve= "..duplicatorclient.temp.numofpieces.."\n==========\n")
end
usermessage.Hook("RecieveSaveStart", ClientRecieveSaveStart)
local function ClientRecieveSaveData( um )
local piece = um:ReadShort()
local temp = um:ReadString()
duplicatorclient.temp.recievedpieces = duplicatorclient.temp.recievedpieces + 1
Msg("getting file data, piece: "..piece.." of "..duplicatorclient.temp.numofpieces.."\n")
duplicatorclient.temp.piece[piece] = temp
if (duplicatorclient.temp.recievedpieces >= duplicatorclient.temp.numofpieces) then
Msg("recieved last piece\n")
LocalPlayer():ConCommand("adv_duplicator_clientsavefile")
end
end
usermessage.Hook("RecieveSaveData", ClientRecieveSaveData)
local function ClientSaveFile()
local filepath, filename = duplicatorclient.FileNoOverWriteCheck( duplicatorclient.temp.dir, duplicatorclient.temp.filename )
//reassemble the pieces
local temp = ""
for k, v in pairs(duplicatorclient.temp.piece) do
temp = temp .. v
end
//temp = string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(temp,"|mn","\t\t\"__name\"\t\t"),"|mt","\t\t\"__type\"\t\t"),"|mv|","\t\t\t\"V\"\t\t"),"|mD","\t\t\t\"DupeInfo\""),"|mN","\"Number\"\n"),"|mS","\"String\"\n"),"|mA","\"Angle\"\n"),"|mV","\"Vector\"\n"),"|mB","\"Bool\"\n"),"|mC","\"Class\""),"|mm","\"material\""),"|mp","\"prop_physics\""),"|VI","\t\t\"VersionInfo\"\n\t\t\"FileVersion\"\n\t\t{\n"),"|wm","\"models"),"|NC","\n\t\t\t\"NoCollide\"\n\t\t\t{\n\t"),"|nc","\"nocollide\"\n"),"|HE","\"HeadEntID\"\n"),"|ha","\n\t}\n\t\"holdangle\"\n\t{\n"),"|qY","\t\t\"Y\"\t\t\""),"|qz","\t\t\"z\"\t\t\""),"|qx","\t\t\"x\"\t\t\""),"|qA","\t\t\"A\"\t\t\""),"|qB","\t\t\"B\"\t\t\""),"|qg","\t\t\"g\"\t\t\""),"|qr","\t\t\"r\"\t\t\""),"|qp","\t\t\"p\"\t\t\""),"|HA","\"HoldAngle\"\n"),"|4","\t\t\t\t"),"|3","\t\t\t"),"|N","name")
temp = dupeshare.DeCompress(temp, false)
file.Write(filepath, temp)
Msg("Your file: \""..filepath.."\" was saved form the server\n")
Msg("Your file: \""..filename.."\" was saved form the server\n")
LocalPlayer():ConCommand("adv_duplicator_updatelist")
end
concommand.Add( "adv_duplicator_clientsavefile", ClientSaveFile )
/*---------------------------------------------------------
functions for clients from server side duplicator.lua
---------------------------------------------------------*/
/*---------------------------------------------------------
Name: duplicatorclient.PrepareTableToSave( table )
Desc: Converts a table in to a lot tables to protect
vectors, angles, bools, numbers, and indexes
from being horribly raped by TableToKeyValues
---------------------------------------------------------*/
function duplicatorclient.PrepareTableToSave( t, done)
local done = done or {}
local tbl = {}
for k, v in pairs ( t ) do
if ( type( v ) == "table" and !done[ v ] ) then
done[ v ] = true
tbl[ k ] = duplicatorclient.PrepareTableToSave ( v, done )
tbl[k].__name = k
else
if ( type(v) == "Vector" ) then
local x, y, z = v.x, v.y, v.z
if y == 0 then y = nil end
if z == 0 then z = nil end
tbl[k] = { __type = "Vector", x = x, y = y, z = z, __name = k }
elseif ( type(v) == "Angle" ) then
local p,y,r = v.pitch, v.yaw, v.roll
if p == 0 then p = nil end
if y == 0 then y = nil end
if r == 0 then r = nil end
tbl[k] = { __type = "Angle", p = p, y = y, r = r, __name = k }
elseif ( type(v) == "boolean" ) then
tbl[k] = { __type = "Bool", v = tostring( v ), __name = k }
elseif ( type(v) == "number" ) then
tbl[k] = { __type = "Number", v = tostring( v ), __name = k }
else
tbl[k] = { __type = "String", v = tostring( v ), __name = k }
end
end
end
return tbl
end
/*---------------------------------------------------------
Name: duplicatorclient.RebuildTableFromLoad( table )
Desc: Removes the protection added by PrepareTableToSave
after table is loaded with KeyValuesToTable
---------------------------------------------------------*/
function duplicatorclient.RebuildTableFromLoad( t, done )
local done = done or {}
local tbl = {}
for k, v in pairs ( t ) do
if ( type( v ) == "table" and !done[ v ] ) then
done[ v ] = true
if ( v.__type ) then
if ( v.__type == "Vector" ) then
tbl[ v.__name ] = Vector( v.x, v.y, v.z )
elseif ( v.__type == "Angle" ) then
tbl[ v.__name ] = Angle( v.p, v.y, v.r )
elseif ( v.__type == "Bool" ) then
tbl[ v.__name ] = util.tobool( v.v )
elseif ( v.__type == "Number" ) then
tbl[ v.__name ] = tonumber( v.v )
elseif ( v.__type == "String" ) then
tbl[ v.__name ] = tostring( v.v )
end
else
tbl[ v.__name ] = duplicatorclient.RebuildTableFromLoad ( v, done )
end
else
if k != "__name" then //don't add the table names to output
tbl[ k ] = v
end
end
end
return tbl
end
/*---------------------------------------------------------
Name: duplicatorclient.FileNoOverWriteCheck( dir, filename )
Desc: Check if dir and filename exist and if so renames
returns filepath (dir.."/"..filename..".txt")
---------------------------------------------------------*/
function duplicatorclient.FileNoOverWriteCheck( dir, filename )
if !file.Exists(dir) then
file.CreateDir(dir)
elseif !file.IsDir(dir) then
local x = 0
while x ~= nil do
x = x + 1
if not file.Exists(dir.."_"..tostring(x)) then
dir = dir.."_"..tostring(x)
file.CreateDir(dir)
x = nil
end
end
end
if file.Exists(dir .. "/" .. filename .. ".txt") then
local x = 0
while x ~= nil do
x = x + 1
if not file.Exists(dir.."/"..filename.."_"..tostring(x)..".txt") then
filename = filename.."_"..tostring(x)
x = nil
end
end
end
local filepath = dir .. "/" .. filename .. ".txt"
return filepath, filename, dir
end
Msg("--- Wire duplicator client module installed! ---\n")
end

View File

@@ -4,6 +4,7 @@
local meta = FindMetaTable("Entity") local meta = FindMetaTable("Entity")
if (!meta) then return end if (!meta) then return end
/*not need any more
if (!oldDORFunction) then if (!oldDORFunction) then
oldDORFunction = meta.DeleteOnRemove oldDORFunction = meta.DeleteOnRemove
@@ -46,7 +47,7 @@ function meta:GetDeleteOnRemoveInfo()
end end
return DORInfo return DORInfo
end end*/
//Set DeleteOnRemoveInfo //Set DeleteOnRemoveInfo
function meta:SetDeleteOnRemoveInfo(DORInfo, GetEntID) function meta:SetDeleteOnRemoveInfo(DORInfo, GetEntID)
@@ -67,7 +68,7 @@ function meta:SetDeleteOnRemoveInfo(DORInfo, GetEntID)
end end
// Console Command to print EntIndex() of all attached ents // Console Command to print EntIndex() of all attached ents
local function PrintDOREntities(player,command,arguments) /*local function PrintDOREntities(player,command,arguments)
local trace = player:GetEyeTrace() local trace = player:GetEyeTrace()
if (!trace.HitPos || !trace.Entity || !trace.Entity:IsValid() || trace.Entity:IsPlayer()) then return end if (!trace.HitPos || !trace.Entity || !trace.Entity:IsValid() || trace.Entity:IsPlayer()) then return end
if (!trace.Entity.DeleteOnRemoveInfo) then return end if (!trace.Entity.DeleteOnRemoveInfo) then return end
@@ -80,4 +81,4 @@ local function PrintDOREntities(player,command,arguments)
Msg(index..": "..ent:EntIndex().."\n") Msg(index..": "..ent:EntIndex().."\n")
end end
end end
concommand.Add("dor_entities",PrintDOREntities) concommand.Add("dor_entities",PrintDOREntities)*/

File diff suppressed because it is too large Load Diff

View File

@@ -504,3 +504,10 @@ function Wire_CreateOutputIterator()
return iter return iter
end end
function Wire_AfterPasteMods(ply, Ent, DupeInfo)
//this does nothing for now, we need the blank function to get the duplicator to copy the WireDupeInfo into the pasted ent
end
duplicator.RegisterEntityModifier( "WireDupeInfo", Wire_AfterPasteMods )

View File

@@ -1,385 +1 @@
//this file left blank on purpose to overwrite existing file on upgrade
dupeshare = {}
dupeshare.Dictionary = {
[1] = {"|MCl", "\"\n\t\t\t}\n\t\t\t\"class\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"Class\"\n\t\t\t\t\"__type\"\t\t\"String\"\n\t\t\t\t\"V\"\t\t\""},
[2] = {"|Mfz", "\"\n\t\t\t}\n\t\t\t\"frozen\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"frozen\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[3] = {"|Mre", "\"\n\t\t\t}\n\t\t\t\"resistance\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"resistance\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[4] = {"|Msp", "\"\n\t\t\t}\n\t\t\t\"speed\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"speed\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[5] = {"|Mkd", "\"\n\t\t\t}\n\t\t\t\"key_d\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"key_d\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[6] = {"|Mnc", "\"\n\t\t\t}\n\t\t\t\"NoCollide\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"nocollide\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[7] = {"|Mdm", "\"\n\t\t\t}\n\t\t\t\"damageable\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"damageable\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[8] = {"|Mkb", "\"\n\t\t\t}\n\t\t\t\"key_bck\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"key_bck\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[9] = {"|Mfr", "\"\n\t\t\t}\n\t\t\t\"force\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"force\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[10] = {"|Mky", "\"\n\t\t\t}\n\t\t\t\"key\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"key\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[11] = {"|Mmd", "\"\n\t\t\t}\n\t\t\t\"model\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"model\"\n\t\t\t\t\"__type\"\t\t\"String\"\n\t\t\t\t\"V\"\t\t\""},
[12] = {"|Mtg", "\"\n\t\t\t}\n\t\t\t\"toggle\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"toggle\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[13] = {"|Mef", "\"\n\t\t\t}\n\t\t\t\"effect\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"effect\"\n\t\t\t\t\"__type\"\t\t\"String\"\n\t\t\t\t\"V\"\t\t\""},
[14] = {"|ME1", "\"\n\t\t\t}\n\t\t\t\"Ent1\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"Ent1\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[15] = {"|ME2", "\"\n\t\t\t}\n\t\t\t\"Ent2\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"Ent2\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[16] = {"|MB1", "\"\n\t\t\t}\n\t\t\t\"Bone1\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"Bone1\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[17] = {"|MB2", "\"\n\t\t\t}\n\t\t\t\"Bone2\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"Bone2\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[18] = {"|Mtl", "\"\n\t\t\t}\n\t\t\t\"torquelimit\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"torquelimit\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[19] = {"|Mty", "\"\n\t\t\t}\n\t\t\t\"type\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"Type\"\n\t\t\t\t\"__type\"\t\t\"String\"\n\t\t\t\t\"V\"\t\t\""},
[20] = {"|Mfl", "\"\n\t\t\t}\n\t\t\t\"forcelimit\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"forcelimit\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[21] = {"|Mln", "\"\n\t\t\t}\n\t\t\t\"length\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"length\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[22] = {"|MCI", "\"\n\t\t\t}\n\t\t\t\"ConstID\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"ConstID\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[23] = {"|Mwd", "\"\n\t\t\t}\n\t\t\t\"width\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"width\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[24] = {"|Mrg", "\"\n\t\t\t}\n\t\t\t\"rigid\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"rigid\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[25] = {"|Mmt", "\"\n\t\t\t}\n\t\t\t\"material\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"material\"\n\t\t\t\t\"__type\"\t\t\"String\"\n\t\t\t\t\"V\"\t\t\""},
[26] = {"|Mal", "\"\n\t\t\t}\n\t\t\t\"addlength\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"addlength\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[27] = {"|MFI", "\"\n\t\t\t}\n\t\t\t\"FileInfo\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"FileInfo\"\n\t\t\t\t\"__type\"\t\t\"String\"\n\t\t\t\t\"V\"\t\t\""},
[28] = {"|MND", "\"\n\t\t\t}\n\t\t\t\"NumOfDupeInfo\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"NumOfDupeInfo\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[29] = {"|MNE", "\"\n\t\t\t}\n\t\t\t\"NumOfEnts\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"NumOfEnts\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[30] = {"|MNC", "\"\n\t\t\t}\n\t\t\t\"NumOfConst\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"NumOfConst\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[31] = {"|MCr", "\"\n\t\t\t}\n\t\t\t\"Creator\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"Creator\"\n\t\t\t\t\"__type\"\t\t\"String\"\n\t\t\t\t\"V\"\t\t\""},
[32] = {"|MDc", "\"\n\t\t\t}\n\t\t\t\"Desc\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"Desc\"\n\t\t\t\t\"__type\"\t\t\"String\"\n\t\t\t\t\"V\"\t\t\""},
[33] = {"|Mop", "\"\n\t\t\t}\n\t\t\t\"out_pos\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"out_pos\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[34] = {"|Miw", "\"\n\t\t\t}\n\t\t\t\"ignore_world\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"ignore_world\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[35] = {"|Mdz", "\"\n\t\t\t}\n\t\t\t\"default_zero\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"default_zero\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[36] = {"|Msb", "\"\n\t\t\t}\n\t\t\t\"show_beam\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"show_beam\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[37] = {"|Moa", "\"\n\t\t\t}\n\t\t\t\"out_ang\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"out_ang\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[38] = {"|Mtw", "\"\n\t\t\t}\n\t\t\t\"trace_water\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"trace_water\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[39] = {"|Mov", "\"\n\t\t\t}\n\t\t\t\"out_vel\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"out_vel\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[40] = {"|Moc", "\"\n\t\t\t}\n\t\t\t\"out_col\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"out_col\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[41] = {"|Moa", "\"\n\t\t\t}\n\t\t\t\"out_val\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"out_val\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[42] = {"|Mod", "\"\n\t\t\t}\n\t\t\t\"out_dist\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"out_dist\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[43] = {"|Mbd", "\"\n\t\t\t}\n\t\t\t\"doblastdamage\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"doblastdamage\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[44] = {"|Mra", "\"\n\t\t\t}\n\t\t\t\"removeafter\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"removeafter\"\n\t\t\t\t\"__type\"\t\t\"Bool\"\n\t\t\t\t\"V\"\t\t\""},
[45] = {"|Mrd", "\"\n\t\t\t}\n\t\t\t\"radius\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"radius\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[46] = {"|Mat", "\"\n\t\t\t}\n\t\t\t\"action\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"action\"\n\t\t\t\t\"__type\"\t\t\"String\"\n\t\t\t\t\"V\"\t\t\""},
[47] = {"|Mkg", "\n\t\t\t\"keygroup\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"keygroup\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[48] = {"|Mvo", "\"\n\t\t\t}\n\t\t\t\"value_off\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"value_off\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[49] = {"|Mvn", "\"\n\t\t\t}\n\t\t\t\"value_on\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"value_on\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[50] = {"|MAa", "\"\n\t\t\t}\n\t\t\t\"A\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"a\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[51] = {"|MBb", "\"\n\t\t\t}\n\t\t\t\"B\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"b\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[52] = {"|Mab", "\"\n\t\t\t}\n\t\t\t\"ab\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"ab\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[53] = {"|Maa", "\"\n\t\t\t}\n\t\t\t\"aa\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"aa\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[54] = {"|Mag", "\"\n\t\t\t}\n\t\t\t\"ag\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"ag\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[55] = {"|Mbg", "\"\n\t\t\t}\n\t\t\t\"bg\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"bg\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[56] = {"|Mba", "\"\n\t\t\t}\n\t\t\t\"ba\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"ba\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[57] = {"|Mbb", "\"\n\t\t\t}\n\t\t\t\"bb\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"bb\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[58] = {"|Mar", "\"\n\t\t\t}\n\t\t\t\"ar\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"ar\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[59] = {"|Mbr", "\"\n\t\t\t}\n\t\t\t\"br\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"br\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[60] = {"|MVe", "\"\n\t\t\t}\n\t\t\t\"Vel\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"Vel\"\n\t\t\t\t\"__type\"\t\t\"Vector\"\n\t\t\t\t\"V\"\t\t\""},
[61] = {"|MaV", "\"\n\t\t\t}\n\t\t\t\"aVel\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"aVel\"\n\t\t\t\t\"__type\"\t\t\"Vector\"\n\t\t\t\t\"V\"\t\t\""},
[62] = {"|MSm", "\"\n\t\t\t}\n\t\t\t\"Smodel\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"Smodel\"\n\t\t\t\t\"__type\"\t\t\"String\"\n\t\t\t\t\"V\"\t\t\""},
[63] = {"|MWw", "\"\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\"width\"\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"__name\"\t\t\"Width\"\n\t\t\t\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\t\t\t\"V\"\t\t\""},
[64] = {"|MWS", "\"\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\"Src\"\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"__name\"\t\t\"Src\"\n\t\t\t\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\t\t\t\"V\"\t\t\""},
[65] = {"|MWI", "\"\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\"SrcId\"\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"__name\"\t\t\"SrcId\"\n\t\t\t\t\t\t\t\"__type\"\t\t\"String\"\n\t\t\t\t\t\t\t\"V\"\t\t\""},
[66] = {"|MWm", "\"\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\"material\"\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"__name\"\t\t\"material\"\n\t\t\t\t\t\t\t\"__type\"\t\t\"String\"\n\t\t\t\t\t\t\t\"V\"\t\t\""},
[67] = {"|MWD", "\"\n\t\t\t}\n\t\t\t\"DupeInfo\"\n\t\t\t{\n\t\t\t\t\"__name\"\t\t\"DupeInfo\"\n\t\t\t\t\"Wires\"\n\t\t\t\t{\n\t\t\t\t\t\"A\"\n\t\t\t\t\t{\n\t\t\t\t\t\t\"__name\"\t\t\"A\"\n\t\t\t\t\t\t\"SrcPos\"\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"Y\"\t\t\""},
[68] = {"|MWB", "\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\"B\"\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"__name\"\t\t\"b\"\n\t\t\t\t\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\t\t\t\t\"V\"\t\t\""},
[69] = {"|MWg", "\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\"g\"\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"__name\"\t\t\"g\"\n\t\t\t\t\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\t\t\t\t\"V\"\t\t\""},
[70] = {"|MWr", "\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\"r\"\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"__name\"\t\t\"r\"\n\t\t\t\t\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\t\t\t\t\"V\"\t\t\""},
[71] = {"|mn", "\t\t\"__name\"\t\t"},
[72] = {"|mt", "\t\t\"__type\"\t\t"},
[73] = {"|mv", "\t\t\t\"V\"\t\t"},
[74] = {"|mD", "\t\t\t\"DupeInfo\""},
[75] = {"|mN", "\"Number\"\n"},
[76] = {"|mS", "\"String\"\n"},
[77] = {"|mA", "\"Angle\"\n"},
[78] = {"|mV", "\"Vector\"\n"},
[79] = {"|mB", "\"Bool\"\n"},
[80] = {"|mC", "\"Class\""},
[81] = {"|mm", "\"material\""},
[82] = {"|mp", "\"prop_physics\""},
[83] = {"|VI", "\t\t\"VersionInfo\"\n\t\t\"FileVersion\"\n\t\t{\n\t\t\t\t\"__name\"\t\t\"FileVersion\"\n\t\t\t\t\"__type\"\t\t\"Number\"\n\t\t\t\t\"V\"\t\t\""},
[84] = {"|wm", "\"models"},
[85] = {"|nC", "\n\t\t\t\"NoCollide\"\n\t\t\t{\n\t"},
[86] = {"|nc", "\"nocollide\"\n"},
[87] = {"|HE", "\"HeadEntID\"\n"},
[88] = {"|ha", "\n\t}\n\t\"holdangle\"\n\t{\n"},
[89] = {"|qY", "\t\t\"Y\"\t\t\""},
[90] = {"|qz", "\t\t\"z\"\t\t\""},
[91] = {"|qx", "\t\t\"x\"\t\t\""},
[92] = {"|qA", "\t\t\"A\"\t\t\""},
[93] = {"|qB", "\t\t\"B\"\t\t\""},
[94] = {"|qg", "\t\t\"g\"\t\t\""},
[95] = {"|qr", "\t\t\"r\"\t\t\""},
[96] = {"|qp", "\t\t\"p\"\t\t\""},
[97] = {"|HA", "\"HoldAngle\"\n"},
[98] = {"|5", "\t\t\t\t\t"},
[98] = {"|4", "\t\t\t\t"},
[99] = {"|3", "\t\t\t"},
[100] = {"|2", "\t\t"},
[101] = {"|N", "name"},
}
function dupeshare.Compress(str, ForConCommand)
local beforelen = string.len(str)
for k=1,101 do
local entry = dupeshare.Dictionary[k]
str = string.gsub(str, entry[2], entry[1])
end
if (ForConCommand) then //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> unused special chars
str = string.gsub(string.gsub(string.gsub(str,"<EFBFBD>","|<7C>"),"<EFBFBD>","|<7C>"),"<EFBFBD>","|<7C>") //incase it has any of these...
str = string.gsub(string.gsub(string.gsub(str,"\n","<EFBFBD>"),"\t","<EFBFBD>"),"\"","<EFBFBD>")
end
local afterlen = string.len(str)
Msg("String Compressed: "..afterlen.." / "..beforelen.." ratio: "..(afterlen / beforelen).."%\n")
return str
end
function dupeshare.DeCompress(str, FormConCommand)
local afterlen = string.len(str)
for k=101,1,-1 do
local entry = dupeshare.Dictionary[k]
str = string.gsub(str, entry[1], entry[2])
end
if (FormConCommand) then
str = string.gsub(string.gsub(string.gsub(str,"|<7C>","<EFBFBD>"),"|<7C>","<EFBFBD>"),"|<7C>","<EFBFBD>")
str = string.gsub(string.gsub(string.gsub(str,"<EFBFBD>","\n"),"<EFBFBD>","\t"),"<EFBFBD>","\"")
end
local beforelen = string.len(str)
Msg("String Decompressed: "..afterlen.." / "..beforelen.." ratio: "..(afterlen / beforelen).."%\n")
return str
end
dupeshare.BadChars = {"\\", "/", ":", "*", "?", "\"", "<", ">", "<EFBFBD>", "|"}
function dupeshare.ReplaceBadChar(str)
for _,entry in pairs(dupeshare.BadChars) do
str = string.gsub(str, entry, "_")
end
return str
end
if (CLIENT) then
LocalPlayer():ConCommand("GiveMeSteamID")
local function GetSteamID( um )
dupeshare.MySteamID = um:ReadString()
Msg("My SteamID is: "..(dupeshare.MySteamID or "NIL").."\n")
end
usermessage.Hook("GivePlayerSteamID", GetSteamID)
function dupeshare.GetPlayerName(pl)
local name = dupeshare.MySteamID or pl:GetName() or "unknown"
if (name == "STEAM_ID_LAN") or (name == "UNKNOWN") or (name == "STEAM_ID_PENDING") then
name = pl:GetName() or "unknown"
end
name = dupeshare.ReplaceBadChar(name)
return name
end
end
if (SERVER) then
if (!SinglePlayer()) then
local function GivePlayerTheirSteamID( pl, cmd, args )
umsg.Start("GivePlayerSteamID", pl)
umsg.String(pl:SteamID())
Msg("Player \""..tostring(pl:GetName()).."\" SteamID is: "..pl:SteamID().."\n")
umsg.End()
end
concommand.Add("GiveMeSteamID", GivePlayerTheirSteamID)
end
function dupeshare.GetPlayerName(pl)
local name = pl:SteamID() or pl:GetName() or "unknown"
if (name == "STEAM_ID_LAN") or (name == "UNKNOWN") or (name == "STEAM_ID_PENDING") then
name = pl:GetName() or "unknown"
end
name = dupeshare.ReplaceBadChar(name)
return name
end
end
function dupeshare.CurrentToolIsDuplicator(tool, advdupeonly)
if (tool) and (tool:GetClass() == "gmod_tool" )
and ((tool:GetTable():GetToolObject().Name == "Advanced Duplicator")
or ((tool:GetTable():GetToolObject().Name == "Duplicator") and !advdupeonly)) then
return true
else
return false
end
end
/*---------------------------------------------------------
Name: dupeshare.PrepareTableToSave( table )
Desc: Converts a table in to a lot tables to protect
vectors, angles, bools, numbers, and indexes
from being horribly raped by TableToKeyValues
---------------------------------------------------------*/
function dupeshare.PrepareTableToSave( t, done)
local done = done or {}
local tbl = {}
for k, v in pairs ( t ) do
if ( type( v ) == "table" and !done[ v ] ) then
done[ v ] = true
tbl[ k ] = dupeshare.PrepareTableToSave ( v, done )
tbl[k].__name = k
else
if ( type(v) == "Vector" ) then
local x, y, z = v.x, v.y, v.z
if y == 0 then y = nil end
if z == 0 then z = nil end
tbl[k] = { __type = "Vector", x = x, y = y, z = z, __name = k }
elseif ( type(v) == "Angle" ) then
local p,y,r = v.pitch, v.yaw, v.roll
if p == 0 then p = nil end
if y == 0 then y = nil end
if r == 0 then r = nil end
tbl[k] = { __type = "Angle", p = p, y = y, r = r, __name = k }
elseif ( type(v) == "boolean" ) then
tbl[k] = { __type = "Bool", v = tostring( v ), __name = k }
elseif ( type(v) == "number" ) then
tbl[k] = { __type = "Number", v = tostring( v ), __name = k }
else
tbl[k] = { __type = "String", v = tostring( v ), __name = k }
end
end
end
return tbl
end
/*---------------------------------------------------------
Name: dupeshare.RebuildTableFromLoad( table )
Desc: Removes the protection added by PrepareTableToSave
after table is loaded with KeyValuesToTable
---------------------------------------------------------*/
function dupeshare.RebuildTableFromLoad( t, done )
local done = done or {}
local tbl = {}
for k, v in pairs ( t ) do
if ( type( v ) == "table" and !done[ v ] ) then
done[ v ] = true
if ( v.__type ) then
if ( v.__type == "Vector" ) then
tbl[ v.__name ] = Vector( v.x, v.y, v.z )
elseif ( v.__type == "Angle" ) then
tbl[ v.__name ] = Angle( v.p, v.y, v.r )
elseif ( v.__type == "Bool" ) then
tbl[ v.__name ] = util.tobool( v.v )
elseif ( v.__type == "Number" ) then
tbl[ v.__name ] = tonumber( v.v )
elseif ( v.__type == "String" ) then
tbl[ v.__name ] = tostring( v.v )
end
else
tbl[ v.__name ] = dupeshare.RebuildTableFromLoad ( v, done )
end
else
if k != "__name" then //don't add the table names to output
tbl[ k ] = v
end
end
end
return tbl
end
function dupeshare.ProtectCase(str)
str2=""
for i = 1, string.len(str) do
local chr = string.sub(str, i, i)
if (chr != string.lower(chr)) then chr = "^"..chr end
str2 = str2..chr
end
return str2
end
function dupeshare.UnprotectCase(str)
str2=""
for i = 1, string.len(str) do
local chr = string.sub(str, i, i)
if (string.sub(str, i+1, i+1) == "^") then chr = string.upper(chr) end
if char != "^" then str2 = str2..chr end
end
return str2
end
/*---------------------------------------------------------
Name: dupeshare.FileNoOverWriteCheck( dir, filename )
Desc: Check if dir and filename exist and if so renames
returns filepath (dir.."/"..filename..".txt")
---------------------------------------------------------*/
function dupeshare.FileNoOverWriteCheck( dir, filename )
if !file.Exists(dir) then
file.CreateDir(dir)
elseif !file.IsDir(dir) then
local x = 0
while x ~= nil do
x = x + 1
if not file.Exists(dir.."_"..tostring(x)) then
dir = dir.."_"..tostring(x)
file.CreateDir(dir)
x = nil
end
end
end
if file.Exists(dir .. "/" .. filename .. ".txt") then
local x = 0
while x ~= nil do
x = x + 1
if not file.Exists(dir.."/"..filename.."_"..tostring(x)..".txt") then
filename = filename.."_"..tostring(x)
x = nil
end
end
end
local filepath = dir .. "/" .. filename .. ".txt"
return filepath, filename, dir
end
/*---------------------------------------------------------
cause garry's crashes the server
and this one returns the filename without extention
---------------------------------------------------------*/
function dupeshare.GetFileFromFilename(path)
for i = string.len(path), 1, -1 do
local str = string.sub(path, i, i)
if str == "/" or str == "\\" then path = string.sub(path, (i + 1)) end
end
//removed .txt from the end if its there.
if (string.sub(path, -4) == ".txt") then
path = string.sub(path, 1, -5)
end
return path
end
Msg("--- Wire duplicator shared module installed! ---\n")

View File

@@ -77,7 +77,7 @@ function ENT:BuildDupeInfo()
return info return info
end end
function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID, GetConstByID) function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID)
if (info.Wires) then if (info.Wires) then
for k,input in pairs(info.Wires) do for k,input in pairs(info.Wires) do
Wire_Link_Start(ply:UniqueID(), ent, input.StartPos, k, input.Material, input.Color, input.Width) Wire_Link_Start(ply:UniqueID(), ent, input.StartPos, k, input.Material, input.Color, input.Width)
@@ -90,3 +90,21 @@ function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID, GetConstByID)
end end
end end
end end
//
//new duplicator stuff
//
function ENT:PreEntityCopy()
//build the DupeInfo table and save it as an entity mod
local DupeInfo = self:BuildDupeInfo()
if DupeInfo then
duplicator.StoreEntityModifier( self.Entity, "WireDupeInfo", DupeInfo )
end
end
function ENT:PostEntityPaste( Player, Ent, CreatedEntities )
//apply the DupeInfo
if (Ent.EntityMods) and (Ent.EntityMods.WireDupeInfo) then
Ent:ApplyDupeInfo(Player, Ent, Ent.EntityMods.WireDupeInfo, function(id) return CreatedEntities[id] end)
end
end

View File

@@ -82,7 +82,7 @@ end*/
function ENT:Paste() function ENT:Paste()
if (self.stage != 0) then return end if (self.stage != 0) then return end
Msg("====start====\n") --Msg("====start====\n")
self:HideGhost(true) self:HideGhost(true)
@@ -106,7 +106,7 @@ function ENT:Paste()
self.offset = self.Entity:GetPos() + self.Entity:GetUp() * self.Entity:OBBMaxs().z self.offset = self.Entity:GetPos() + self.Entity:GetUp() * self.Entity:OBBMaxs().z
end end
Msg("going to stage 1\n") --Msg("going to stage 1\n")
self.stage = 1 self.stage = 1
end end
@@ -243,7 +243,7 @@ function ENT:Think()
end end
end end
Msg("going to stage 2\n") --Msg("going to stage 2\n")
self.stage = 2 self.stage = 2
self.Entity:NextThink(CurTime() + self.thinkdelay) self.Entity:NextThink(CurTime() + self.thinkdelay)
return true return true
@@ -277,7 +277,7 @@ function ENT:Think()
return true return true
end end
else else
Msg("going to stage 3\n") --Msg("going to stage 3\n")
self.stage = 4 self.stage = 4
self.Entity:NextThink(CurTime() + self.thinkdelay) self.Entity:NextThink(CurTime() + self.thinkdelay)
return true return true
@@ -286,7 +286,7 @@ function ENT:Think()
elseif (self.stage == 3) then elseif (self.stage == 3) then
for id, infoTable in pairs(self.DupeInfo) do /*for id, infoTable in pairs(self.DupeInfo) do
local ent = self.entIDtable[id] local ent = self.entIDtable[id]
local isdupeinfo = false local isdupeinfo = false
if (ent) and (ent:IsValid()) and (infoTable) and (ent.ApplyDupeInfo) then if (ent) and (ent:IsValid()) and (infoTable) and (ent.ApplyDupeInfo) then
@@ -305,21 +305,32 @@ function ENT:Think()
return true return true
end end
end end
end*/
for id, infoTable in pairs(self.DupeInfo) do
local ent = self.entIDtable[id]
if (ent) and (ent:IsValid()) and (infoTable) and (ent.ApplyDupeInfo) then
ent:ApplyDupeInfo(
self:GetPlayer(), ent, infoTable,
function(id) return self.entIDtable[id] end,
function(id) return self.constIDtable[id] end
)
end
end end
Msg("going to stage 4\n") --Msg("going to stage 4\n")
self.stage = 4 self.stage = 4
self.Entity:NextThink(CurTime() + self.thinkdelay) self.Entity:NextThink(CurTime() + self.thinkdelay)
return true return true
elseif (self.stage == 4) then elseif (self.stage == 4) then
//this just looks wrong, so no //this just looks wrong, so no
/*Msg("starting rotate\n") --Msg("starting rotate\n")
duplicator.PasteRotate( self:GetPlayer(), self.HeadEntity, self.CreatedEnts )*/ duplicator.PasteRotate( self:GetPlayer(), self.HeadEntity, self.CreatedEnts )
duplicator.PasteApplyDORInfo( self.DORInfo, function(id) return self.entIDtable[id] end ) duplicator.PasteApplyDORInfo( self.DORInfo, function(id) return self.entIDtable[id] end )
Msg("going to stage 5\n") --Msg("going to stage 5\n")
self.stage = 5 self.stage = 5
self.Entity:NextThink(CurTime() + self.thinkdelay) self.Entity:NextThink(CurTime() + self.thinkdelay)
return true return true
@@ -368,7 +379,7 @@ function ENT:Think()
Msg("====done====\n") --Msg("====done====\n")
self:HideGhost(false) self:HideGhost(false)

View File

@@ -91,6 +91,19 @@ function ENT:OnTakeDamage( dmginfo )
//self.Entity:TakePhysicsDamage( dmginfo ) //self.Entity:TakePhysicsDamage( dmginfo )
end end
/*---------------------------------------------------------
Name: Think
---------------------------------------------------------*/
function ENT:Think()
self.Entity:NextThink( CurTime() + 0.25 )
self.Entity:SetNetworkedInt( "TargetZ", self:GetTargetZ() )
return true
end
/*--------------------------------------------------------- /*---------------------------------------------------------
Name: Simulate Name: Simulate
---------------------------------------------------------*/ ---------------------------------------------------------*/
@@ -110,10 +123,11 @@ function ENT:PhysicsSimulate( phys, deltatime )
txt = txt.." (on)" txt = txt.." (on)"
self:SetOverlayText( txt ) self:SetOverlayText( txt )
if ( self.ZVelocity != 0 ) then if ( self.ZVelocity != 0 ) then
self:SetTargetZ( self:GetTargetZ() + (self.ZVelocity * deltatime * self:GetSpeed()) ) self:SetTargetZ( self:GetTargetZ() + (self.ZVelocity * deltatime * self:GetSpeed()) )
self.Entity:GetPhysicsObject():Wake() self.Entity:GetPhysicsObject():Wake()
end end
phys:Wake() phys:Wake()

View File

@@ -23,3 +23,13 @@ function ENT:TriggerInput(iname, value)
self:SetDisplayB( string.format("%.2f", value) ) self:SetDisplayB( string.format("%.2f", value) )
end end
end end
function ENT:Setup(SingleValue, SingleBigFont, TextA, TextB)
// Extra stuff for Wire Screen (TheApathetic)
self:SetTextA(TextA)
self:SetTextB(TextB)
self:SetSingleBigFont(SingleBigFont)
// Put it here to update inputs if necessary (TheApathetic)
self:SetSingleValue(SingleValue)
end

View File

@@ -175,7 +175,7 @@ function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID)
if (info.to_sense) then if (info.to_sense) then
self:SetBeacon(GetEntByID(info.to_sense)) self:SetBeacon(GetEntByID(info.to_sense))
if (!self.ToSense) then if (!self.ToSense) then
self:SetBeacon(ents.GetByIndexs(info.to_sense)) self:SetBeacon(ents.GetByIndex(info.to_sense))
end end
end end
end end

View File

@@ -48,9 +48,9 @@ end
---------------------------------------------------------*/ ---------------------------------------------------------*/
function ENT:SetAxis( vec ) function ENT:SetAxis( vec )
self.Axis = self.Entity:GetPos() + (vec * 512) self.Axis = self.Entity:GetPos() + vec * 512
self.Axis = self.Entity:NearestPoint( self.Axis ) + vec self.Axis = self.Entity:NearestPoint( self.Axis )
self.Axis = self.Entity:WorldToLocal( self.Axis ) self.Axis = self.Entity:WorldToLocal( self.Axis )
end end
@@ -96,12 +96,18 @@ function ENT:SetMotor( Motor )
end end
function ENT:GetMotor() function ENT:GetMotor()
return self.Motor or NULL
if (!self.Motor) then
self.Motor = constraint.FindConstraintEntity( self.Entity, "Motor" )
end
return self.Motor
end end
function ENT:SetDirection( dir ) function ENT:SetDirection( dir )
self.Entity:SetNetworkedInt( 1, dir ) self.Entity:SetNetworkedInt( 1, dir )
self.Direction = dir
end end
function ENT:SetToggle( bool ) function ENT:SetToggle( bool )
@@ -136,7 +142,8 @@ function ENT:Forward( mul )
local Motor = self:GetMotor() local Motor = self:GetMotor()
if ( !Motor:IsValid() ) then if ( !Motor:IsValid() ) then
Msg("Wheel doesn't have a motor!\n"); Msg("Wheel doesn't have a motor!\n");
return false end return false
end
mul = mul or 1 mul = mul or 1
local mdir = Motor:GetTable().direction local mdir = Motor:GetTable().direction
@@ -228,10 +235,9 @@ function ENT:DoDirectionEffect()
if (!Motor || !Motor:IsValid()) then return end if (!Motor || !Motor:IsValid()) then return end
local effectdata = EffectData() local effectdata = EffectData()
effectdata:SetOrigin( self.Entity:LocalToWorld( self.Axis ) ) effectdata:SetOrigin( self.Axis )
effectdata:SetStart( self.Axis )
effectdata:SetEntity( self.Entity ) effectdata:SetEntity( self.Entity )
effectdata:SetScale( Motor:GetTable().direction ) effectdata:SetScale( Motor.direction )
util.Effect( "wheel_indicator", effectdata, true, true ) util.Effect( "wheel_indicator", effectdata, true, true )
end end

File diff suppressed because it is too large Load Diff

View File

@@ -85,8 +85,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world, unless we wanted too // Don't weld to world, unless we wanted too
if ( trace.Entity:IsValid() || worldweld ) then if ( trace.Entity:IsValid() || worldweld ) then
for x=1, 7 do for x=1, 7 do
const[x] = constraint.Weld( wire_indicators[x], trace.Entity, 0, trace.PhysicsBone, 0, true ) const[x] = constraint.Weld( wire_indicators[x], trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_indicators[x] )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
if ( collision == 0 ) then if ( collision == 0 ) then
@@ -175,7 +174,7 @@ if (SERVER) then
//weld this segment to eveyone before it //weld this segment to eveyone before it
for y=1,x do for y=1,x do
const = constraint.Weld( wire_indicators[x], wire_indicators[y], 0, 0, 0, true ) const = constraint.Weld( wire_indicators[x], wire_indicators[y], 0, 0, 0, true, true )
end end
wire_indicators[x-1]:DeleteOnRemove( wire_indicators[x] ) //when one is removed, all are. a linked chain wire_indicators[x-1]:DeleteOnRemove( wire_indicators[x] ) //when one is removed, all are. a linked chain
end end

View File

@@ -67,9 +67,19 @@ function TOOL:LeftClick( trace )
local min = wire_adv_input:OBBMins() local min = wire_adv_input:OBBMins()
wire_adv_input:SetPos( trace.HitPos - trace.HitNormal * min.z ) wire_adv_input:SetPos( trace.HitPos - trace.HitNormal * min.z )
// Don't weld to world
local const, nocollide
if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_adv_input, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
// Don't disable collision if it's not attached to anything
wire_adv_input:GetPhysicsObject():EnableCollisions( false )
wire_adv_input.nocollide = true
end
undo.Create("WireInput") undo.Create("WireInput")
undo.AddEntity( wire_adv_input ) undo.AddEntity( wire_adv_input )
undo.AddEntity( const )
undo.SetPlayer( ply ) undo.SetPlayer( ply )
undo.Finish() undo.Finish()

View File

@@ -69,8 +69,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_button, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_button, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_button )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_button:GetPhysicsObject():EnableCollisions( false ) wire_button:GetPhysicsObject():EnableCollisions( false )
wire_button.nocollide = true wire_button.nocollide = true

View File

@@ -78,10 +78,20 @@ function TOOL:LeftClick( trace )
wire_cpu = MakeWireCpu( ply, Ang, trace.HitPos, Smodel ) wire_cpu = MakeWireCpu( ply, Ang, trace.HitPos, Smodel )
local min = wire_cpu:OBBMins() local min = wire_cpu:OBBMins()
wire_cpu:SetPos( trace.HitPos - trace.HitNormal * min.z ) wire_cpu:SetPos( trace.HitPos - trace.HitNormal * min.z )
local const, nocollide
// Don't weld to world
if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_cpu, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
// Don't disable collision if it's not attached to anything
wire_cpu:GetPhysicsObject():EnableCollisions( false )
wire_cpu.nocollide = true
end
undo.Create("WireCpu") undo.Create("WireCpu")
undo.AddEntity( wire_cpu ) undo.AddEntity( wire_cpu )
undo.SetPlayer( ply ) undo.SetPlayer( ply )
undo.AddEntity( const )
undo.Finish() undo.Finish()
ply:AddCleanup( "wire_cpus", wire_cpu ) ply:AddCleanup( "wire_cpus", wire_cpu )

View File

@@ -61,8 +61,7 @@ function TOOL:LeftClick( trace )
local min = wire_detonator:OBBMins() local min = wire_detonator:OBBMins()
wire_detonator:SetPos( trace.HitPos - trace.HitNormal * min.z ) wire_detonator:SetPos( trace.HitPos - trace.HitNormal * min.z )
const = constraint.Weld( wire_detonator, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_detonator, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_detonator )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
if ( collision == 0 ) then if ( collision == 0 ) then

View File

@@ -69,8 +69,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_dual_input, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_dual_input, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_dual_input )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_dual_input:GetPhysicsObject():EnableCollisions( false ) wire_dual_input:GetPhysicsObject():EnableCollisions( false )
wire_dual_input.nocollide = true wire_dual_input.nocollide = true

View File

@@ -128,8 +128,11 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() && _weld ) then if ( trace.Entity:IsValid() && _weld ) then
const, nocollide = constraint.Weld( explosive, trace.Entity, 0, trace.PhysicsBone, 0, collision == 0 ) if (_noparentremove) then
if (!_noparentremove) then trace.Entity:DeleteOnRemove( explosive ) end const, nocollide = constraint.Weld( explosive, trace.Entity, 0, trace.PhysicsBone, 0, collision == 0 )
else
const, nocollide = constraint.Weld( explosive, trace.Entity, 0, trace.PhysicsBone, 0, collision == 0, true )
end
end end
if (_weight <= 0) then _weight = 1 end if (_weight <= 0) then _weight = 1 end

View File

@@ -52,8 +52,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_forcer, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_forcer, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_forcer )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_forcer:GetPhysicsObject():EnableCollisions( false ) wire_forcer:GetPhysicsObject():EnableCollisions( false )
wire_forcer:GetTable().nocollide = true wire_forcer:GetTable().nocollide = true

View File

@@ -62,8 +62,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_gate_arithmetic, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_gate_arithmetic, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_gate_arithmetic )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_gate_arithmetic:GetPhysicsObject():EnableCollisions( false ) wire_gate_arithmetic:GetPhysicsObject():EnableCollisions( false )
wire_gate_arithmetic.nocollide = true wire_gate_arithmetic.nocollide = true

View File

@@ -60,8 +60,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_gate_comparison, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_gate_comparison, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_gate_comparison )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_gate_comparison:GetPhysicsObject():EnableCollisions( false ) wire_gate_comparison:GetPhysicsObject():EnableCollisions( false )
wire_gate_comparison.nocollide = true wire_gate_comparison.nocollide = true

View File

@@ -60,8 +60,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_gate_logic, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_gate_logic, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_gate_logic )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_gate_logic:GetPhysicsObject():EnableCollisions( false ) wire_gate_logic:GetPhysicsObject():EnableCollisions( false )
wire_gate_logic.nocollide = true wire_gate_logic.nocollide = true

View File

@@ -59,8 +59,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_gate_memory, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_gate_memory, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_gate_memory )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_gate_memory:GetPhysicsObject():EnableCollisions( false ) wire_gate_memory:GetPhysicsObject():EnableCollisions( false )
wire_gate_memory.nocollide = true wire_gate_memory.nocollide = true

View File

@@ -60,8 +60,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_gate_selection, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_gate_selection, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_gate_selection )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_gate_selection:GetPhysicsObject():EnableCollisions( false ) wire_gate_selection:GetPhysicsObject():EnableCollisions( false )
wire_gate_selection.nocollide = true wire_gate_selection.nocollide = true

View File

@@ -60,8 +60,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_gate_time, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_gate_time, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_gate_time )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_gate_time:GetPhysicsObject():EnableCollisions( false ) wire_gate_time:GetPhysicsObject():EnableCollisions( false )
wire_gate_time.nocollide = true wire_gate_time.nocollide = true

View File

@@ -60,8 +60,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_gate_trig, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_gate_trig, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_gate_trig )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_gate_trig:GetPhysicsObject():EnableCollisions( false ) wire_gate_trig:GetPhysicsObject():EnableCollisions( false )
wire_gate_trig.nocollide = true wire_gate_trig.nocollide = true

View File

@@ -53,8 +53,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_gps, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_gps, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_gps )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_gps:GetPhysicsObject():EnableCollisions( false ) wire_gps:GetPhysicsObject():EnableCollisions( false )
wire_gps.nocollide = true wire_gps.nocollide = true

View File

@@ -58,8 +58,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_gyroscope, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_gyroscope, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_gyroscope )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_gyroscope:GetPhysicsObject():EnableCollisions( false ) wire_gyroscope:GetPhysicsObject():EnableCollisions( false )
wire_gyroscope.nocollide = true wire_gyroscope.nocollide = true

View File

@@ -78,9 +78,8 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity != NULL && !trace.Entity:IsWorld() ) then if ( trace.Entity != NULL && !trace.Entity:IsWorld() ) then
const = constraint.Weld( trace.Entity, wire_ball, trace.PhysicsBone, 0, 0, true ) const = constraint.Weld( trace.Entity, wire_ball, trace.PhysicsBone, 0, 0, true, true )
nocollide = constraint.NoCollide( trace.Entity, wire_ball, 0, trace.PhysicsBone ) nocollide = constraint.NoCollide( trace.Entity, wire_ball, 0, trace.PhysicsBone )
trace.Entity:DeleteOnRemove( wire_ball )
wire_ball:GetPhysicsObject():EnableCollisions( false ) wire_ball:GetPhysicsObject():EnableCollisions( false )
wire_ball:GetTable().nocollide = true wire_ball:GetTable().nocollide = true

View File

@@ -61,8 +61,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
local const2 = constraint.Weld( controller, trace.Entity, 0, trace.PhysicsBone, 0, true ) local const2 = constraint.Weld( controller, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( controller )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
controller:GetPhysicsObject():EnableCollisions( false ) controller:GetPhysicsObject():EnableCollisions( false )
controller.nocollide = true controller.nocollide = true

View File

@@ -101,8 +101,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_indicator, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_indicator, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_indicator )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
if ( collision == 0 ) then if ( collision == 0 ) then

View File

@@ -63,8 +63,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_input, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_input, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_input )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_input:GetPhysicsObject():EnableCollisions( false ) wire_input:GetPhysicsObject():EnableCollisions( false )
wire_input.nocollide = true wire_input.nocollide = true

View File

@@ -70,8 +70,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_light, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_light, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_light )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
if ( collision == 0 ) then if ( collision == 0 ) then

View File

@@ -48,8 +48,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_nailer, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_nailer, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_nailer )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_nailer:GetPhysicsObject():EnableCollisions( false ) wire_nailer:GetPhysicsObject():EnableCollisions( false )
wire_nailer:GetTable().nocollide = true wire_nailer:GetTable().nocollide = true

View File

@@ -57,8 +57,7 @@ function TOOL:LeftClick( trace )
local const, nocollide local const, nocollide
const = constraint.Weld( wire_output, trace.Entity, 0, trace.PhysicsBone, 0, collision == 0 ) const = constraint.Weld( wire_output, trace.Entity, 0, trace.PhysicsBone, 0, collision == 0, true )
trace.Entity:DeleteOnRemove( wire_output )
wire_output:GetPhysicsObject():EnableCollisions( false ) wire_output:GetPhysicsObject():EnableCollisions( false )
undo.Create("WireOutput") undo.Create("WireOutput")

View File

@@ -53,8 +53,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_pixel, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_pixel, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_pixel )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
if ( collision == 0 ) then if ( collision == 0 ) then

View File

@@ -46,8 +46,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_pod, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_pod, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_pod )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_pod:GetPhysicsObject():EnableCollisions( false ) wire_pod:GetPhysicsObject():EnableCollisions( false )
wire_pod:GetTable().nocollide = true wire_pod:GetTable().nocollide = true

View File

@@ -54,10 +54,23 @@ function TOOL:LeftClick( trace )
local min = wire_radio:OBBMins() local min = wire_radio:OBBMins()
wire_radio:SetPos( trace.HitPos - trace.HitNormal * (min.z-5) ) wire_radio:SetPos( trace.HitPos - trace.HitNormal * (min.z-5) )
// Don't weld to world
local const
if ( trace.Entity:IsValid() ) then
local const = constraint.Weld( wire_radio, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
// Don't disable collision if it's not attached to anything
if ( collision == 0 ) then
wire_radio:GetPhysicsObject():EnableCollisions( false )
wire_radio:GetTable().nocollide = true
end
end
undo.Create("WireRadio") undo.Create("WireRadio")
undo.AddEntity( wire_radio ) undo.AddEntity( wire_radio )
undo.SetPlayer( ply ) undo.SetPlayer( ply )
undo.AddEntity(const)
undo.Finish() undo.Finish()

View File

@@ -96,8 +96,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_ranger, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_ranger, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_ranger )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_ranger:GetPhysicsObject():EnableCollisions( false ) wire_ranger:GetPhysicsObject():EnableCollisions( false )
wire_ranger.nocollide = true wire_ranger.nocollide = true

View File

@@ -87,8 +87,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_relay, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_relay, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_relay )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_relay:GetPhysicsObject():EnableCollisions( false ) wire_relay:GetPhysicsObject():EnableCollisions( false )
wire_relay.nocollide = true wire_relay.nocollide = true

View File

@@ -43,24 +43,22 @@ function TOOL:LeftClick( trace )
if (not util.IsValidModel(self:GetClientInfo( "model" ))) then return false end if (not util.IsValidModel(self:GetClientInfo( "model" ))) then return false end
if (not util.IsValidProp(self:GetClientInfo( "model" ))) then return false end if (not util.IsValidProp(self:GetClientInfo( "model" ))) then return false end
local ply = self:GetOwner() local ply = self:GetOwner()
local Ang = trace.HitNormal:Angle() local Ang = trace.HitNormal:Angle()
local Smodel = self:GetClientInfo( "model" ) local Smodel = self:GetClientInfo( "model" )
// Extra stuff for Wire Screen (TheApathetic) // Extra stuff for Wire Screen (TheApathetic)
local SingleValue = self:GetClientNumber("singlevalue") == 1 local SingleValue = self:GetClientNumber("singlevalue") == 1
local SingleBigFont = self:GetClientNumber("singlebigfont") == 1 local SingleBigFont = self:GetClientNumber("singlebigfont") == 1
local TextA = self:GetClientInfo("texta") local TextA = self:GetClientInfo("texta")
local TextB = self:GetClientInfo("textb") local TextB = self:GetClientInfo("textb")
// Check to update screen if necessary (TheApathetic) // Check to update screen if necessary (TheApathetic)
if (trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_screen" && trace.Entity.pl == ply) then if (trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_screen" && trace.Entity.pl == ply) then
trace.Entity:SetSingleValue(SingleValue) trace.Entity:Setup(SingleValue, SingleBigFont, TextA, TextB)
trace.Entity:SetSingleBigFont(SingleBigFont)
trace.Entity:SetTextA(TextA) trace.Entity.SingleValue = SingleValue
trace.Entity:SetTextB(TextB) trace.Entity.SingleBigFont = SingleBigFont
trace.Entity.SingleValue = SingleValue
trace.Entity.SingleBigFont = SingleBigFont
trace.Entity.TextA = TextA trace.Entity.TextA = TextA
trace.Entity.TextB = TextB trace.Entity.TextB = TextB
return true return true
@@ -91,28 +89,21 @@ if (SERVER) then
local wire_screen = ents.Create( "gmod_wire_screen" ) local wire_screen = ents.Create( "gmod_wire_screen" )
if (!wire_screen:IsValid()) then return false end if (!wire_screen:IsValid()) then return false end
wire_screen:SetModel(Smodel) wire_screen:SetModel(Smodel)
// Extra stuff for Wire Screen (TheApathetic)
wire_screen:GetTable():SetTextA(TextA)
wire_screen:GetTable():SetTextB(TextB)
wire_screen:GetTable():SetSingleBigFont(SingleBigFont)
wire_screen:SetAngles( Ang ) wire_screen:SetAngles( Ang )
wire_screen:SetPos( Pos ) wire_screen:SetPos( Pos )
wire_screen:Spawn() wire_screen:Spawn()
// Put it here to update inputs if necessary (TheApathetic) wire_screen:Setup(SingleValue, SingleBigFont, TextA, TextB)
wire_screen:GetTable():SetSingleValue(SingleValue)
wire_screen:SetPlayer(pl) wire_screen:SetPlayer(pl)
local ttable = { local ttable = {
pl = pl, pl = pl,
Smodel = Smodel, Smodel = Smodel,
SingleValue = SingleValue, SingleValue = SingleValue,
SingleBigFont = SingleBigFont, SingleBigFont = SingleBigFont,
TextA = TextA, TextA = TextA,
TextB = TextB TextB = TextB
} }
table.Merge(wire_screen:GetTable(), ttable ) table.Merge(wire_screen:GetTable(), ttable )

View File

@@ -69,8 +69,7 @@ function TOOL:LeftClick(trace)
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const, nocollide = constraint.Weld( wire_sensor, trace.Entity, 0, trace.PhysicsBone, 0, true ) const, nocollide = constraint.Weld( wire_sensor, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_sensor )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_sensor:GetPhysicsObject():EnableCollisions( false ) wire_sensor:GetPhysicsObject():EnableCollisions( false )
wire_sensor.nocollide = true wire_sensor.nocollide = true

View File

@@ -121,7 +121,13 @@ function TOOL:LeftClick( trace )
if ( trace.Entity:IsValid() && _weld ) then if ( trace.Entity:IsValid() && _weld ) then
local const, nocollide = constraint.Weld( explosive, trace.Entity, 0, trace.PhysicsBone, 0, collision == 0 ) local const, nocollide = constraint.Weld( explosive, trace.Entity, 0, trace.PhysicsBone, 0, collision == 0 )
undo.AddEntity( const ) undo.AddEntity( const )
if (!_noparentremove) then trace.Entity:DeleteOnRemove( explosive ) end if (_noparentremove) then
local const, nocollide = constraint.Weld( explosive, trace.Entity, 0, trace.PhysicsBone, 0, collision == 0, false )
undo.AddEntity( const )
else
local const, nocollide = constraint.Weld( explosive, trace.Entity, 0, trace.PhysicsBone, 0, collision == 0, true )
undo.AddEntity( const )
end
end end
undo.SetPlayer( ply ) undo.SetPlayer( ply )

View File

@@ -68,8 +68,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_emitter, trace.Entity, 0, trace.PhysicsBone, 0, (collision == 0) ) const = constraint.Weld( wire_emitter, trace.Entity, 0, trace.PhysicsBone, 0, (collision == 0), true )
trace.Entity:DeleteOnRemove( wire_emitter )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_emitter:GetPhysicsObject():EnableCollisions( false ) wire_emitter:GetPhysicsObject():EnableCollisions( false )
wire_emitter.nocollide = true wire_emitter.nocollide = true

View File

@@ -61,8 +61,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_speedometer, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_speedometer, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_speedometer )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_speedometer:GetPhysicsObject():EnableCollisions( false ) wire_speedometer:GetPhysicsObject():EnableCollisions( false )
wire_speedometer.nocollide = true wire_speedometer.nocollide = true

View File

@@ -113,8 +113,7 @@ function TOOL:LeftClick(trace)
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const, nocollide = constraint.Weld( wire_target_finder, trace.Entity, 0, trace.PhysicsBone, 0, collision == 0 ) const, nocollide = constraint.Weld( wire_target_finder, trace.Entity, 0, trace.PhysicsBone, 0, collision == 0, true )
trace.Entity:DeleteOnRemove( wire_target_finder )
end end
undo.Create("WireTargetFinder") undo.Create("WireTargetFinder")

View File

@@ -103,8 +103,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const, nocollide = constraint.Weld( wire_thruster, trace.Entity, 0, trace.PhysicsBone, 0, collision ) const, nocollide = constraint.Weld( wire_thruster, trace.Entity, 0, trace.PhysicsBone, 0, collision, true )
trace.Entity:DeleteOnRemove( wire_thruster )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
if ( collision ) then if ( collision ) then
wire_thruster:GetPhysicsObject():EnableCollisions( false ) wire_thruster:GetPhysicsObject():EnableCollisions( false )

View File

@@ -123,9 +123,8 @@ function TOOL:LeftClick( trace, worldweld )
// Don't weld to world // Don't weld to world
if ( trace.Entity != NULL && (!trace.Entity:IsWorld() || worldweld) ) then if ( trace.Entity != NULL && (!trace.Entity:IsWorld() || worldweld) ) then
Weld( Ent1, Ent2, Bone1, Bone2, forcelimit, nocollide, deleteonbreak )
weld = constraint.Weld( trace.Entity, turret, trace.PhysicsBone, 0, 0 ) weld = constraint.Weld( trace.Entity, turret, trace.PhysicsBone, 0, 0, true, true )
trace.Entity:DeleteOnRemove( turret )
// Don't hit your parents or you will go to jail. // Don't hit your parents or you will go to jail.

View File

@@ -71,10 +71,23 @@ function TOOL:LeftClick( trace )
local min = wire_twoway_radio:OBBMins() local min = wire_twoway_radio:OBBMins()
wire_twoway_radio:SetPos( trace.HitPos - trace.HitNormal * (min.z-5) ) wire_twoway_radio:SetPos( trace.HitPos - trace.HitNormal * (min.z-5) )
// Don't weld to world
local const
if ( trace.Entity:IsValid() ) then
local const = constraint.Weld( wire_twoway_radio, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
// Don't disable collision if it's not attached to anything
if ( collision == 0 ) then
wire_twoway_radio:GetPhysicsObject():EnableCollisions( false )
wire_twoway_radio:GetTable().nocollide = true
end
end
undo.Create("WireTwoWay_Radio") undo.Create("WireTwoWay_Radio")
undo.AddEntity( wire_twoway_radio ) undo.AddEntity( wire_twoway_radio )
undo.SetPlayer( ply ) undo.SetPlayer( ply )
undo.AddEntity( const )
undo.Finish() undo.Finish()
ply:AddCleanup( "wire_twoway_radioes", wire_twoway_radio ) ply:AddCleanup( "wire_twoway_radioes", wire_twoway_radio )

View File

@@ -59,8 +59,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
const = constraint.Weld( wire_value, trace.Entity, 0, trace.PhysicsBone, 0, true ) const = constraint.Weld( wire_value, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( wire_value )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
wire_value:GetPhysicsObject():EnableCollisions( false ) wire_value:GetPhysicsObject():EnableCollisions( false )
wire_value.nocollide = true wire_value.nocollide = true

View File

@@ -77,7 +77,7 @@ function TOOL:LeftClick( trace )
// Create the wheel // Create the wheel
local wheelEnt = MakeWireWheel( ply, trace.HitPos, Angle(0,0,0), model, nil, nil, nil, fwd, bck, stop ) local wheelEnt = MakeWireWheel( ply, trace.HitPos, Angle(0,0,0), model, nil, nil, nil, fwd, bck, stop, toggle )
// Make sure we have our wheel angle // Make sure we have our wheel angle
@@ -109,18 +109,17 @@ function TOOL:LeftClick( trace )
undo.AddEntity( wheelEnt ) undo.AddEntity( wheelEnt )
undo.SetPlayer( ply ) undo.SetPlayer( ply )
undo.Finish() undo.Finish()
ply:AddCleanup( "wire_wheels", axis ) ply:AddCleanup( "wire_wheels", axis )
ply:AddCleanup( "wire_wheels", constraint ) ply:AddCleanup( "wire_wheels", constraint )
ply:AddCleanup( "wire_wheels", wheelEnt ) ply:AddCleanup( "wire_wheels", wheelEnt )
wheelEnt:GetTable():SetMotor( constraint ) wheelEnt:SetMotor( constraint )
wheelEnt:GetTable():SetDirection( constraint:GetTable().direction ) wheelEnt:SetDirection( constraint.direction )
wheelEnt:GetTable():SetAxis( trace.HitNormal ) wheelEnt:SetAxis( trace.HitNormal )
wheelEnt:GetTable():SetToggle( toggle ) wheelEnt:SetToggle( toggle )
wheelEnt:GetTable():DoDirectionEffect() wheelEnt:DoDirectionEffect()
wheelEnt:GetTable():SetBaseTorque( torque ) wheelEnt:SetBaseTorque( torque )
return true return true
@@ -166,10 +165,10 @@ if ( SERVER ) then
/*--------------------------------------------------------- /*---------------------------------------------------------
For duplicator, creates the wheel. For duplicator, creates the wheel.
---------------------------------------------------------*/ ---------------------------------------------------------*/
function MakeWireWheel( pl, Pos, Ang, Model, Vel, aVel, frozen, fwd, bck, stop ) function MakeWireWheel( pl, Pos, Ang, Model, Vel, aVel, frozen, fwd, bck, stop, toggle, direction, Axis, Data )
if ( !pl:CheckLimit( "wire_wheels" ) ) then return false end if ( !pl:CheckLimit( "wire_wheels" ) ) then return false end
local wheel = ents.Create( "gmod_wire_wheel" ) local wheel = ents.Create( "gmod_wire_wheel" )
if ( !wheel:IsValid() ) then return end if ( !wheel:IsValid() ) then return end
@@ -178,39 +177,32 @@ if ( SERVER ) then
wheel:SetAngles( Ang ) wheel:SetAngles( Ang )
wheel:Spawn() wheel:Spawn()
wheel:GetTable():SetPlayer( pl ) wheel:SetPlayer( pl )
if ( wheel:GetPhysicsObject():IsValid() ) then duplicator.DoGenericPhysics( wheel, pl, Data )
Phys = wheel:GetPhysicsObject()
if Vel then Phys:SetVelocity(Vel) end
if aVel then Phys:AddAngleVelocity(aVel) end
Phys:EnableMotion(frozen != true)
end
wheel:GetTable().model = model wheel.model = model
wheel:GetTable().fwd = fwd wheel.fwd = fwd
wheel:GetTable().bck = bck wheel.bck = bck
wheel:GetTable().stop = stop wheel.stop = stop
wheel:GetTable():SetFwd( fwd ) wheel:SetFwd( fwd )
wheel:GetTable():SetBck( bck ) wheel:SetBck( bck )
wheel:GetTable():SetStop( stop ) wheel:SetStop( stop )
if ( axis ) then
wheel.Axis = axis
end
/*local ttable = { if ( direction ) then
pl = pl, wheel:SetDirection( direction )
nocollide = nocollide, end
description = description,
Pos = Pos, if ( toggle ) then
Ang = Ang, wheel:SetToggle( toggle )
Model = Model, end
fwd = fwd,
bck = bck,
stop = stop
}
table.Merge( wheel:GetTable(), ttable )*/
pl:AddCount( "wire_wheels", wheel ) pl:AddCount( "wire_wheels", wheel )
@@ -219,9 +211,9 @@ if ( SERVER ) then
end end
duplicator.RegisterEntityClass( "gmod_wire_wheel", MakeWireWheel, "Pos", "Ang", "model", "Vel", "aVel", "frozen", "fwd", "bck", "stop" ) duplicator.RegisterEntityClass( "gmod_wire_wheel", MakeWireWheel, "Pos", "Ang", "model", "Vel", "aVel", "frozen", "fwd", "bck", "stop", "Axis", "Data" )
end end
function TOOL:UpdateGhostWireWheel( ent, player ) function TOOL:UpdateGhostWireWheel( ent, player )

View File

@@ -65,8 +65,7 @@ function TOOL:LeftClick( trace )
// Don't weld to world // Don't weld to world
if ( trace.Entity:IsValid() ) then if ( trace.Entity:IsValid() ) then
local const2 = constraint.Weld( controller, trace.Entity, 0, trace.PhysicsBone, 0, true ) local const2 = constraint.Weld( controller, trace.Entity, 0, trace.PhysicsBone, 0, true, true )
trace.Entity:DeleteOnRemove( controller )
// Don't disable collision if it's not attached to anything // Don't disable collision if it's not attached to anything
controller:GetPhysicsObject():EnableCollisions( false ) controller:GetPhysicsObject():EnableCollisions( false )
controller.nocollide = true controller.nocollide = true