- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register








The script repo is an archive of historical scripts. For modern scripts, or to post your own, please use the Scripts forum section.





Staff Pick: dFurnitureEditor


By Xenmai
Created: 2016/07/12 07:36:18 UTC-07:00 (7 years and 281 days ago)
Edited: 2017/04/09 16:09:24 UTC-07:00 (7 years and 10 days ago)
Likes: 2

Staff pick as of: 2016/07/12 13:01:15 UTC-07:00 (7 years and 281 days ago)
Denizen Version: Release Build #1631
Script Version: 0.10
Description:

dFurnitureEditor is an inventory GUI based furniture editor (surprise!). It lets you create and remove props, as well as add and tweak their model components, without even needing to open a script file. This is all done thanks to armor stands, and the changes take place as soon as you make them. No need for reloads.

Prop parts have some available options including: their offset position relative to the prop center, their rotation angles, wether or not they are small (small armor stands render smaller items), the item they hold, wether or not the player can sit on them and wether or not they emit fire particles.

If you want to get some sample props to get you started, you can do so at https://github.com/Xenmai/dFurnitureEditor/blob/master/Samples.yml. Just feel free to copy and paste the contents of the file into your Models.yml file inside your dFurnitureEditor folder. WARNING: Stop the server before pasting the samples, save the file, and then start it again. Manually editing the file while the server is live can result in data loss due to rollbacks and overrides.

It still lacks polishing and documentation, and I'll most likely add more utilities to it as time progresses.

For any questions regarding this script, or anything else, feel free to ping me in the IRC.

Usage:

/dfe edit -a *opens the main editor GUI

/dfe place Stool -p *places the prop named Stool at your current location with your current yaw

/dfe place Stool 0 *places the prop named Stool at your current location with yaw 0

/dfe remove 3 *removes the placed prop with ID

<--script-tracker-->
tags=furniture,props,chair,table,stool,decoration,models
<--!script-tracker-->


Download script | View raw script
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
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
84700

dFurnitureEditor_Version:
  type: version
  author: Xenmai
  name: dFurnitureEditor
  version: 0.10
  description: An advanced menu for editing and placing/removing furniture Models
  id: 98

