-
Notifications
You must be signed in to change notification settings - Fork 1
/
DSEditorScripts.nut
700 lines (601 loc) · 22.3 KB
/
DSEditorScripts.nut
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
/*#########################################
DSEditorScripts v0.1b - Still looking for a better name
It is important that the file is alphabetically behind DScript -> must be compiled after.
###########################################
!!READ BEFORE USE!!
These are a collection of scripts for Mission Designers which might make some work progress easier.
DAutoTxtRepl & DDumpModels are fine
DImportObj is not finally revised - When using it there is a high chance that you still get errors but I'm 95% confident that the origin will lie in the imported .str file and not in the code.
The DImportObj script is a very powerful one which let's you import, create & modify archetypes via script and a text file with the properties you want.
Further explanation in the .csv file. With the last DML patch this function became rather obsolete, but still allows a nice overview over your models and properties in a spreedsheet.
#######################
For DumpModels script:
#######################
Before you can use this script you have to do some additional work as a complete list of all filenames is needed.
*NEW: Use the DumpAllModels.cmd look for it in the obj folder.
• Open it with a text editor and SET OneLine=YES.
• Optional choose input and ouput folder and file.
1-3.) Obsolete now
4.) Open your output file. Go the the very end of you line and delete the last ,
5.) Copy everything and paste it into the [ ] brackets in the DDumpModels script class. TODO: In the next update I will move this up here.
6.) Save this file and open your DromEd. Make sure squirrel.osm is loaded.
7.) Create a any object and give it the DDumpModels script, remember it's ObjID for the next steps.
If you don't want to create screenshots you can start the progress.
In the editor write 'script_test ObjID'. This progress will be done in less than a minute.
IN CASE OF CRASH:
•In case of wrong models: The script will dump the models it has/tried to create in the last entries of monolog.txt you should find a clue which models make trouble. •Delete/Move the file and also delete the model name from the long "modelname" line.
•In case of memory problems -> Check the parameters below. Use First and MaxModels.
8.) Best to create your airbrushes now, when you see how small and big objects are distributed. I had no problems with ~400x200 air brushes.
TAKING SCREENSHOTS:
!--> WARNING: In cam_ext.cfg use screenshot_format BMP. --- PNG will TAKE AGES and possibly skip models! <---!
A) First you should create all models without screenshots and place your airbrushes accordingly.
B) Create a button/leaver and CD link it to the marker.
C) Create a second Marker name it Camera.
•Give it the property Renderer->CameraOverlay.
•Set it to active and set Alpha to 0
D) It's better to delete all models again so none obscours the camera. (Textures are preloaded as well so the chance of skipping a model due to high ress size is smaler)
E) Make sure you set the parameter Screenshots = 1 in the DesignNote.
•Press the Button in Game Mode.
If you machine is not so powerfull it could happen that some models are skipped, in that case you have to search for the line SetOneShotTimer("timer",0.15) and slightly increase the last number, e.g. to 0.2
-----
In the DesignNote the following optional parameters can be used (exactly) as written here:
First=Can be a model name or number Will start the process at the given ModelName or at the #th Model in your list.
MaxModels=1000 There can be trouble because to many models are created. With MaxModels you can set a limit to create for example just 100 models.
To continue the process where you left set First to the next Model after that. Order: First alphabetically shorter words come before: Mod before Model.
Default is 2000. I had no problems with 1300 - expect only at first with defect models which caused crashes.
Screenshots = 1 to create a screenshot for every model during the process. This will make it a LOT slower, especially if you enabled PNG format.
*/
####################################
# DAutoTxtRepl Preset Collection #
####################################
/*The DAutoTxtRepl script will automatically fill the Texture Replacement fields with a random texture out of a given set of textures on object creation.
This set can manually be assigned in the Design Note or out of the preset collection found below.
###############################################
SQUIRREL NOTE: We define this stuff globally here so not every script instance uses a copy. Modify to your liking.*/
ParseDone<-false
ModTable<-
{ //Standard is TexRep0, insert a number (1-3) behind a model name to change it to TexRep#
//a $ will be replaced by the entries in an array in the slot directly behind the model name: "Model$",["A","B"] -> "ModelA","ModelB"
//a # will be replaced by the numbers x->y specified a slot behind the model name "Model_#",1.3 -> Model_1,Model_2,Model_3
//All three optional variants can be combined but must be in the order Array,Float,integer
//"#$Worstcase",["a","b"],1.2,3 ->a1Worstcase,3,a2Worstcase,3,b1Worstcase,3,b2Worstcase,3
Pictures=["NVPictureFrame","QuaintMain","DL_Wpaint1","res_pntv","res_pnth"]
PictureFrames=[]
Posters=["#$Worstcase",["a","b"],1.4,1,"Anothercase$",["A","B"],1,"CaseC",1,"CaseD","blah","bluh"]
Bushes=["DBushR","DBushR#",2.5]
Branches=["5aLeaves","7aLeaves"]
Barks=["#$Tree",["a","b"],1.4,"DTrunk#$",["a","b"],1.4,"#$Trunk",["a","b"],1.2,"1aTrunklod1","1aTrunklod2","1aTrunkN","1bTrunkN","1bTrunklod1","1bTrunklod2","2aBushTrunk","2aTrunkLod1","2aTrunkLod2","2bTrunklod1","2bTrunklod2","3aTreelod1","3aTreelod2","3aTrunk","3aTrunklod1","3aTrunklod2","3bTreelod2","3bTrunkHP","3bTrunklod1","3bTrunklod2","3bTrunkLP","3cTree","3cTrunklod2","3cTrunklod1","3dTree","3dTrunk","3dTrunklod1","3dTrunklod2","4aTrunk","4aTrunklod2","DL_tabletrunk","TreeBoughtFarm","TreeTorB_01"]
DLeaves=["#$Tree",["a","b"],1.4,1,"DLeaves#$",["a","b"],1.4,"#$Leaves",["a","b"],1.4,"DLeaves3c","DLeaves3d","1aLeaveslod2","1bLeaveslod1","1bLeaveslod2","1bLeaveslod3","2bLeavesLod2","3aLeaveslod1","3aLeaveslod2","3aTreelod1",1,"3aTreelod2",1,"3bLeaveslod1","3bLeaveslod2","3bTreelod2",1,"3cTree",1,"3dTree",1,"4bLeavesLod2"],
Book31=["DBook","DBookB"] //Bind Cover ratio id 3:1
DBookWithSide=["DBook2","DBookB2"]
Banner=[]
Windows=["DWin1","DWin3","House07Win1","House07Win2"]
DoubleWindows=[]
Doors=["beldoor2"]
//If the Textures are in a SubTable the behind number indicates the max field that should be filled. So for example BookWithSide=[..,"MyBook(.bin)",1,..] would only get TexRepr0 and TexRepr1
//TODO: Does not work for 0
Buildings4R=["House05RTower",0,"House01R","House02R","House03R","House04R","House05R","House05Rb","House05RSingle","House06R"]
Roof=[]
CoSaSBeds=["jbg-nubed0#",1.9,"jbg-nubed10"]
}
TexTable<-
{
//A number behind a Texture will replace the # with 1->i for integer and for example 18->32 for float numbers.
//While it doesn't matter if a user doesn't have the models in ModTable you should make sure that the ones here in TexTable are provided or standard.
Pictures=["Paint1","Paint#",18.32,"picnic","RipOff",11,"RipOff",13.16] //These might Require EPv2
PictureFrames=[]
Posters=[]
Bushes=["PlantDa_#",20]
Branches=["falbrch","leaves#",4,"branch#",8,"v_Abranch","v_Abranch2","v_asp","v_branch","v_bush","v_fir","v_mapleaf","v_mapleaf2","smtrbrch","sprbrch","vindec3"]
Barks=["bark#256",6,"v_apbark","v_obark","v_mapbark","v_seqbark","v_vbrk","GBark"]
DLeaves=["leaves#",4],
Book31=
{
//Here these should be strings and a : instead of =
"0":["Book#",14],
"2":["DPage2Text"],
"3":["DBindBlack","DBindBlue","DBindGreen","DBindRed","DBindYel"],
}
DBookWithSide=
{
//string with #field names which should share the same randomed index both arrays must have the same size.
KeepIndex="01",
"0":["Book#-0",13],
"1":["Book#-1",13],
"2":["DPage2Text"],
"3":["DBindBlack","DBindBlue","DBindGreen","DBindRed","DBindYel"],
}
Windows=["win324","win324L","fam\\NVWindows\\DWin9","fam\\NVWindows\\Glass2","fam\\NVWindows\\hammer_window","fam\\NVWindows\\stainedglass03","fam\\NVWindows\\WinDiamond",2,"fam\\NVWindows\\win325l"]
Banner=["banner#",6,"banner8","banstar",3,"NVBanStar01"]
DoubleWindows=[]
Doors=[]
Buildings4R=
{
"0":["fam\\HQCity\\DCWall#",24]
"1":["fam\\HQCity\\DCWall#",24]
"2":["fam\\HQCity\\DCWall#",24]
"3":["fam\\HQCity\\DCWall#",24]
}
Roof=["roof","rooftile"],
CoSaSBeds=
{
KeepIndex="013",
"0":["jbg-bedsd-$",["i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],"jbg-bedsp02","jbg-bedsp0#",4.9,"jbg-bedsp#",10.12,"jbg-bedsp-$",["b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]]
"1":["jbg-bedra-$",["i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],"jbg-bedra02","jbg-bedra0#",4.9,"jbg-bedra#",10.12,"jbg-bedra-$",["b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]]
"2":["jbg-pillow-$",["c","g","d","b","b","g","d","d","b","h","c","g","b","d","b","h","b","e","b","d","h","b","c","c","e","b","c","h"],"jbg-pillow-$",["b","c","d","e","f","g","h","h","g","g","e","b","c","f","f","b","c","b","e","e","g","e","h","b","c"]]
}
}
####################################
class DAutoTxtRepl extends DBaseTrap
####################################
{
// ["NVPictureFrame","DBushR","DBushR2","DBushR3","DBushR4","DBushR5"]
DefOn="+TurnOn+test";
function DChangeTxtRepl(texarray,field=0,i=-1,obj=false,path="obj\\txt16\\")
{
if (!obj)
obj=self
if (i==-1) //If same index is desired
i=Data.RandInt(0,texarray.len()-1)
local tex = texarray[i]
if (startswith(tex,"fam\\"))
{path=""}
Property.Add(obj,"OTxtRepr"+field)
if (!(DGetParam(GetClassName()+"Lock",false)&&Property.Get(obj,"OTxtRepr"+field)!="")) //Should work without !=, Archetype definitions will be kept.
Property.SetSimple(obj,"OTxtRepr"+field, path+tex)
return i
}
function DParseTexArray(texarray)
{
local rem=[]
foreach (i,tv in texarray)
{
if (this=="ModTable"&&typeof(tv)=="string")
{
texarray[i]=tv.tolower()
continue
}
if (typeof(tv)=="array")
{
local tname=split(texarray[i-1],"$")
foreach (idx,char in tv)
{
char=char.tolower()
if (tname.len()>1)
texarray.append(tname[0]+char+tname[1])
else
texarray.append(tname[0]+char)
if (typeof(texarray[i+1])=="integer"||typeof(texarray[i+1])=="float") //Will parse numbers separetly later
{
texarray.append(texarray[i+1])
if (typeof(texarray[i+2])=="integer") //Will parse numbers separetly later "#$Worstcase",["a","b","c"],2.4,2
{
//print
texarray.append(texarray[i+2])
if (idx==tv.len()-1)
{
rem.append(i+2) //trash 1st generation
}
}
if (idx==0) //float XOR int trash
rem.append(i+1)
}
}
rem.append(i) //trash array and original
rem.append(i-1)
continue
}
local j=1
local ModInt=false
local noarbefore = (i==0||typeof(texarray[i-1])!="array")
if (typeof(tv)=="float"&&noarbefore)
{
tv=split(tv.tostring(),".")
j=tv[0].tointeger()
tv=tv[1].tointeger()
ModInt=true
}
if (typeof(tv)=="integer"&&(this=="TexTable"||ModInt)) //don't want to Parse for example Model-Leaves[1aTree,1]
{
local x=1
if (!noarbefore)
{
x=2
}
else
{
rem.append(i-x)
rem.append(i)
}
local tname=split(texarray[i-x],"#")
for (j;j<=tv;j++)
{
if (tname.len()>1)
texarray.append(tname[0]+j+tname[1])
else
texarray.append(tname[0]+j)
if (typeof(texarray[i+1])=="integer") //ModTable Beds=["Bed#",1.12,2] Parsing and a Field specified
{
texarray.append(texarray[i+1])
if (j==tv) //trash 2nd generation
{
rem.append(i+1)
}
}
}
}
}
//Trash preparsed entries
rem.sort()
for (local r=rem.len()-1;r>=0;r--)
{
texarray.remove(rem[r])
}
// Print result for control
/*
foreach (i,tv in texarray)
{
print(texarray+"["+i+"]="+tv)
}
*/
return texarray
}
############################################
function DoOn(DN) //TexTable={k=v[index i=tv] }
{
//Parse TexTablefor easier random use
if (!::ParseDone) //needs only be done once per Session
{
::ParseDone=true
foreach (k,v in TexTable)
{
if (typeof(v)=="array")
{
DParseTexArray.call("TexTable",v)
}
else //another table TexTable={ k= v={ k2=v2[index i=tv] } }
{
foreach (v2 in v)
{
if (typeof(v2)!="array") //KeepIndex. THIS IS THE PARSER
continue
DParseTexArray.call("TexTable",v2)
}
}
}
foreach (k,v in ModTable)
DParseTexArray.call("ModTable",v)
}
########### Actual Selection
type=DGetParam("DAutoTxtReplType",false,DN)
if (!type)
{//DetectionMode
local m = Property.Get(self,"ModelName").tolower()
foreach (k,v in ModTable)
{
local idx=v.find(m)
if (idx!=null)
{
//Check if custom tex field is specified.
local f = 0
if (!(idx==v.len()-1)&&typeof(v[idx+1])=="integer") //if its the last entry v[idx+1] would throw an error.
{
f = v[idx+1]
}
//Get Texture from a Array[]
if (typeof(TexTable[k])=="array")
{
DChangeTxtRepl(TexTable[k],f)
}
else //Get Textures from sub table like BookWithSide
{
local KeepIndex=[""]
if ("KeepIndex" in TexTable[k])
{
KeepIndex=[TexTable[k]["KeepIndex"],-1]
}
foreach (field, tv in TexTable[k]) //TexTable={ k=TexTbl[k]={ field=tv[...] } }
{
//TODO: Does not work for 0
if (typeof(tv)!="array"||f>0&&field.tointeger()>f) // KeepIndex case OR not all Fields should be used
continue
if (KeepIndex[0].find(field)!=null)
KeepIndex[1]=DChangeTxtRepl(tv,field,KeepIndex[1])
else
DChangeTxtRepl(tv,field)
}
}
}
//else
//That's wrong here print("DAutoTxtRepl ERROR: Didn't find a match for Shape ModelName "+m+". On Object "+self+. "Specify DAutoTxtReplType")
}
}
else
{
DChangeTxtRepl(TexTable[type],DGetParam("DAutoTxtReplField",0,DN))
}
}
/*For demo video
if (IsEditor()==2)
SetOneShotTimer("Change",1.5)
}
function OnTimer()
{
DoOn(userparams())
}
//*/
function constructor()
{
local DN=userparams()
local Mode = DGetParam("DAutoTxtReplMode",1,DN)
local Exe = IsEditor()
// 0 will only work when TurnedOn (standard Trap behavior) Default: TurnOn and script_test ObjID
// 1 (Default) Not automatically in game.exe
// 2 Everytime. PRO: Works on in game.exe created objects CONTRA: Also executes after save game loads. Consider DAutoTxtReplCount=1 (TODO: Check if compatible with BaseTrapConstructor) or (TODO:) No Overwrite option.
if (Mode!=0&&!(Exe+Mode==1))
DoOn(DN)
}
}
##########################################
class DDumpModels extends DBaseTrap
##########################################
{
MyModels =
[
"sam","GOTarch01","GOTarch02","JonSnow","Edd","slynt","GOTSWrd01","GOTSWrd02","NightKing","GOTSWrd03","Jeor1"
//COPY YOUR FILE NAMES INTO HERE. -- ONE LINE ONLY!!!!
//REMEMBER: remove the last , if you used DumpModels.cmd
//No need to modify for DImportObj!
]
xmax=0
v=vector()
m=""
i=0
count=0
MaxModels=2000
cam = null
function FoundSth(test,dump,v)
{
local o = null
if (typeof(test)=="string")
{
Property.SetSimple(-5739,"ModelName",test)
o = Object.Create(-2294)
Property.SetSimple(o,"ModelName",test)
Object.SetName(o,test)
}
else
{
o=Object.Create(test)
}
local v2 = Property.Get(o,"PhysDims","Size")
if (v2==0)
v2 = Property.Get(o,"PhysDims","Radius 1")
if (v2==0)
v2=vector(12,12,12)
else
v2=v2*2
local x = v2.x
local y = v2.y
local z = v2.z
if (x>xmax)
xmax=x
v.y += y/2
Object.Teleport(o,v,vector())
//Object.Teleport("player",v,vector())
//making the screenshot
if (dump)
{
local d = 0.62*y+0.5 //~cos(45)
Object.Teleport(cam,vector(v.x-d,v.y+d,v.z+v2.z/8+2),vector(0,32,-45))
if (i != 0)
Debug.Command("screen_dump",MyModels[i-1])
}
v.y += y/2+1
print(i+" "+m)
if (v.y > 400)
{
v.y = -380
v.x += xmax
xmax = xmax/4
if (v.x >900)
print("Maxiumum Area used ending the progress")
return v
}
return v
}
function OnTimer()
{
m= MyModels[i]
FoundSth(m,true,v)
i++
count++
if (count < MaxModels)
SetOneShotTimer("timer",0.15) //TIME BETWEEN SCREENSHOTS. Do not use png format in cam_ext.cfg
}
function DoOn(db)
{
local first = DGetParam("First",0,db)
local dump = DGetParam("Screenshots",false,db)
if (dump)
{
local cam = Object.Create("Marker")
Camera.StaticAttach(4)
}
count = 0
Property.Add(-5739,"ModelName")
cam = Object.Named("Camera")
if (typeof first == "string")
{first = MyModels.find(first)}
i= first
MaxModels = DGetParam("MaxModels",MyModels.len()-i,db)
v = vector(-380,-380,0)
if (dump)
SetOneShotTimer("timer",0.15)
else
{
for (local i = first;count < MaxModels;count++)
{
m= MyModels[i]
v = FoundSth(MyModels[i],dump,v)
i++
}
}
xmax = 0
count = 0
//Object.Destroy(self)
//Camera.ForceCameraReturn()
}
function OnMessage()
{
if (message().message == "Test")
DoOn(userparams())}
}
####################################################################
class DImportObj extends DDumpModels
####################################################################
{
DefOn="Test"
function DoOn(DN)
{
print("############## Starting Import ##############")
local DN=userparams()
local file = DGetParam(GetClassName()+"File","ImportObj.str")
local max = DGetParam(GetClassName()+"End",Data.GetString(file, "ObjMax","100","obj").tointeger()) //EndValue
local echooff = DGetParam(GetClassName()+"EchoOff",false)
local force = DGetParam(GetClassName()+"Force",false)
print("############## Importing file "+file+" with (max)"+max+" entries.##############")
//AutoImport -> DumpModels option via Editor variable
local ir = int_ref()
Engine.ConfigGetInt("create", ir)
if (ir.tointeger() != 0)
ir=true
local create = (DGetParam(GetClassName()+"Create",false)||ir)
if (create)
MyModels =[]
//------------
local i = DGetParam(GetClassName()+"Start",-10) //This (-10) adds 10 extra slots for forgotten Archetypes which might have no space later.
for (i;i<=max;i++)
{
local data = Data.GetString(file, "Obj"+i,"","obj") // !!!STRING FILE IN OBJ FOLDER!!!
##print(data)
if (i<0) //Negative entries are Obj_10, Obj_9...
{
local j = "_"+(i*-1).tostring()
data = Data.GetString(file, "Obj"+j,"","obj")
}
if (data=="") //Not found ->Skip
continue
data=split(data,"=;")
if (data[0]=="SKIP") //Manuall Skip
continue
local l = null
local name = strip(data[3])
local a = ObjID(name) // = 0 for non existent
local parent = strip(data[1])
if ((strip(data[2])=="FORCE"||force)&& a!=0)
l = Link.GetOne("MetaProp",ObjID(name)) //Get link from existing a to it's archetype
else
{
l = Link.GetOne("~MetaProp","MISSING") //Get first link and object in MISSING
a = LinkDest(l)
//Check if an empty Archetype is avaliable
if (! (a<0))
{
print("DImportObj - ERROR: No more convertable Archetypes in MISSING for Obj"+i+" \n!!!SCRIPT STOPPED!!!")
return
}
if (Object.Exists(name))
{
if (!echooff)
print("DImportObj - ERROR: Archetype with name "+name+"("+ObjID(name)+") already exists (Obj"+i+"). Check your Hierarchy or ImportObj.txt. SKIPPING")
continue
}
}
if (! (ObjID(parent)<0))
{
print("DImportObj - ERROR: New Parent Archetypes ("+parent+") for Obj"+i+"("+name+") does not exist. Check your Hierarchy or ImportObj.txt. SKIPPING")
continue
}
//Checks done go
//Changeing location
Link.Create("~MetaProp",parent,a)
Link.Destroy(l)
Object.SetName(a,name)
//Add Properties?
local j = data.len()
if (j > 4)
{
for (local k=4;k<j; k+=2)
{
local prop=split(strip(data[k]),":")
if (prop[0]=="")
continue
if (prop.len()==1)
{
if (prop[0]=="Meta")
Object.AddMetaProperty(a,DCheckString(strip(data[k+1])))
else
if (!startswith(DCheckString(strip(data[k+1])),"{"))
{
Property.Add(a,prop[0])
Property.SetSimple(a,prop[0],DCheckString(strip(data[k+1])))
}
else
{//Add multiple in {}
local prop2=split(strip(data[k+1]),"{:}")
for (local m =1; m<=prop2.len()-1;m+=2)
{
Property.Add(a,prop[0])
Property.Set(a,prop[0],prop2[m],DCheckString(strip(prop2[m+1])))
}
}
}
else
{
if (prop[0]=="Link")
{
local l =Link.Create(prop[1],a,DCheckString(prop[2]))
local prop2=split(strip(data[k+1]),":")
for (local m =1; m<=prop2.len();m+=2)
{
LinkTools.LinkSetData(l,prop2[m-1],DCheckString(prop2[m]))
}
}
else
Property.Set(a,prop[0],prop[1],DCheckString(strip(data[k+1])))
}
}
}
print("Imported "+name+"("+a+")")
if (create)
MyModels.append(a)
}
print("############## DImportObj complete ##############")
//Also Create the models?
if (create)
base.DoOn(DN)
}
}
####################################################################
class DAutoImport extends DImportObj
####################################################################
{
/*HOW TO USE (Suggestion)
CREATION:
Open a new map. Do NOT load squirrel.osm!
load_group DummyArches.vbr, this will give you enough dummy archetypes to export further.
Create any object and give it S->Script DAutoImport and DesignNote DImportObjFile="YourFileName.str".
Now multibrush this object (for example with the default JorgeBrush) and save_group -> AutoImportMyObjs.vbr (any name you want.vbr)
EXECUTION:
YourFileName.str goes into the obj Folder.
Squirrel script and DScript must be present and loaded.
load_group AutoImportMyObjs.vbr
And now all Archetypes were automatically created for the other user.
*/
constructor()
{
base.DoOn(userparams())
//Debug.Command("purge_missing_objs")
}
}