Is YAML Modified (Condition) — skript-yaml

Addon: skript-yaml · Category: Condition · Since: 1.7.2

Syntax

y[a]ml %string% is (modified|unsaved)

Description

Checks if a YAML file has been modified since it was last loaded or saved.

Examples

# Basic check
yaml "config" is modified:
    broadcast "Config has unsaved changes!"
    save yaml "config"
# Negation
yaml "config" is not modified:
    broadcast "Config is up to date!"
# Synonyms
yaml "config" is unsaved:
    save yaml "config"
# Auto-save example
every 5 minutes:
    if yaml "playerdata" is modified:
        save yaml "playerdata"
        broadcast "Player data auto-saved!"
# Prevent data loss on quit
on quit:
    if yaml "playerdata" is modified:
        save yaml "playerdata"
        broadcast "Saved unsaved changes before shutdown!"
# Conditional save function
function saveIfModified(yamlId: text):
    if yaml "%{_yamlId}%" is modified:
        save yaml "%{_yamlId}%"
        return true
    return false
# Comment change triggers modified state
set yaml comment "A new comment" in "config"
if yaml "config" is modified:
    save yaml "config"

View source