#   _____                                          _    _____           _       _
#  / ____|                                        | |  / ____|         (_)     | |
# | |     ___  _ __ ___  _ __ ___   __ _ _ __   __| | | (___   ___ _ __ _ _ __ | |_ ___
# | |    / _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` |  \___ \ / __| '__| | '_ \| __/ __|
# | |___| (_) | | | | | | | | | | | (_| | | | | (_| |  ____) | (__| |  | | |_) | |_\__ \
#  \_____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_| |_____/ \___|_|  |_| .__/ \__|___/
#                                                                        | |
#                                                                        |_|
dFE_Command:
  type: command
  debug: false
  name: dfe
  description"Main dFE command. Allows for editing and placing Models."
  usage: /dfe [edit|place]
  aliases:
    - dfurnitureeditor
  allowed help:
    - determine <player.is_op||<context.server>>
  tab complete:
    - if !<player.is_op||<context.server>> queue clear
    - determine <li@edit|place.filter[starts_with[<context.args.last>]]>
  script:

  - if !<player.is_op||<context.server>> {
    - narrate "<red>You do not have permission for that command."
    - queue clear
  }

  - if <context.args.size.is[==].to[0]> {
    - narrate "> GENERAL dFE INFORMATION:"
    - narrate "Author: xenmai"
    - narrate "Denizen Version: Release Build #1623"
    - narrate "Script Version: 0.9 (alpha)"
  }

  - choose <context.args.get[1]||null>:

    # Opens the general dFE editor GUI.
    - case edit:
      - flag <player> dFE:!

      - if <context.args.size.is[==].to[2]> {
        - if <context.args.get[2].is[==].to[-a]> {
          - define model -all
        }
        else {
          - narrate "Invalid second argument specified. Please use -a, -s, -t, a positive integer or a model name."
          - queue clear
        }
      }
      else if <context.args.size.is[==].to[3]> {
        - if <context.args.get[2].is[==].to[-s]> {
          - define model <yaml[dFE_Placed_Props].read[<player.flag[dFE_Selection]>.model]>
        }
        else if <context.args.get[2].is[==].to[-t]> {
          - define model <yaml[dFE_Placed_Props].read[<player.target.flag[dFE.ID]>.model]>
        }
        else if <context.args.get[2].is[==].to[<context.args.get[2].as_int||null>]> && <context.args.get[2].is[MORE].to[0]> {
          - define model <yaml[dFE_Placed_Props].read[<context.args.get[2]>.model]>
        }
        else if <context.args.get[2].matches[<&lb>a-zA-Z0-9_<&rb>+]> {
          - define model <context.args.get[2]>
        }
        else {
          - narrate "Invalid second argument specified. Please use -a, -s, -t, a positive integer or a model name."
          - queue clear
        }
        - if <context.args.get[3].is[==].to[-a]> {
          - define part -all
        }
        else if <context.args.get[3].matches[<&lb>a-zA-Z0-9_<&rb>+]> {
          - define part <context.args.get[3]>
        }
        else {
          - narrate "Invalid third argument specified. Please use -a or a part name."
          - queue clear
        }
      }
      else {
        - narrate "Invalid number of arguments specified. Proper usage is '/dfe edit [-a/-s/-t/#/<&lt>model<&gt>] [-a/<&lt>part<&gt>]'."
        - queue clear
      }

      - run dFE_Task_Edit def:<def[model]>|<def[part]||null> instantly

    # Selects a placed prop for later ease of moving or removing.
    - case select:
      - if <context.args.size.is[!=].to[2]> {
        - narrate "Invalid number of arguments specified. Proper usage is '/dfe select [-t/#]'."
        - queue clear
      }

      - if <context.args.get[2].is[==].to[-t]> {
        - run dFE_Task_Select def:<player.target.flag[dFE.ID]> instantly
      }
      else if <context.args.get[2].is[==].to[<context.args.get[2].as_int||null>]> && <context.args.get[2].is[MORE].to[0]> {
        - run dFE_Task_Select def:<context.args.get[2]> instantly
      }
      else {
        - narrate "Invalid second argument specified. Please use -t or a positive integer."
      }

    # Moves a placed prop to your position.
    - case move:
      - if <context.args.size.is[!=].to[2]> {
        - narrate "Invalid number of arguments specified. Proper usage is '/dfe move [-s/#]'."
        - queue clear
      }

      - if <context.args.get[2].is[==].to[-s]> {
        - run dFE_Task_Move def:<player.flag[dFE_Selection]>|<player.location.block> instantly
      }
      else if <context.args.get[2].is[==].to[<context.args.get[2].as_int||null>]> && <context.args.get[2].is[MORE].to[0]> {
        - run dFE_Task_Move def:<context.args.get[2]>|<player.location.block> instantly
      }
      else {
        - narrate "Invalid second argument specified. Please use -s or a positive integer."
      }

    # Rotates a placed drop to a yaw.
    - case rotate:
      - if <context.args.size.is[!=].to[3]> {
        - narrate "Invalid number of arguments specified. Proper usage is '/dfe rotate [-s/-t/#] [#]'."
        - queue clear
      }

      - if <context.args.get[2].is[==].to[-s]> {
        - run dFE_Task_Rotate def:<player.flag[dFE_Selection]>|<context.args.get[3]> instantly
      }
      else if <context.args.get[2].is[==].to[-t]> {
        - run dFE_Task_Rotate def:<player.target.flag[dFE.ID]>|<context.args.get[3]> instantly
      }
      else if <context.args.get[2].is[==].to[<context.args.get[2].as_int||null>]> && <context.args.get[2].is[MORE].to[0]> {
        - run dFE_Task_Rotate def:<context.args.get[2]>|<context.args.get[3]> instantly
      }
      else {
        - narrate "Invalid second argument specified. Please use -s, -t or a positive integer."
      }

    # Places a prop at your current location.
    # For example, '/dfe place Stool -p' will place a Stool model with your yaw.
    - case place:
      - if <context.args.size.is[!=].to[3]> {
        - narrate "Invalid number of arguments specified. Proper usage is '/dfe place [<&lt>model<&gt>] [-p/#.#]'."
        - queue clear
      }
      - if <context.args.get[3].is[==].to[-p]> {
        - run dFE_Task_Place def:<player.location.block>|<player.location.yaw>|<context.args.get[2]> instantly
      } else if <context.args.get[3].round_to[2]||false> || <context.args.get[3].is[==].to[<context.args.get[3].as_int||null>]> {
        - run dFE_Task_Place def:<player.location.block>|<context.args.get[3].round_to[2]>|<context.args.get[2]> instantly
      } else {
        - narrate "Invalid third argument specified. Please use -p or a number."
      }

    # Removes a prop at your current location.
    # For example, '/dfe remove -t' will remove the placed movel you are looking at.
    - case remove:
      - if <context.args.size.is[!=].to[2]> {
        - narrate "Invalid number of arguments specified. Proper usage is '/dfe remove [-s/-t/#]'."
        - queue clear
      }
      - if <context.args.get[2].is[==].to[-s]> {
        - run dFE_Task_Remove def:<player.flag[dFE_Selection]> instantly
      } else if <context.args.get[2].is[==].to[-t]> {
        - run dFE_Task_Remove def:<player.target.flag[dFE.ID]> instantly
      } else if <context.args.get[2].is[==].to[<context.args.get[2].as_int||null>]> && <context.args.get[2].is[MORE].to[0]> {
        - run dFE_Task_Remove def:<context.args.get[2]> instantly
      } else {
        - narrate "Invalid second argument specified. Please use -s, -t or a positive integer."
      }
    # Changes the placed prop with an old ID to a new one.
    - case changeid:
      - if <context.args.size.is[!=].to[3]> {
        - narrate "Invalid number of arguments specified. Proper usage is '/dfe changeid [#] [#]'."
        - queue clear
      }
      - run dFE_Task_ChangeId def:<context.args.get[2]>|<context.args.get[3]> instantly

