Paste #59457: undo command

Date: 2019/10/30 12:26:13 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


menu:
    type: world
    debug: true 
    events:
        on player quit:
            - flag player scoreboard:false
            # Start the Undo Command stuff
            #- if <yaml.list>:
            # clear the undo list
        on server start:
            - flag server start_time:<server.current_time_millis>
            # Start the Undo Command stuff
            - inject locally "events.on reload scripts"
        on reload scripts:
            # Start the Undo Command stuff
            - if <yaml.list> !contains editor_undo:
                - if <server.has_file[editor_undo]>:
                    - yaml load:editor_undo.yml id:editor_undo
                - else: 
                    - yaml create id:editor_undo
        on player joins:
            #make a yaml file entry to store a list of locations/materials for an undo command
            - narrate "<s@editor_undo.contains[<player.name>]>"
            # If the file does not have an entry for the player, make one
            - if <editor_undo.contains[<player.name>]> == false:
                #  Set an entry
                - yaml id:editor_undo set editor_undo.<player.name>:true
                # Save it so I can look at it and say hrmmm why still not work
                - yaml savefile:editor_undo.yml id:editor_undo
                - wait 2s
                # Cmon baby I know its in there....
                - narrate "set to <s@editor_undo.contains[<player.name>]>"

        on undo command:
            - determine passively FULFILLED
            - if !<player.is_op>:
                - queue clear
            - else:
                - inject locally "events.on player joins"