Paste #23901: Finished?

Date: 2015/12/17 22:12:04 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


ActivityLogResetTask: 
    type: task 
    script: 
        - define date <util.date.time.duration.sub[d@<util.date.time.hour>h].sub[d@<util.date.time.minute>m].sub[d@<util.date.time.second>s]> 
        - if <yaml.list.contains[my_log_%date%].not> { 
            - foreach <yaml.list.filter[starts_with{my_log_]]> { 
                - yaml savefile:/Logs/<def[value].after[my_log_].as_duration.time.replace[<&sp>].with[_]>.yml id:%value% 
                - yaml unload id:%value% 
            } 
            - if <server.has_file[/Logs/<def[date].time.replace[<&sp>].with[_]>.yml]> 
            - yaml load:/Logs/<def[date].time.replace[<&sp>].with[_]>.yml id:my_log_%date% 
        } else { 
            - yaml create id:my_log_%date% 
        } 


ActivityLogManualSave:
    type: task
    script:
        - define date <util.date.time.duration.sub[d@<util.date.time.hour>h].sub[d@<util.date.time.minute>m].sub[d@<util.date.time.second>s]> 
        - if <yaml.contains[my_log_%date%]> {
            - yaml savefile:/Logs/<def[value].after[my_log_].as_duration.time.replace[<&sp>].with[_]>.yml id:%value%
        }


ActivityLogSaveCommand:
    type: command
    name: savelog
    script:
        - run ActivityLogManualSave instantly
        - narrate "Saved log."
        - determine fulfilled

ActivityLogReset: 
    type: world 
    events: 
        on server start: 
            - wait 1t 
            - run ActivityLogResetTask instantly 
        on system time hourly: 
            - run ActivityLogResetTask instantly 
        on system time minutely: 
            - if <context.minute.mod[10]> != 0 queue clear 
            - foreach <yaml.list.filter[starts_with{my_log_]]> { 
                - yaml savefile:/Logs/<def[value].after[my_log_].as_duration.time.replace[<&sp>].with[_]>.yml id:%value% 
            } 


ActivityLogger:
    type: world
    events:
        on player joins:
            - define date <util.date.time.duration.sub[d@<util.date.time.hour>h].sub[d@<util.date.time.minute>m].sub[d@util.date.time.second>s]>
            - if <yaml.list.contains[my_log_%date%]> {
                - yaml id:my_log_%date% set "<util.date.time.hour><&co><util.date.time.minute><&dot><util.date.time.second>: <player.name> joined."
                - flag player login_time:<util.date.time.duration>
            }
        on player quits:
            - define date <util.date.time.duration.sub[d@<util.date.time.hour>h].sub[d@<util.date.time.minute>m].sub[d@util.date.time.second>s]>
            - if <yaml.list.contains[my_log_%date%]> {
                - yaml id:my_log_%date% set "<util.date.time.hour><&co><util.date.time.minute><&dot><util.date.time.second>: <player.name> quit (<util.date.time.duration.sub[<player.flag[login_time]>].formatted>)."
                - flag player login_time:!
            }