Paste #45174: Edit of P#45173 - Untitled Paste

Date: 2017/10/24 07:43:35 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[20]> == 3 {
            - define question <yaml[Trivia].list_keys[key].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 key.<context.args.remove[first|last].space_separated>:<context.args.last>
            - narrate "<&a>Added question: <context.args.remove[first|last].space_separated> with answer: <context.args.last>."
            - yaml "savefile:dChatGames/Trivia.yml" id:Trivia