#  _______        _       _____           _       _
# |__   __|      | |     / ____|         (_)     | |
#    | | __ _ ___| | __ | (___   ___ _ __ _ _ __ | |_ ___
#    | |/ _` / __| |/ /  \___ \ / __| '__| | '_ \| __/ __|
#    | | (_| \__ \   <   ____) | (__| |  | | |_) | |_\__ \
#    |_|\__,_|___/_|\_\ |_____/ \___|_|  |_| .__/ \__|___/
#                                          | |
#                                          |_|
# Places certain model at a location with a specified yaw.
dFE_Task_Place:
  type: task
  debug: false
  definitions: loc|yaw|model
  script:

  - if <yaml[dFE_Models].list_keys[].contains[<def[model]>].not> {
    - narrate "Model with name <def[model]> doesn't exist. Make sure you're specifying the correct model."
    - queue clear
  }
  - light <def[loc].below> <def[loc].light>
  - light <def[loc].below.below> <def[loc].light>
  - define id 1
  - while <yaml[dFE_Placed_Props].list_keys[].contains[<def[id]>]> {
    - define id <def[id].add[1]>
  }
  - yaml id:dFE_Placed_Props set <def[id]>.location:<def[loc]>
  - yaml id:dFE_Placed_Props set <def[id]>.yaw:<def[yaw]>
  - yaml id:dFE_Placed_Props set <def[id]>.model:<def[model]>
  - foreach <yaml[dFE_Models].list_keys[<def[model]>]> {
    - define location l@<yaml[dFE_Models].read[<def[model]>.<def[value]>.location]>
    - define angle <yaml[dFE_Models].read[<def[model]>.<def[value]>.angle].split[,].as_list.parse[to_radians].separated_by[,]||0,0,0>
    - define small <yaml[dFE_Models].read[<def[model]>.<def[value]>.small]>
    - define item <yaml[dFE_Models].read[<def[model]>.<def[value]>.item]||air>
    - define type <yaml[dFE_Models].read[<def[model]>.<def[value]>.type]>
    - define sityaw <yaml[dFE_Models].read[<def[model]>.<def[value]>.yaw]||0>
    - spawn armor_stand[marker=true;max_health=0.1;visible=false;gravity=false;is_small=<def[small]>;equipment=air|air|air|<def[item]>;armor_pose=head|<def[angle]>] <def[loc].center.add[<def[location].rotate_around_y[<def[yaw].to_radians.mul[-1]>]>].with_pose[0,<def[yaw].add[<def[sityaw]>]>]> save:entity
    - if <def[type].is[==].to[sit]> {
      - flag <entry[entity].spawned_entities.after[li@]> dFE.Utility:Sit
      - adjust <entry[entity].spawned_entities.after[li@]> marker:false
    } else if <def[type].is[==].to[fire]> {
      - flag <entry[entity].spawned_entities.after[li@]> dFE.Utility:Fire
      - flag <entry[entity].spawned_entities.after[li@]> dFE.Burn_Time:<yaml[dFE_Models].read[<def[model]>.<def[value]>.time]>
      - adjust <entry[entity].spawned_entities.after[li@]> marker:false
    }
    - flag <entry[entity].spawned_entities.after[li@]> dFE.ID:<def[id]>
    - yaml id:dFE_Placed_Props set <def[id]>.entities:->:<entry[entity].spawned_entities.after[li@]>
  }
  - narrate "Placed <def[model]> at location <def[loc].simple> with ID <def[id]>."

# Removes certain placed prop.
dFE_Task_Remove:
  type: task
  debug: false
  definitions: id
  script:

  - if <def[id].is[==].to[<def[id].as_int>].not> || <def[id].is[LESS].to[0]> {
    - narrate "Invalid ID specified. Please use a positive integer."
    - queue clear
  }
  - if <yaml[dFE_Placed_Props].list_keys[].contains[<def[id]>].not> {
    - narrate "Placed prop with ID <def[id]> doesn't exist. Make sure you're specifying the correct ID."
    - queue clear
  }
  - light <yaml[dFE_Placed_Props].read[<def[id]>.location].as_location.below> reset
  - light <yaml[dFE_Placed_Props].read[<def[id]>.location].as_location.below.below> reset
  - remove <yaml[dFE_Placed_Props].read[<def[id]>.entities]>
  - narrate "Removed <yaml[dFE_Placed_Props].read[<def[id]>.model]> at location <yaml[dFE_Placed_Props].read[<def[id]>.location].as_location.simple> with ID <def[id]>."
  - yaml id:dFE_Placed_Props set <def[id]>:!

# Selects certain placed prop.
dFE_Task_Select:
  type: task
  debug: false
  definitions: id
  script:

  - if <def[id].is[==].to[<def[id].as_int>].not> || <def[id].is[LESS].to[0]> {
    - narrate "Invalid ID specified. Please use a positive integer."
    - queue clear
  }
  - if <yaml[dFE_Placed_Props].list_keys[].contains[<def[id]>].not> {
    - narrate "Placed prop with ID <def[id]> doesn't exist. Make sure you're specifying the correct ID."
    - queue clear
  }
  - flag <player> dFE_Selection:<def[id]>
  - narrate "Selected <yaml[dFE_Placed_Props].read[<def[id]>.model]> with ID <def[id]>."

