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
Bookmarks