Paste #45214: Untitled Paste

Date: 2017/10/26 10:07:31 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


TRIVIA_BROADCAST: 
    type: world 
    events: 
        on system time minutely: 
        - if <util.random.int[1].to[1]> == 1 { 
            - define question <yaml[Trivia].list_keys[questions].random> 
            - announce "<&7>[<&3>BA<&b>ChatGames<&7>]<&b> <def[question].space_separated>" 
            - define answer <yaml.read[<def[question]>]> 
            - narrate "<&7>Answer: <def[answer]>" 
            - flag server active_question:<def[question]> 
            - flag server active_answer:<def[answer]> 
        } 
        on player chats: 
        - if <context.message> != <server.flag[answer]> 

TRIVIA_COMMAND: 
    type: command 
    name: trivia 
    script: 
    - choose <context.args.get[1]>: 
        - case "setup": 
            - if !<server.has_file[dChatGames/Trivia.yml]> { 
                - yaml create id:Trivia 
                - yaml "savefile:dChatGames/Trivia.yml" id:Trivia 
                - narrate "<&a>Trivia has been set up!" 
            } 
        - case "add": 
            - yaml load:dChatGames/Trivia.yml id:Trivia 
            - yaml id:Trivia set questions.<context.args.get[2]>:<context.args.get[3]> 
            - narrate "<&a>Added question: <context.args.get[2]> with answer: <context.args.get[3]>"
            - yaml "savefile:dChatGames/Trivia.yml" id:Trivia