# Moves certain placed prop to a location.
dFE_Task_Move:
  type: task
  debug: true
  definitions: id|loc
  script:

  - if <def[id].is[==].to[<def[id].as_int>].not> || <def[id].is[LESS].to[0]> {
    - narrate "Invalid ID specified. Please use a positive integer."
    - queue clear
  }
  - if <yaml[dFE_Placed_Props].list_keys[].contains[<def[id]>].not> {
    - narrate "Placed prop with ID <def[id]> doesn't exist. Make sure you're specifying the correct ID."
    - queue clear
  }
  - if <def[loc].is[==].to[<def[loc].as_location>].not> {
    - narrate "Invalid location specified. Please use a dLocation."
    - queue clear
  }
  - light <yaml[dFE_Placed_Props].read[<def[id]>.location].as_location.below> reset
  - light <yaml[dFE_Placed_Props].read[<def[id]>.location].as_location.below.below> reset
  - foreach <yaml[dFE_Placed_Props].read[<def[id]>.entities]> {
    - teleport <def[value]> <def[value].location.add[<def[loc]>].sub[<yaml[dFE_Placed_Props].read[<def[id]>.location].as_location>].with_pose[0,<def[value].location.yaw>]>
  }
  - light <def[loc].below> <def[loc].light>
  - light <def[loc].below.below> <def[loc].light>
  - yaml id:dFE_Placed_Props set <def[id]>.location:<def[loc]>
  - narrate "Moved <yaml[dFE_Placed_Props].read[<def[id]>.model]> with ID <def[id]> to location <def[loc].simple>."

# Rotates a placed drop to match a yaw.
dFE_Task_Rotate:
  type: task
  debug: false
  definitions: id|yaw
  script:

  - if <def[id].is[==].to[<def[id].as_int>].not> || <def[id].is[LESS].to[0]> {
    - narrate "Invalid ID specified. Please use a positive integer."
    - queue clear
  }
  - if <yaml[dFE_Placed_Props].list_keys[].contains[<def[id]>].not> {
    - narrate "Placed prop with ID <def[id]> doesn't exist. Make sure you're specifying the correct ID."
    - queue clear
  }
  - if !<def[yaw].round_to[2]||false> && <def[yaw].is[==].to[<def[yaw].as_int>].not> {
    - narrate "Invalid yaw specified. Please use a number."
    - queue clear
  }
  - foreach <yaml[dFE_Placed_Props].read[<def[id]>.entities]> {
    - teleport <def[value]> <yaml[dFE_Placed_Props].read[<def[id]>.location].as_location.center.add[<def[value].location.sub[<yaml[dFE_Placed_Props].read[<def[id]>.location].as_location.center>].rotate_around_y[<def[yaw].sub[<yaml[dFE_Placed_Props].read[<def[id]>.yaw]>].to_radians.mul[-1]>]>].with_pose[0,<def[yaw]>]>
  }
  - yaml id:dFE_Placed_Props set <def[id]>.yaw:<def[yaw]>
  - narrate "Rotated <yaml[dFE_Placed_Props].read[<def[id]>.model]> with ID <def[id]> to yaw <def[yaw]>."

# Opens the Editor Menu for certain model and part.
dFE_Task_Edit:
  type: task
  debug: false
  definitions: model|part
  script:

  - if <def[model]> == -all {
    - narrate "Opening main Editor menu."
    - inventory open d:in@Editor_Menu
    - queue clear
  }
  - if <yaml[dFE_Models].list_keys[].contains[<def[model]>].not> {
    - narrate "Model with name <def[model]> doesn't exist. Make sure you're specifying the correct model."
    - queue clear
  }
  - if <def[part]> == -all {
    - flag <player> dFE.Editing1:<def[model]>
    - narrate "Editing model <def[model]>."
    - inventory open d:in@Model_Menu
    - queue clear
  }
  - if <yaml[dFE_Models].list_keys[<def[model]>].contains[<def[part]>].not> {
    - narrate "Part with name <def[part]> doesn't exist. Make sure you're specifying the correct part."
    - queue clear
  }
  - flag <player> dFE.Editing1:<def[model]>
  - flag <player> dFE.Editing2:<def[part]>
  - narrate "Editing <def[part]> from model <def[model]>."
  - inventory open d:in@Part_Menu

