All I had to do for my PID was this:
Code:
if (SERVER) then
/* Makes a PID loop */
function MakeWirePID(pl, Model, Pos, Ang, p, i, d, dcut, ilim, limit, nocollide, Vel, aVel, frozen)
local ent = ents.Create("gmod_wire_pid")
ent:SetAngles(Ang)
ent:SetPos(Pos)
ent:SetModel(Model)
ent:Spawn()
ent:SetupGains(p, i, d, dcut, ilim, limit)
ent:SetPlayer(pl)
return ent
end
/* Register us for duplicator compatibility */
duplicator.RegisterEntityClass("gmod_wire_pid", MakeWirePID, "Model", "Pos", "Ang", "p", "i", "d", "dcut", "ilim", "limit", "nocollide", "Vel", "aVel", "frozen")
end I have that in the STool lua, took the idea after checking out how the other wire tools add dup support. It seems that you make a function that handles the creation of the entity and register it with the duplicator. I just call the function in LeftClick() with the appropriate variables and everything works out.
Bookmarks