Custom entities, advanced duplicator 2, and wiremod.

So I’ve been working on some custom entities that have a few wire inputs/outputs. Unfortunately, when I save and spawn the contraption with Adv Dupe 2, the entity spawns in unwired. Does anyone have experience with this? I’m not sure where to even begin, so any help is appreciated.

I suggest looking at source code of some simple wiremod entity, like Wire User. These are the bits you should be paying attention to:

DEFINE_BASECLASS( "base_wire_entity" )

duplicator.RegisterEntityClass("gmod_wire_user", WireLib.MakeWireEnt, "Data", "Range")

There’s another way with manually setting up all duplicator stuff without deriving from Wire Base but it’s more complex. Something like this:

function ENT:BuildDupeInfo()
    local info = WireLib.BuildDupeInfo(self) or {}
    --Store your custom dupe info if needed
    return info

function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID)
    -- Do something with info if needed
    WireLib.ApplyDupeInfo(ply, ent, info, GetEntByID)

function ENT:PreEntityCopy()
    local info = self:BuildDupeInfo()
    if not info then return end
    duplicator.StoreEntityModifier(self, "SomeName", info)

local function EntLookup(created)
    return function(id, def)
        local ent = created[id]
        return (IsValid(ent) and ent or def)

function ENT:PostEntityPaste(ply, ent, created)
    -- Notice "SomeName", it's the same as what you passed to StoreEntityModifier
    if ent.EntityMods and ent.EntityMods.SomeName then
        ent:ApplyDupeInfo(ply, ent, ent.EntityMods.SomeName, EntLookup(created))