Date: 2014/09/06 15:30:16 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
editPackage:
# Still working on this
- define readID 'PerkPoints_packages'
- define writeID 'PerkPoints_packages'
- if !<yaml.list.contains[%readID%]> yaml 'load:<script.relative_filename>' 'id:%readID%'
# Did the user type in a package name?
- define pack '<c.args.get[3].replace[.].with[-].escaped||null>'
- if <def[pack].is[==].to[null]> {
- narrate "<&b>PerkPoints<&co> <&c>You must specify a package name!"
- announce "<&b>PerkPoints<&co> <&c>You must specify a package name!" to_console
- queue stop
}
- define readPath 'packages.%pack%'
- define writePath 'packages.%pack%'
# Does that package exist?
- define packList '<yaml[%readID%].list_keys[packages].exclude[ExamplePackage]||null>'
- if !<def[packList].contains[%pack%]> {
- narrate "<&b>PerkPoints<&co> <&c>Package <&b>%pack%<&c> does not exist!"
- announce "<&b>PerkPoints<&co> <&c>Package <&b>%pack%<&c> does not exist!" to_console
- queue stop
}
# Let's check the option the user wants to edit...
- define option '<c.args.get[4].replace[.].with[-].escaped||null>'
- define keylist <yaml[%readID%].list_keys[%readPath%]>
- if !<def[keylist].contains[%option%]> {
- narrate "<&b>PerkPoints<&co> <&f>Available Options"
- narrate "<&b>PerkPoints<&co> <&f><def[keylist].comma_separated>"
- queue stop
}
# Ok, that option exists, does it have sub-options?
- define optionsList <yaml[%readID%].list_keys[%readPath%.%option%]||null>
- if <def[optionsList].is_empty>
|| <def[optionsList].is[==].to[null]> {
- narrate "Do processing here..."
- queue stop
}
# There are sub options, let's check on that...
else {
- define subOption '<c.args.get[5].replace[.].with[-].escaped||null>'
- if !<def[optionsList].contains[%subOption%]> {
- narrate "<&b>PerkPoints<&co> <&f>Available Sub Options"
- narrate "<&b>PerkPoints<&co> <&f><def[optionsList].comma_separated>"
- queue stop
}
else {
- narrate "Do processing here..."
- queue stop
}
}