Template:ConfigKeyNotExist

From OpenKore Wiki
Revision as of 21:10, 4 July 2019 by 4epT (talk | contribs) (Created page with " <noinclude>This template describes the '''ConfigKeyNotExist''' state Conditions of the automacro eventMacros.</noinclude> ;ConfigKeyNotExist :* Descripti...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
This template describes the ConfigKeyNotExist state Conditions of the automacro eventMacros.
ConfigKeyNotExist
  • Description: Checks if the at least one of the config keys doesn't exist in config.txt.
Syntax:
ConfigKeyNotExist <comma separated list config keys>
Config key can be a variable
Example:
ConfigKeyNotExist gameGuard, saveMap
Set variables:
$.ConfigKeyNotExistLastKey => Saves the last config key that made ConfigKeyNotExist become true
$.ConfigKeyNotExistLastMemberIndex => Saves the list index in condition list that made ConfigKeyNotExist become true
Note: Good to be sure your custom config keys were added (can auto-configure plugins), example below with perl sub to add missing keys:
automacro AddgameGuardMissingKey {
    exclusive 1
    timeout 10
    overrideAI 1
    CheckOnAI auto, manual, off
    ConfigKeyNotExist gameGuard
    call {
        $wantedkey = $.ConfigKeyNotExistLastKey
        $wantedvalue = 1
        call AddMissingKey
    }
}

automacro AddcmdOnLoginMissingKey {
    exclusive 1
    timeout 10
    overrideAI 1
    CheckOnAI auto, manual, off
    ConfigKeyNotExist cmdOnLogin
    call {
        $wantedkey = $.ConfigKeyNotExistLastKey
        $wantedvalue = c \@autoloot
        call AddMissingKey
    }
}

macro AddMissingKey {
    log There is a missing key in config.txt
    log The key is $wantedkey
    log The wanted value for it is is $wantedvalue
    log Adding key $wantedkey with value $wantedvalue with perl sub 'add_key'
    add_key("$wantedkey","$wantedvalue")
}

sub add_key {
    my ($key, $value) = @_;
    configModify($key, $value);
}

This macro will make sure you added the config keys for gameGuard and cmdOnLogin plugin.