+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 14

Thread: Adv. Dupe Python library / CD adv. dupe generator

  1. #1
    Wirererer sk89q will become famous soon enough sk89q will become famous soon enough sk89q's Avatar
    Join Date
    Sep 2009
    Posts
    158

    Default Adv. Dupe Python library / CD adv. dupe generator

    I wrote a Python library to parse and write Adv. Dupe files.

    Here it is:
    sk89q's pyadvdupe at master - GitHub

    If you have setuptools, you can also do easy_install pyadvdupe.

    And here's a sample file to generate CD adv. dupe files:
    (Note: I haven't actually tested the following code, as the CD ray angers me, but it should work.)
    Code:
    import advdupe
    from advdupe.types import LuaTable, Vector, Angle, Player
    
    radius = 10
    precision = 4
    data = {
        # Sector.Track.Stack
        '1.1.0': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
        '5.3.0': [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
    }
    
    # ====================================
    
    # Build the data array
    out = {
        'IRadius': radius,
        'Precision': precision,
        'DiskMemory': {}
    }
    index = 0
    for i in data:
        out['DiskMemory'][i] = index
        out['DiskData%d' % index] = data[i]
        index = index + 1
    
    # Build the adv. dupe file
    doc = advdupe.AdvDupeDocument()
    doc.entities = \
        {1: {'Class': 'gmod_wire_cd_disk',
             'EntityMods': {'WireDupeInfo': out},
             'LocalAngle': Angle(0, 0, 0),
             'LocalPos': Vector(0, 0, 10),
             'Model': 'models/venompapa/wirecd_medium.mdl',
             'PhysicsObjects': {0: {'Frozen': True,
                                    'LocalAngle': Angle(0, 0, 0),
                                    'LocalPos': Vector(0, 0, 10)}},
             'Skin': 1}}
    
    # Output!
    print doc.dumps()
    
    Output:
    Code:
    [Info]
    Type:AdvDupe File
    Creator:"pyAdvDupe"
    Date:11/01/09
    Description:"none"
    Entities:1
    Constraints:0
    [More Information]
    FileVersion:0.84
    AdvDupeVersion:1.85
    AdvDupeToolVersion:1.9
    AdvDupeSharedVersion:1.72
    SerialiserVersion:1.4
    WireVersion:1722
    Time:09:55 PM
    Head:0,0,0
    HoldAngle:0,0,0
    HoldPos:0,0,0
    StartPos:0,0,0
    [Save]
    Entities:00000008{N:0=T:00000009;}00000009{Y:12=B:t;Y:10=V:0,0,10;Y:13=A:0,0,0;}H00000001{N:1=T:00000002;}00000002{Y:1=T:00000003;Y:10=V:0,0,10;Y:11=T:00000008;Y:13=A:0,0,0;Y:14=N:1;Y:15=Y:16;Y:17=Y:18;}00000003{Y:2=T:00000004;}00000004{Y:3=T:00000005;Y:6=N:10;Y:7=T:00000006;Y:8=N:4;Y:9=T:00000007;}00000005{Y:4=N:0;Y:5=N:1;}00000006{N:0=N:0;N:1=N:1;N:2=N:2;N:3=N:3;N:4=N:4;N:5=N:5;N:6=N:6;N:7=N:7;N:8=N:8;N:9=N:9;}00000007{N:0=N:10;N:1=N:11;N:2=N:12;N:3=N:13;N:4=N:14;N:5=N:15;N:6=N:16;N:7=N:17;N:8=N:18;N:9=N:19;}
    Constraints:H00000001{;}
    [Dict]
    1:"EntityMods"
    2:"WireDupeInfo"
    3:"DiskMemory"
    4:"1.1.0"
    5:"5.3.0"
    6:"IRadius"
    7:"DiskData0"
    8:"Precision"
    9:"DiskData1"
    10:"LocalPos"
    11:"PhysicsObjects"
    12:"Frozen"
    13:"LocalAngle"
    14:"Skin"
    15:"Model"
    16:"models/venompapa/wirecd_medium.mdl"
    17:"Class"
    18:"gmod_wire_cd_disk"
    Saved:2
    
    Last edited by sk89q; 11-02-2009 at 10:18 AM.

  2. #2
    Official Bastard of Wire



    Jat Goodwin is a splendid one to behold Jat Goodwin is a splendid one to behold Jat Goodwin is a splendid one to behold Jat Goodwin is a splendid one to behold Jat Goodwin is a splendid one to behold Jat Goodwin is a splendid one to behold Jat Goodwin is a splendid one to behold Jat Goodwin is a splendid one to behold Jat Goodwin's Avatar
    Join Date
    Aug 2008
    Location
    Colorado Springs
    Posts
    1,187

    Default Re: Adv. Dupe Python library / CD adv. dupe generator

    mmmm, delicious python....

    Actually I might be able to use this in my current project.


    I Require More Minions! Join us on the IRC!
    List of Reasons to idle on the IRC: Wire QDB

  3. #3
    no brain, no headache

    -HP- has a spectacular aura about -HP- has a spectacular aura about -HP-'s Avatar
    Join Date
    Feb 2009
    Location
    Behind you with a very sharp knife.
    Posts
    1,223

    Default Re: Adv. Dupe Python library / CD adv. dupe generator

    Quote Originally Posted by Jat Goodwin View Post
    mmmm, delicious python....

    Actually I might be able to use this in my current project.
    Current project?

    Project = learn moar python
    Why = work for ccp

    amirite?
    sry 4 my bad spelign, but enligh is my 2 langage



  4. #4
    Wire Sofaking Schilcote will become famous soon enough Schilcote's Avatar
    Join Date
    Jan 2009
    Location
    There.
    Posts
    1,189

    Default Re: Adv. Dupe Python library / CD adv. dupe generator

    Quote Originally Posted by Jat Goodwin View Post
    mmmm, delicious python....

    Actually I might be able to use this in my current project.
    Hmm. I seem to be incapable of having an original idea...


    Well this monster dosen't look to hard to defeOshit

  5. #5
    Wire Sofaking Vbitz will become famous soon enough Vbitz's Avatar
    Join Date
    Feb 2009
    Location
    NZ
    Posts
    528

    Default Re: Adv. Dupe Python library / CD adv. dupe generator

    can you have it write things like e2 and wire contraptions
    Questions, Comments and Concerns about any of
    my posts can be directed to my website which is at
    http://vbitz.wordpress.com on the comments post

    Quote Originally Posted by Bull View Post
    As example Jat Goodwin is "the official bastard of wiremod", but that isn't true.. He's very cute and huggable like a little puppy.

  6. #6
    Wirererer sk89q will become famous soon enough sk89q will become famous soon enough sk89q's Avatar
    Join Date
    Sep 2009
    Posts
    158

    Default Re: Adv. Dupe Python library / CD adv. dupe generator

    Yes. It can write everything, as all the data is there. The hard part is figuring out the format, but you can glean that off from reading the Lua files, or less preferably, opening saved adv. dupe files containing an example of what you want.

  7. #7
    Wire Sofaking Unsmart is on a distinguished road Unsmart's Avatar
    Join Date
    Dec 2008
    Location
    Slovakia OR BANland
    Posts
    932

    Default Re: Adv. Dupe Python library / CD adv. dupe generator

    Is it same as adv dup or better?


    May I suggest (original suggestion by ZP)

    1. create prop
    2. store mass to array. set every prop weight to 50,000
    3. create constraints
    4. apply original weight from array

  8. #8
    Wirererer sk89q will become famous soon enough sk89q will become famous soon enough sk89q's Avatar
    Join Date
    Sep 2009
    Posts
    158

    Default Re: Adv. Dupe Python library / CD adv. dupe generator

    It doesn't replace Adv. Dupe. It only can read/write Adv. Dupe files.

    For most tasks, you could just code an STool to do it. This is more for importing data from outside Gmod into the game through adv. dupe files, or perhaps generating objects on the fly from outside Gmod.

    Edit: On another note, I just noticed Schilcote's less than one week old thread about the adv. dupe format. Haha, I find that kind of funny.

  9. #9
    Wirererer emspike is on a distinguished road emspike's Avatar
    Join Date
    Feb 2008
    Location
    Chicagoland, Illinois
    Posts
    283

    Default Re: Adv. Dupe Python library / CD adv. dupe generator

    Quote Originally Posted by sk89q View Post
    On another note, I just noticed Schilcote's less than one week old thread about the adv. dupe format. Haha, I find that kind of funny.
    And you sir have ninja'd the WIP I talked about in said thread. Except mine wasn't scripted.

    EDIT: Seems I misread the post at first. Mine doesn't write them. It edits existing ones.

  10. #10
    Wirererer sk89q will become famous soon enough sk89q will become famous soon enough sk89q's Avatar
    Join Date
    Sep 2009
    Posts
    158

    Default Re: Adv. Dupe Python library / CD adv. dupe generator

    Mine does both.

+ Reply to Thread
Page 1 of 2
1 2 LastLast

Similar Threads

  1. Adv dupe help
    By megadeath141 in forum Wiremod General Chat
    Replies: 0
    Last Post: 08-06-2009, 11:00 PM
  2. E2 Dupe Help
    By xr34p3rx in forum Expression Help
    Replies: 7
    Last Post: 06-29-2009, 03:47 AM
  3. There is a Bug with Adv Dupe
    By Lol-Nade in forum Help & Support
    Replies: 10
    Last Post: 06-22-2009, 12:25 PM
  4. adv.dupe help
    By 1xinfusion in forum Help & Support
    Replies: 1
    Last Post: 08-02-2007, 05:07 PM
  5. Adv Dupe Gone?
    By Tricky in forum Bug Reports Archive
    Replies: 2
    Last Post: 05-21-2007, 01:43 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