MV - YEP_OptionsCore - add option to control game variable.

● ARCHIVED · READ-ONLY
Started by Soulrender 3 posts View original ↗
  1. Before you write something stupid - I know well that you cannot game variables outside actuall game (except using dev console). But I'm struggling how to add to Options Core entry to control gameVariable's value via slider like to change window color tone.

    Here's some entries that fails to do the thing.
    Draw Option Code
    Code:
    var rect = this.itemRectForText(index);
    var statusWidth = this.statusWidth();
    var titleWidth = rect.width - statusWidth;
    this.resetTextColor();
    this.changePaintOpacity(this.isCommandEnabled(index));
    this.drawOptionsName(index);
    var value = this.getConfigValue(symbol);
    var rate = ((value) / 6).clamp(0, 1);
    if (value > 6) {
      var gaugeColor1 = this.textColor(14);
      var gaugeColor2 = this.textColor(6);
    } else {
      var gaugeColor1 = this.textColor(20);
      var gaugeColor2 = this.textColor(21);
    }
    this.drawOptionsGauge(index, rate, gaugeColor1, gaugeColor2);
    this.drawText("$soulrender.difficultyLevelLabel()", titleWidth, rect.y, statusWidth, 'center');

    Process OK code
    Code:
    var index = this.index();
    var symbol = this.commandSymbol(index);
    var value = this.getConfigValue(symbol);
    value += 1;
    if (value > 6) value = 1;
    value = value.clamp(1, 6);
    this.changeValue(symbol, value);
    $gameVariables.setValue(42, value);

    Cursor Right Code
    Code:
    var index = this.index();
    var symbol = this.commandSymbol(index);
    var value = this.getConfigValue(symbol);
    value += 1;
    value = value.clamp(1, 6);
    $gameVariables.setValue(42, value);

    Cursor Left Code
    Code:
    var index = this.index();
    var symbol = this.commandSymbol(index);
    var value = this.getConfigValue(symbol);
    value -= 1;
    value = value.clamp(1, 6);
    $gameVariables.setValue(42, value);

    This entries are causing this error:
  2. The error means that the game has tried to draw a gradient (the gauge in this case) with one or more non-finite coordinates. In this case I imagine that value is NaN. Check the relevant Default, Load, and/or Save Config Code parameters.

    The problem with game variables in the options is that they typically reset on new/load game, i.e. you'd need something to make certain variables persistent. However, it's usually easier to just reference ConfigManager[symbol] via a script call when you need it, e.g. ConfigManager.bgmVolume.
  3. I managed to remove error, but strange things happens - pressing esc lowers value of variable - ahh nevermind... I'll stick with "Show Choices" event at the very start of game and that's all.