Paste #9384: Untitled Paste

Date: 2014/09/06 15:30:16 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


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
        }
      }