Date: 2014/05/09 13:10:02 UTC-07:00
Type: Denizen 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
################################################################################
# #
# Configurations #
# #
# These are the default configurations. They will be used to build the user #
# level config files on first run. Each parent node defines the file type and #
# the child nodes that follow are the configurations for that config file type.#
# #
#______________________________________________________________________________#
# #
#__________DO_NOT_EDIT_THIS_FILE___EVERYTHING_IS_CONFIGURABLE_IN_GAME__________#
# #
#______________________________________________________________________________#
'ConfigFileGeneratorTestConfigurations':
type: task
debug: false
# Where you save this script file
scriptPath: 'scripts/Network/Utilities/ConfigFileGeneratorTest.yml'
# ------ Single Value Test Config ------ #
singleValues:
keyA: 1
keyA: 0.1
keyA: -1
keyA: NaN
keyA: This is a StRiNg!
# ------ Single Lists ------ #
singleLists:
listA:
- 1
- 0.1
- -1
- NaN
- This is a StRiNg!
listB:
- 2
- 0.2
- -2
- nAn
- This is a sTrInG!
# ------ Recursive Lists ------ #
recursiveLists:
list1:
list1A:
value1: 1
list1:
- 1
- 2
list2:
list2A:
list2A1:
value1: 1
list1:
- 1
- 2
list2A2:
list2A2A:
value1: 1
value1:
- 1
- 2
################################################################################
#
# Config File Generator Test Helper
#
#
# This script tells the s@BasicConfigFileGenerator which files to generate based
# on the configs above.
#
"ConfigFileGeneratorTestHelper":
type: task
debug: true
script:
- ^define scriptPath '<s@ConfigFileGeneratorTest.constant[scriptPath]>'
- ^define readID 'ConfigFileGeneratorTest'
- ^yaml 'load:<def[scriptPath]>' 'id:%readID%'
- ^define keylist '<yaml[%readID%].list_keys[ConfigFileGeneratorTest].exclude[type|debug|scriptPath]>'
- foreach <def[keylist]> {
- define node <def[value]>
- if !<server.has_file[ConfigFileGeneratorTest/%node%.yml]> {
- narrate "<&a>Generating default %node%.yml file..."
- define basePath 'ConfigFileGeneratorTest'
- define writePath '%node%'
- define writeID 'ConfigFileGeneratorTest_%node%'
- yaml create 'id:%writeID%'
- inject s@ConfigFileGenerator
- narrate "<&b>Done!"
- if !<def[dryrun]> yaml savefile:ConfigFileGeneratorTest/%node%.yml 'id:%writeID%'
- yaml unload 'id:%writeID%'
}
else narrate "<&a>%node%.yml already exists!"
}
- narrate "<&6>Done!"
################################################################################
#
# Configuration File Generator
#
#
# This script generates default config files based on the definitions passed to
# it. It should be flexible enough to handle any script.
#
# - run s@ConfigFileGenerator def:%readID%|%writeID%|%basePath%|writePath
#
'BasicConfigFileGenerator':
type: task
debug: true
definitions: readID|writeID|basePath|writePath
script:
- ^define keylist '<yaml[%readID%].list_keys[%basePath%.%writePath%]>'
- ^foreach <def[keylist]> {
- define key '<def[value]>'
- define oldWritePath '%writePath%'
- define writePath '%writePath%.%key%'
- narrate "<&a>Next Path<&co> <&b>%basePath%.%writePath%"
- inject s@ConfigFileGenerator
- define writePath '%oldWritePath%'
- narrate "<&4>Done!"
}
- ^narrate "<&6>Done!"
"ConfigFileGeneratorTestCommand":
type: world
debug: false
events:
on cfgtest command:
- define dryrun true
- inject s@ConfigFileGeneratorTestHelper
- inject s@FinishCommand