# Changes the ID of a placed prop.
dFE_Task_ChangeId:
  type: task
  debug: false
  definitions: old|new
  script:

  - if <def[old].is[==].to[<def[old].as_int>].not> || <def[new].is[==].to[<def[new].as_int>].not> {
    - narrate "Invalid IDs specified. Please use two positive integers."
    - queue clear
  }
  - if <def[old].is[LESS].to[1]> || <def[new].is[LESS].to[1]> {
    - narrate "Invalid IDs specified. Please use two positive integers."
    - queue clear
  }
  - if <def[new]> >= <def[old]> {
    - narrate "The new id must be lower than the old one."
    - queue clear
  }
  - if <yaml[dFE_Placed_Props].list_keys[].contains[<def[old]>].not> {
    - narrate "Placed prop with ID <def[old]> doesn't exist. Make sure you're specifying the correct ID."
    - queue clear
  }
  - if <yaml[dFE_Placed_Props].list_keys[].contains[<def[new]>]> {
    - narrate "Placed prop with ID <def[new]> already exists. Make sure you're specifying an unused ID."
    - queue clear
  }
  - foreach <yaml[dFE_Placed_Props].list_keys[<def[old]>]> {
    - yaml id:dFE_Placed_Props set <def[new]>.<def[value]>:<yaml[dFE_Placed_Props].read[<def[old]>.<def[value]>]>
  }
  - yaml id:dFE_Placed_Props set <def[old]>:!
  - narrate "Changed placed prop with old ID <def[old]> to new ID <def[new]>"

# Updates placed models to match their latest values.
dFE_Task_Update:
  type: task
  debug: true
  definitions: model
  script:

  - foreach <yaml[dFE_Placed_Props].list_keys[]> {
    - if <yaml[dFE_Placed_Props].read[<def[value]>.model].is[==].to[<def[model]>]> {
      - define loc <yaml[dFE_Placed_Props].read[<def[value]>.location]>
      - define model <yaml[dFE_Placed_Props].read[<def[value]>.model]>
      - define yaw <yaml[dFE_Placed_Props].read[<def[value]>.yaw]>
      - define id <def[value]>
      - remove <yaml[dFE_Placed_Props].read[<def[id]>.entities]>
      - yaml id:dFE_Placed_Props set <def[id]>:!
      - yaml id:dFE_Placed_Props set <def[id]>.location:<def[loc]>
      - yaml id:dFE_Placed_Props set <def[id]>.model:<def[model]>
      - yaml id:dFE_Placed_Props set <def[id]>.yaw:<def[yaw]>
      - foreach <yaml[dFE_Models].list_keys[<def[model]>]> {
        - define location l@<yaml[dFE_Models].read[<def[model]>.<def[value]>.location]>
        - define angle <yaml[dFE_Models].read[<def[model]>.<def[value]>.angle].split[,].as_list.parse[to_radians].separated_by[,]>
        - define small <yaml[dFE_Models].read[<def[model]>.<def[value]>.small]>
        - define item <yaml[dFE_Models].read[<def[model]>.<def[value]>.item]||air>
        - define type <yaml[dFE_Models].read[<def[model]>.<def[value]>.type]>
        - define sityaw <yaml[dFE_Models].read[<def[model]>.<def[value]>.yaw]||0>
        - spawn armor_stand[marker=true;max_health=0.1;visible=false;gravity=false;is_small=<def[small]>;equipment=air|air|air|<def[item]>;armor_pose=head|<def[angle]>] <def[loc].center.add[<def[location].rotate_around_y[<def[yaw].to_radians.mul[-1]>]>].with_pose[0,<def[yaw].add[<def[sityaw]>]>]> save:entity
        - if <def[type].is[==].to[sit]> {
          - flag <entry[entity].spawned_entities.after[li@]> dFE.Utility:Sit
          - adjust <entry[entity].spawned_entities.after[li@]> marker:false
        } else if <def[type].is[==].to[fire]> {
          - flag <entry[entity].spawned_entities.after[li@]> dFE.Utility:Fire
          - flag <entry[entity].spawned_entities.after[li@]> dFE.Burn_Time:<yaml[dFE_Models].read[<def[model]>.<def[value]>.time]>
          - adjust <entry[entity].spawned_entities.after[li@]> marker:false
        }
        - flag <entry[entity].spawned_entities.after[li@]> dFE.ID:<def[id]>
        - yaml id:dFE_Placed_Props set <def[id]>.entities:->:<entry[entity].spawned_entities.after[li@]>
      }
    }
  }
  - narrate "Updated all placed props <def[model]> props."

# Plays fire in an entity position for a minute.
dFE_Task_Fire:
  type: task
  debug: true
  definitions: entity|time
  script:

  - if <def[time].is[==].to[<def[time].as_int>].not> || <def[time].is[LESS].than[1]> {
    - narrate "Invalid time specified!"
    - queue clear
  }
  - repeat <def[time].mul[2]> {
    - if <def[entity].is_spawned.not||true> {
      - queue clear
    }
    - if <def[entity].location.find.entities[player].within[16].size.is[MORE].than[0]> {
      - playeffect <def[entity].location> effect:flame data:0.001 quantity:<yaml[dFE_Models].read[<yaml[dFE_Placed_Props].read[<def[entity].flag[dFE.ID]>.model]>.quantity]> offset:0.05,0.05,0.05
    }
    - wait 10t
  }
# __          __        _     _    _____           _       _
# \ \        / /       | |   | |  / ____|         (_)     | |
#  \ \  /\  / /__  _ __| | __| | | (___   ___ _ __ _ _ __ | |_ ___
#   \ \/  \/ / _ \| '__| |/ _` |  \___ \ / __| '__| | '_ \| __/ __|
#    \  /\  / (_) | |  | | (_| |  ____) | (__| |  | | |_) | |_\__ \
#     \/  \/ \___/|_|  |_|\__,_| |_____/ \___|_|  |_| .__/ \__|___/
#                                                   | |
#                                                   |_|
dFE_World:
  type: world
  debug: false
  events:

    # Loads the files, or creates them if it doesn't exist yet.
    on server start:

    - foreach li@dFE_Models|dFE_Placed_Props {
      - if <server.has_file[/dFurnitureEditor/<def[value]>.yml]> {
        - yaml "load:/dFurnitureEditor/<def[value]>.yml" id:<def[value]>
      }
      else {
        - yaml create id:<def[value]>
        - yaml "savefile:/dFurnitureEditor/<def[value]>.yml" id:<def[value]>
      }
    }

    # Loads the files, or creates them if it doesn't exist yet.
    on reload scripts:
    
    - foreach li@dFE_Models|dFE_Placed_Props {
      - if <server.has_file[/dFurnitureEditor/<def[value]>.yml]> {
        - yaml "savefile:/dFurnitureEditor/<def[value]>.yml" id:<def[value]>
        - yaml "load:/dFurnitureEditor/<def[value]>.yml" id:<def[value]>
      }
      else {
        - yaml create id:<def[value]>
        - yaml "savefile:/dFurnitureEditor/<def[value]>.yml" id:<def[value]>
      }
    }

    # Saves and unloads the data.
    on shutdown:

    - foreach li@dFE_Models|dFE_Placed_Props {
      - yaml "savefile:/dFurnitureEditor/<def[value]>.yml" id:<def[value]>
      - yaml unload id:<def[value]>
    }

    # Listener for the Editor Menu. Prevents clicking items.
    on player clicks in Editor_Menu:
    
    - determine passively cancelled
    - choose <context.item.display.strip_color>:

      - case "Exit":
        - inventory close

      - case "Create Model":
        - inventory close
        - narrate "Enter name for the new model."
        - flag player dFE.CreateModel

      - default:
        - if <context.item.material> == m@workbench {
          - inventory close
          - flag player dFE.Editing1:<context.item.display.strip_color>
          - inventory open d:in@Model_Menu
        }

    # Prevents dragging items.
    on player drags in Editor_Menu:

    - determine cancelled

    # Listener for the Prop Menu. Prevents clicking items.
    on player clicks in Model_Menu:

    - determine passively cancelled
    - choose <context.item.display.strip_color>:

      - case "Return":
        - inventory open d:in@Editor_Menu

      - case "Delete Model":
        - if <player.has_flag[dFE.DeleteModel].not> {
          - flag <player> dFE.DeleteModel duration:2s
          - narrate "<yellow>Click again to confirm."
          - queue clear
        }
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>:!
        - narrate "Model <yellow><player.flag[dFE.Editing1]> <gray>deleted!"
        - inventory open d:in@Editor_Menu

      - case "Create Part":
        - inventory close
        - narrate "Enter name for the new part."
        - flag player dFE.CreatePart

      - default:
        - if <context.item.material> == m@armor_stand {
          - inventory close
          - flag player dFE.Editing2:<context.item.display.strip_color>
          - inventory open d:in@Part_Menu
        }

    # Prevents dragging items.
    on player drags in Model_Menu:

      - determine cancelled

    # Listener for the Part Menu. Prevents clicking items.
    on player clicks in Part_Menu:

    - determine passively cancelled
    - choose <context.item.display.strip_color>:

      - case "Return":
        - inventory open d:in@Model_Menu
      
      - case "Delete Part":
        - if <player.has_flag[dFE.DeletePart].not> {
          - flag <player> dFE.DeletePart duration:2s
          - narrate "<yellow>Click again to confirm."
          - queue clear
        }
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>:!
        - narrate "Part <yellow><player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]> <gray>deleted!"
        - inventory open d:in@Model_Menu
        
      - case "Type":
        - inventory close
        - narrate "Enter type of the element (normal, sit and fire allowed)."
        - flag player dFE.SetType

      - case "Location":
        - inventory close
        - narrate "Enter location offset value as x,y,z."
        - flag player dFE.SetLocation

      - case "Angle":
        - inventory close
        - narrate "Enter head angle values as a,b,c."
        - flag player dFE.SetAngle

      - case "Small":
        - inventory close
        - narrate "Small state toggled."
        - if <yaml[dFE_Models].read[<player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.small]> == true {
          - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.small:false
        }
        else {
          - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.small:true
        }
        - run dFE_Task_Update def:<player.flag[dFE.Editing1]> instantly
        - inventory open d:in@Part_Menu

      - case "Item":
        - inventory close
        - narrate "Enter name of item to equip."
        - flag player dFE.SetItem
      
      - case "Time":
        - inventory close
        - if <context.click> == left {
          - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.time:++
        } else if <context.click> == right {
          - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.time:--
        }
        - run dFE_Task_Update def:<player.flag[dFE.Editing1]> instantly
        - inventory open d:in@Part_Menu
        
      - case "Yaw":
        - inventory close
        - if <context.click> == left {
          - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.yaw:++
        } else if <context.click> == right {
          - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.yaw:--
        }
        - run dFE_Task_Update def:<player.flag[dFE.Editing1]> instantly
        - inventory open d:in@Part_Menu
        
    # Prevents dragging items.
    on player drags in Part_Menu:

    - determine cancelled

    # Listens to the chat as input for names and values.
    on player chats:

    # Enter name for the new prop.
    - if <player.has_flag[dFE.CreateModel]> {
      - determine passively cancelled
      # Checks for input to be alphanumerical & _.
      - if <context.message.matches[<&lb>a-zA-Z0-9_<&rb>+].not> {
        - narrate "Prop names must be alphanumerical & _, please try again with a valid name."
        - queue clear
      }
      - if <yaml[dFE_Models].list_keys[].contains[<context.message>]> {
        - narrate "Prop name <context.message> already in use!"
      }
      else {
        - yaml id:dFE_Models set <context.message>:empty
        - narrate "Prop <context.message> created!"
      }
      - flag player dFE.CreateModel:!
      - flag player dFE.Editing1:<context.message>
      - inventory open d:in@Model_Menu
      
    # Enter name for the new part.
    } else if <player.has_flag[dFE.CreatePart]> {
      - determine passively cancelled
      # Checks for input to be alphanumerical & _.
      - if <context.message.matches[<&lb>a-zA-Z0-9_<&rb>+].not> {
        - narrate "Part names must be alphanumerical & _, please try again with a valid name."
        - queue clear
      }
      - if <yaml[dFE_Models].list_keys[<player.flag[dFE.Editing1]>].contains[<context.message>]> {
        - narrate "Part name already in use!"
      }
      else {
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<context.message>.location:0,0,0
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<context.message>.angle:0,0,0
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<context.message>.small:false
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<context.message>.item:stone
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<context.message>.type:normal
        - narrate "Part <context.message> created!"
      }
      - flag player dFE.CreatePart:!
      - flag player dFE.Editing2:<context.message>
      - inventory open d:in@Part_Menu

    # Enter location offset value as x,y,z.
    } else if <player.has_flag[dFE.SetLocation]> {
      - determine passively cancelled
      - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.location:<context.message>
      - narrate "Location offset set to <context.message>!"
      - run dFE_Task_Update def:<player.flag[dFE.Editing1]> instantly
      - flag player dFE.SetLocation:!
      - inventory open d:in@Part_Menu

    # Enter head angle values as a,b,c.
    } else if <player.has_flag[dFE.SetAngle]> {
      - determine passively cancelled
      - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.angle:<context.message>
      - narrate "Rotation angle set to <context.message>!"
      - run dFE_Task_Update def:<player.flag[dFE.Editing1]> instantly
      - flag player dFE.SetAngle:!
      - inventory open d:in@Part_Menu

    # Enter item name to equip.
    } else if <player.has_flag[dFE.SetItem]> {
      - determine passively cancelled
      - if <li@sit|fire.contains[<yaml[dFE_Models].read[<player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.type]>]> {
        - narrate "You can't give an item to a this type of element! Please change the element type to normal first."
        - queue clear
      }
      - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.item:<context.message>
      - narrate "Item name set to <context.message>!"
      - run dFE_Task_Update def:<player.flag[dFE.Editing1]> instantly
      - flag player dFE.SetItem:!
      - inventory open d:in@Part_Menu

    # Enter element type.
    } else if <player.has_flag[dFE.SetType]> {
      - determine passively cancelled
      - if <li@normal|sit|fire.contains[<context.message>].not> {
        - narrate "Invalid element type! Valid types are normal, sit and fire."
        - queue clear
      }
      - if <context.message> == normal {
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.item:air
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.time:!
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.yaw:!
      } else if <context.message> == sit {
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.item:!
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.time:!
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.yaw:0.0
      } else if <context.message> == fire {
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.item:!
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.time:15.0
        - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.yaw:!
      } else {
        - narrate "Invalid element type! Use normal, sit or fire."
        - queue clear
      }      
      - yaml id:dFE_Models set <player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.type:<context.message>
      - narrate "Element type set to <context.message>!"
      - run dFE_Task_Update def:<player.flag[dFE.Editing1]> instantly
      - flag player dFE.SetType:!
      - inventory open d:in@Part_Menu
    }

    # Listener for sitting components in placed Models.
    on player right clicks at entity:
    
    - determine passively cancelled
    - foreach <context.entity.location.find.entities[armor_stand].within[2].filter[has_flag[dFE.Utility]]> {
      - if <context.entity.flag[dFE.ID]> == <def[value].flag[dFE.ID]> {
        - define entity <def[value]>
      }
    }
    - choose <def[entity].flag[dFE.Utility]||null>:
    
      - case "Sit":
        - if <def[entity].has_passenger> && <def[entity].passenger.is[!=].to[<player>]||false> {
          - narrate "That position is already occupied by another person!"
          - queue clear
        }
        - mount <player>|<def[entity]> <def[entity].location>
      
      - case "Fire":
        - define time <def[entity].flag[dFE.Burn_Time]>
        - run dFE_Task_Fire def:<def[entity]>|<def[time].as_int> instantly
        
    # Hourly backups to avoid data loss on server crash. Also BC's script-tracker.
    on system time hourly:
    
    - webget "http://stats.denizenscript.com/tracker?script=98&players=<server.list_online_players.size>&script_version=0.8.2&models=<yaml[dFE_Models].list_keys[].size>&placed_props=<yaml[dFE_Placed_Props].list_keys[].size>&tps=<server.recent_tps>"

    - foreach li@dFE_Models|dFE_Placed_Props {
      - yaml "savefile:/dFurnitureEditor/<def[value]>.yml" id:dFE_<def[value]>
    }

#  _____                      _                      _____           _       _
# |_   _|                    | |                    / ____|         (_)     | |
#   | |  _ ____   _____ _ __ | |_ ___  _ __ _   _  | (___   ___ _ __ _ _ __ | |_ ___
#   | | | '_ \ \ / / _ \ '_ \| __/ _ \| '__| | | |  \___ \ / __| '__| | '_ \| __/ __|
#  _| |_| | | \ V /  __/ | | | || (_) | |  | |_| |  ____) | (__| |  | | |_) | |_\__ \
# |_____|_| |_|\_/ \___|_| |_|\__\___/|_|   \__, | |_____/ \___|_|  |_| .__/ \__|___/
#                                            __/ |                    | |
#                                           |___/                     |_|
Editor_Menu:
  type: inventory
  debug: false
  inventory: chest
  size: 54
  title"Editor Menu"
  slots:
  - "[i@green_wool[display_name=<&b>Exit]] [i@air] [i@blue_wool[display_name=<&b>Create Model]] [i@air] [] [] [] [] []"
  - "[i@air] [i@air] [i@air] [i@air] [] [] [] [] []"
  - "[] [] [] [] [] [] [] [] []"
  - "[] [] [] [] [] [] [] [] []"
  - "[] [] [] [] [] [] [] [] []"
  - "[] [] [] [] [] [] [] [] []"
  procedural items:
  - define items li@
  - foreach <yaml[dFE_Models].list_keys[].as_list.alphanumeric||li@> {
    - define items "<def[items].include[i@workbench[display_name=<&b><def[value]>;lore=<&d>Parts:|<yaml[dFE_Models].list_keys[<def[value]>].as_list.alphanumeric.after[li@]||None>]]>"
  }
  - determine <def[items]>

Model_Menu:
  type: inventory
  debug: false
  inventory: chest
  size: 54
  title"Model: <player.flag[dFE.Editing1]>"
  slots:
  - "[i@green_wool[display_name=<&b>Return]] [i@air] [i@red_wool[display_name=<&b>Delete Model]] [i@air] [i@blue_wool[display_name=<&b>Create Part]] [i@air] [] [] []"
  - "[i@air] [i@air] [i@air] [i@air] [i@air] [i@air] [] [] []"
  - "[] [] [] [] [] [] [] [] []"
  - "[] [] [] [] [] [] [] [] []"
  - "[] [] [] [] [] [] [] [] []"
  - "[] [] [] [] [] [] [] [] []"
  procedural items:
  - define items li@
  - foreach <yaml[dFE_Models].list_keys[<player.flag[dFE.Editing1]>].as_list.alphanumeric||li@> {
    - define part <def[value]>
    - define lore li@
    - foreach <yaml[dFE_Models].list_keys[<player.flag[dFE.Editing1]>.<def[part]>].as_list.alphanumeric> {
      - define lore "<def[lore].include[<&d><def[value]>: <&5><&o><yaml[dFE_Models].read[<player.flag[dFE.Editing1]>.<def[part]>.<def[value]>]>]>"
    }
    - define items "<def[items].include[i@armor_stand[display_name=<&b><def[part]>;lore=<def[lore]>]]>"
  }
  - determine <def[items]>

Part_Menu:
  type: inventory
  debug: false
  inventory: chest
  size: 18
  title"Model: <player.flag[dFE.Editing1]> Part<player.flag[dFE.Editing2]>"
  slots:
  - "[i@green_wool[display_name=<&b>Return]] [i@air] [i@red_wool[display_name=<&b>Delete Part]] [i@air] [] [] [] [] []"
  - "[i@air] [i@air] [i@air] [i@air] [] [] [] [] []"
  procedural items:
  - define items li@
  - foreach <yaml[dFE_Models].list_keys[<player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>].as_list.exclude[entities|marker].alphanumeric||li@> {
    - define items <def[items].include[i@paper[display_name=<&b><def[value]>;lore=li@<yaml[dFE_Models].read[<player.flag[dFE.Editing1]>.<player.flag[dFE.Editing2]>.<def[value]>]>]]>
  }
  - determine <def[items]>







View History