Paste #37164: Untitled Paste

Date: 2016/10/26 06:00:07 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


PD_Proc:
    type: procedure
    debug: false
    definitions: path|type|player
    script:
    - if <def[path].exists.not||true> {
        - queue clear
    }
    # - determine <yaml[<def[player].uuid||<player.uuid>>].read[<def[path]>]||null>
    - if <def[type].exists.not||true> {
        - define type read
    }
    - if <def[player].exists.not||true> {
        - define player <player>
    }
    - if <yaml.list.contains[<def[player].uuid||<player.uuid>>].not> {
        - if <server.has_file[<s@PlayerData_Data.yaml_key[config.save_path]><def[player].uuid||<player.uuid>>.yml].not||true> {
            - determine 0
        }
        - yaml "load:<s@PlayerData_Data.yaml_key[config.save_path]><def[player].uuid||<player.uuid>>.yml" id:<def[player].uuid||<player.uuid>>
    }
    - if <def[type]> == list {
        - defnie outcome <yaml[<def[player].uuid||<player.uuid>>].list_keys[<def[path]>]||0>
    }
    else if <def[type]> == has {
        - define outcome <yaml[<def[player].uuid||<player.uuid>>].contains[<def[path]>]||false>
    }
    else {
        - define outcome <yaml[<def[player].uuid||<player.uuid>>].read[<def[path]>]||0>
    }
    - if <def[player].is_online.not> {
        - if <yaml.list.contains[<def[player].uuid||<player.uuid>>]> {
            - yaml id:<def[player].uuid||<player.uuid>> "savefile:<s@PlayerData_Data.yaml_key[config.save_path]><def[player].uuid||<player.uuid>>.yml"
            - yaml unload id:<def[player].uuid||<player.uuid>>
        }
    }
    - determine <def[outcome]>