+ Reply to Thread
Results 1 to 8 of 8

Thread: How to add Advanced Dupe Support?

  1. #1
    Wire Noob snakesvx's Avatar
    Join Date
    Apr 2007
    Posts
    5

    Default How to add Advanced Dupe Support?

    Hi

    I'm working on a new RD (since TAD2020 seems absent) and well I need to know how to add Advanced Dupe support to it.

    What functions do I need to call?
    What Implementations do I need to add?

    ...

  2. #2
    Wire Noob Critical_Impact's Avatar
    Join Date
    May 2007
    Posts
    13

    Default Re: How to add Advanced Dupe Support?

    Quote Originally Posted by snakesvx View Post
    Hi

    I'm working on a new RD (since TAD2020 seems absent) and well I need to know how to add Advanced Dupe support to it.

    What functions do I need to call?
    What Implementations do I need to add?

    ...
    I'm no LUA expert, I did modify Fly by Wire to support Advanced Dupe and it just required this at the bottom of the entities init.lua

    Code:
    function ENT:OnRemove()
        Wire_Remove(self.Entity)
    end
    
    function ENT:OnRestore()
        Wire_Restored(self.Entity)
    end
    
    function ENT:BuildDupeInfo()
        return WireLib.BuildDupeInfo(self.Entity)
    end
    
    function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID)
        WireLib.ApplyDupeInfo( ply, ent, info, GetEntByID )
    end
    
    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

  3. #3
    Wire Noob Moyer's Avatar
    Join Date
    May 2008
    Posts
    9

    Default Re: How to add Advanced Dupe Support?

    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.

  4. #4
    Wirererer Free Fall's Avatar
    Join Date
    Dec 2007
    Location
    Got digitalized and now lives in his PC's RAM
    Posts
    349

    Default Re: How to add Advanced Dupe Support?

    I have a question to Adv. Dupe. support in entities too:

    How do i make entities paste frozen, if they were frozen before duping?

    always if i paste my self-coded things, they fall to ground, even if they were freeze before duping. And this is pretty bad for stability of things.


    So, has this to be done in the "ENT:ApplyDupeInfo" function or in the "duplicator.RegisterEntityClass" Line, or even somewhere else, nobody knows?
    Needz moar Lua

  5. #5
    Wire Sofaking IEF015's Avatar
    Join Date
    Feb 2008
    Location
    London, ON (Canada, eh?)
    Posts
    1,640

    Default Re: How to add Advanced Dupe Support?

    I THINK that where you put the ENT:ApplyDupeInfo and the duplicator.RegisterEntityClass, you just put "frozen".
    "It's my favourite country song. And I hate it."

  6. #6
    Wirererer Free Fall's Avatar
    Join Date
    Dec 2007
    Location
    Got digitalized and now lives in his PC's RAM
    Posts
    349

    Default Re: How to add Advanced Dupe Support?

    You mean like

    Code:
    duplicator.RegisterEntityClass("gmod_wire_ramcardreader", MakeWireRamCardReader, "Pos", "Ang", "frozen")
    ?

    I had this before, but I didn't have the effect I wanted. Is this not all I need, or wrong place?
    Needz moar Lua

  7. #7
    Wire Sofaking IEF015's Avatar
    Join Date
    Feb 2008
    Location
    London, ON (Canada, eh?)
    Posts
    1,640

    Default Re: How to add Advanced Dupe Support?

    I found this:

    Code:
        duplicator.RegisterEntityClass("gmod_wire_colorer", MakeWireColorer, "Pos", "outColor", "Range", "Model", "Ang", "Vel", "aVel", "frozen")
    ...inside lua/weapons/gmod_tools/stools/wire_colorer.lua

    I found nothing else that calls "frozen" anywhere in the script, even in the entities folder.
    "It's my favourite country song. And I hate it."

  8. #8
    Wire Noob Battle Bott's Avatar
    Join Date
    May 2007
    Location
    California
    Posts
    14

    Default Re: How to add Advanced Dupe Support?

    How do you get inputs and outputs to save correctly?
    My chip has dynamic ones, so they have to save with the chip. They are first created by parsing a string, and I made a function that does that correctly.

    But when you dupe it, it breaks. So far I have gotten it to pass the old table to the new function, but that still has all of the old entities.

    I have traced the path of inputs and outputs in the expression chip, but I got lost in the middle where it hits GateInputs.

    How do you transfer Inputs and Outputs through the duplicator? I'm going to try to just AdjustOutputs on the old tables and see if that works, but nothing I seem to do can maintain the old links.

+ Reply to Thread

Similar Threads

  1. Parenting with Advanced Duplicater Support
    By letsmosey in forum Installation and Malfunctions Support
    Replies: 10
    Last Post: 03-14-2009, 12:13 PM
  2. Adding dupe support to things
    By andy1976uk in forum Installation and Malfunctions Support
    Replies: 0
    Last Post: 02-03-2008, 12:44 PM
  3. Advanced Dupe
    By UltimateUnLTD in forum Wiremod General Chat
    Replies: 6
    Last Post: 01-10-2008, 06:21 PM
  4. ADVANCED Dupe
    By Ethan in forum Installation and Malfunctions Support
    Replies: 3
    Last Post: 07-06-2007, 10:43 AM
  5. Wired Support Tools & Adv. Dupe.
    By -=Fox=- in forum Bug Reports Archive
    Replies: 0
    Last Post: 05-11-2007, 05:24 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots