Paste #13331: Untitled Paste

Date: 2015/01/24 14:26:23 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# +----------------------------------
# |   S.A.R.A.H 
# |   Self Actuated Real-Time Automated Helper
# +----------------------------------

Load_Sarah:
    type: task
    Script:
# Works
      - if <server.has_file[Sarah_Data.yml]> {
        - yaml "load:/Data/Sarah_Data.yml" id:Sarah_D
        - narrate "<dark_green>Loading <gold>S.A.R.A.H<dark_green>'s Data"
        } else {
        - yaml create id:Sarah_D
        - narrate "<red>Couldn't find Data file."
        - narrate "<dark_green>Creating new <gold>Sarah_Data.yml <dark_green>file"
        - yaml id:Sarah_D set Failed.Message:->:Temp
        - yaml id:Sarah_D set Failed.Message:<-:Temp
        - yaml id:Sarah_D set Failed.Definition:->:Temp
        - yaml id:Sarah_D set Failed.Definition:<-:Temp
        - yaml id:Sarah_D set Statistics.Fails:1
        - yaml id:Sarah_D set Statistics.Requests.Who_Am_I:0

        - yaml id:Sarah_D set Fun.Quotes.wonderdude:->:Don<&sq>t<&sp>be<&sp>a<&sp>Drem,<&sp>be<&sp>an<&sp>optimist!
        - yaml id:Sarah_D set Fun.Quotes.Drem_:->:Tests by Dr. Drem
        - yaml id:Sarah_D set Fun.Quotes.Unknown:->:Some<&sp>say<&sp>the<&sp>original<&sp>server<&sq>s<&sp>name<&sp><&dq>Erecia<&dq><&sp>was<&sp>related<&sp>to<&sp>a<&sp>certain<&sp>masculine<&sp>feature,<&sp>but<&sp>who<&sp>can<&sp>say<&sp>for<&sp>sure.
        - yaml "savefile:/Data/Sarah_Data.yml" id:Sarah_D
        }

Save_Sarah:
    type: task
    Script:
      - yaml "savefile:/Data/Sarah_Data.yml" id:Sarah_D
      - narrate "<dark_green>Saving <gold>S.A.R.A.H<dark_green>'s Data"
      - run Save_Sarah delay:10m



SARAH:
    type: world
    events:
        on player joins:
        - narrate Format:Sarah_F "Welcome back <gold><player.name>"
        - if <player.is_op> && (<yaml[Sarah_D].read[Failed.Message].size> != 0 || <yaml[Sarah_D].read[Failed.Definition].size> != 0) {
          - if <yaml[Sarah_D].read[Failed.Message].size> != 0 && <yaml[Sarah_D].read[Failed.Definition].size> != 0 {
            - if <yaml[Sarah_D].read[Failed.Message].size> > 1 && <yaml[Sarah_D].read[Failed.Definition].size> > 1 {
              - narrate Format:Sarah_F "I logged <gold><yaml[Sarah_D].read[Failed.Message].size> <red>Failed Messages <gray>and <gold><yaml[Sarah_D].read[Failed.Definition].size> <blue>Failed Definitions"
              } else if <yaml[Sarah_D].read[Failed.Message].size> > 1 && <yaml[Sarah_D].read[Failed.Definition].size> == 1 {
              - narrate Format:Sarah_F "I logged <gold><yaml[Sarah_D].read[Failed.Message].size> <red>Failed Messages <gray>and <gold><yaml[Sarah_D].read[Failed.Definition].size> <blue>Failed Definition"
              } else if <yaml[Sarah_D].read[Failed.Message].size> == 1 && <yaml[Sarah_D].read[Failed.Definition].size> > 1 {
              - narrate Format:Sarah_F "I logged <gold><yaml[Sarah_D].read[Failed.Message].size> <red>Failed Message <gray>and <gold><yaml[Sarah_D].read[Failed.Definition].size> <blue>Failed Definitions"
              } else {
              - narrate Format:Sarah_F "I logged <gold><yaml[Sarah_D].read[Failed.Message].size> <red>Failed Message <gray>and <gold><yaml[Sarah_D].read[Failed.Definition].size> <blue>Failed Definition"
              }
            } else if <yaml[Sarah_D].read[Failed.Message].size> != 0 && <yaml[Sarah_D].read[Failed.Definition].size> == 0 {
            - if <yaml[Sarah_D].read[Failed.Message].size> > 1 {
              - narrate Format:Sarah_F "I logged <gold><yaml[Sarah_D].read[Failed.Message].size> <red>Failed Messages"
              } else {
              - narrate Format:Sarah_F "I logged <gold><yaml[Sarah_D].read[Failed.Message].size> <red>Failed Message"
              }
            } else if <yaml[Sarah_D].read[Failed.Message].size> == 0 && <yaml[Sarah_D].read[Failed.Definition].size> != 0 {
            - if <yaml[Sarah_D].read[Failed.Definition].size> > 1 {
              - narrate Format:Sarah_F "I logged <gold><yaml[Sarah_D].read[Failed.Definition].size> <blue>Failed Definitions"
              } else {
              - narrate Format:Sarah_F "I logged <gold><yaml[Sarah_D].read[Failed.Definition].size> <blue>Failed Definition"
              }
            }
          }
        on player (first) login:
        - narrate Format:Sarah_F "Welcome to <gold>Arithia"
        on player chats:
        - if <context.message.starts_with[Sarah,]> || <context.message.starts_with[Sarah.]> {
          - inject locally Message_Type
          - determine passively cancelled
          - inject locally Control_Center
          }

# +----------------------------------
# |   Message Type
# +----------------------------------
    Message_Type:
# Attempt to add a way to narrate to a specific player. (FAILED)
    - if <context.message.starts_with[Sarah,<&sp>@]> || <context.message.starts_with[Sarah.<&sp>@]> {
      - define Targets <server.match_player[<context.message.regex[.*(\@)(\w+).*].group[2]>]>
      - narrate format:Sarah_F"<red><context.message.regex[.*(\@)(\w+).*].group[2]>" targets:%Targets%
      } else if <context.message.starts_with[Sarah,]> {
      - define Targets <player>
      } else {
      - define Targets <server.list_online_players>
      - wait 0.01
      - inject locally Control_Center
      }

# +----------------------------------
# |   Control Center
# +----------------------------------
    Control_Center:

# |   Questions
    # Who is Sarah
    - if <context.message.contains[who<&sp>are<&sp>you]> || <context.message.contains[what<&sp>are<&sp>you]> inject locally Who_Am_I
    # What time is it?
    - if <context.message.contains[what<&sp>time<&sp>is<&sp>it]> inject locally Current_Time
    # What am I looking at?
    - if <context.message.contains[what<&sp>am<&sp>i<&sp>looking<&sp>at]> || <context.message.contains[who<&sp>am<&sp>i<&sp>looking<&sp>at]> inject locally Looking_at
    # Where am I looking at?
    - if <context.message.contains[where<&sp>am<&sp>i<&sp>looking<&sp>at]> {
      - inject locally Looking_at_Location
      } else if <context.message.contains[where<&sp>am<&sp>i]> {
      - inject locally Location
      }

    # How far?
    - if <context.message.contains[how<&sp>far]> inject locally How_Far

    # How do I switch characters?
    - if <context.message.contains[switch<&sp>characters]> inject locally Switching_Characters
    # Character Commands
    - if <context.message.contains[character<&sp>commands]> inject locally Character_Help
    # What are the commands?
    - if <context.message.contains[commands]> || <context.message.contains[cmds]> inject locally Commands_Help
    # Who is ...?
    - if <context.message.contains[<&sp>who<&sp>is<&sp>]> inject locally Who_Is

    # 1 or 2?
    - if <context.message.contains[<&sp>or<&sp>]> inject locally 1_or_2

# |   Commands
    # Reload SARAH
    - if <context.message.contains[load<&sp>data]> inject locally Sarah_Load
    # Reload Scripts
    - if <context.message.contains[load<&sp>scripts]> inject locally Reload_Scripts
    # Save SARAH
    - if <context.message.contains[save<&sp>data]> inject locally Sarah_Save
    # Delete Failed Messages
    - if <context.message.contains[<&sp>clear<&sp>my<&sp>failed]> ||  <context.message.contains[<&sp>clear<&sp>failed]>  || <context.message.contains[<&sp>remove<&sp>failed]> {
      - inject locally Sarah_Remove_Failed
    # Failed
      } else if <context.message.contains[<&sp>failed]> {
      - inject locally Sarah_Failed
      }

    # Kick
    - if <context.message.starts_with[Sarah,<&sp>kick<&sp>]> || <context.message.starts_with[Sarah.<&sp>kick<&sp>]>inject locally CMD_Kick
    # ban
    - if <context.message.starts_with[Sarah,<&sp>ban<&sp>]> || <context.message.starts_with[Sarah.<&sp>ban<&sp>]> inject locally CMD_Ban

    # Tell (someone)
    - if <context.message.starts_with[Sarah,<&sp>tell<&sp>]> || <context.message.starts_with[Sarah.<&sp>tell<&sp>]> inject locally Tell_Player
    # Say
    - if <context.message.contains[Sarah,<&sp>say<&sp>]> || <context.message.contains[Sarah.<&sp>say<&sp>]> inject locally CMD_Say

    # countdown
    - if <context.message.contains[countdown]> inject locally CMD_Countdown

    # Day
    - if <context.message.contains[make<&sp>it<&sp>day]> || <context.message.contains[make<&sp>it<&sp>bright]> || <context.message.contains[make<&sp>it<&sp>shine]> inject locally CMD_Time_Day
    # Night
    - if <context.message.contains[make<&sp>it<&sp>night]> || <context.message.contains[make<&sp>it<&sp>dark]> inject locally CMD_Time_Night
    # Dawn
    - if <context.message.contains[make<&sp>it<&sp>morning]> inject locally CMD_Time_Dawn


    # Sun
    - if <context.message.contains[make<&sp>it<&sp>sunny]> || <context.message.contains[make<&sp>it<&sp>shine]> inject locally CMD_Weather_Sun
    # Storm
    - if <context.message.contains[make<&sp>it<&sp>rain]> || <context.message.contains[make<&sp>it<&sp>storm]> inject locally CMD_Weather_Storm

    # Website
    - if <context.message.contains[website]> inject locally CMD_Website


# |   Fun
    # Add quote
    - if <context.message.contains[add<&sp>quote<&sp>by<&sp>]> inject locally Fun_Add_Quote

    # Quote by
    - if <context.message.contains[quote<&sp>by<&sp>]> inject locally Fun_Quote_By

    # FUN quote
    - if <context.message.contains[show<&sp>me<&sp>a<&sp>quote]> || <context.message.contains[give<&sp>me<&sp>a<&sp>quote]> || <context.message.contains[<&sp>random<&sp>quote]> inject locally Fun_Random_quote

    # Slap
    - if <context.message.contains[<&sp>slap<&sp>]> inject locally Fun_Slap

    # Swag / Yolo
    - if <context.message.contains[swag]> || <context.message.contains[yolo]> inject locally Fun_bad_word


# |   Chatter
    # Thank you Sarah
    - if <context.message.contains[thank<&sp>you]> inject locally Chatter_Thank_You
    # World ending
    - if <context.message.contains[world<&sp>end]> || <context.message.contains[end<&sp>of<&sp>the<&sp>world]> inject locally Chatter_World_End
    # Penis
    - if <context.message.contains[penis]> inject locally Chatter_Penis
    # Dirty_Talk
    - if <context.message.contains[talk<&sp>dirty]> inject locally Chatter_dirty_Talk
    # Meaning of life
    - if <context.message.contains[meaning<&sp>of<&sp>life]> inject locally Chatter_Meaning_of_Life
    # Deal with it
    - if <context.message.contains[deal<&sp>with<&sp>it]> inject locally Chatter_Deal_With_it


    # Define What is
    - if <context.message.starts_with[Sarah,<&sp>define<&sp>]> || <context.message.starts_with[Sarah.<&sp>define<&sp>]> inject locally Define_What_Is
    # What is
    - if <context.message.starts_with[Sarah,<&sp>what<&sp>is<&sp>]> || <context.message.starts_with[Sarah.<&sp>what<&sp>is<&sp>]> inject locally What_Is


    # If the message, wasn't caught by any of the above. Save the message, so we can add it to Sarah, later.
    - define Number <yaml[Sarah_D].read[Statistics.Fails]>
    - narrate format:Sarah_F "Sorry I don't know that."
    - wait 1
    - narrate format:Sarah_F "I'm logging your message for self-improvement"
    - narrate format:Sarah_F "<red><player.name> <gray>logged a failed message<&co> <red><context.message>" targets:<server.list_online_ops>
    - yaml id:Sarah_D set Failed.Message:->:%Number%<&co><&sp><context.message>
    - yaml id:Sarah_D set Statistics.Fails:++
    - queue clear