set new value on Array config

Discussion in 'Development' started by CupidonSauce173, Apr 14, 2019.

  1. CupidonSauce173

    CupidonSauce173 Zombie

    Messages:
    276
    GitHub:
    cupidonsauce173
    Hello, I am trying to change a value from a config on a event, just do a reset or doing a +1
    This is the config :
    Code:
                        $this->player_file = new Config($this->getDataFolder() . $victim . ".yml", Config::YAML, [
                        "value_1" => 0,
                        "value_2" => 0
                        ]);
    Now, I want to do to do a +1 on value_1, I know how to get "value_1" but no idea on how to set a new value on it. Thanks for the help
     
  2. Diduhless

    Diduhless Slime

    Messages:
    96
    GitHub:
    Diduhless
    PHP:
    /** @var Config $config */
    $config->set("value_1"$config->get("value_1") + 1);
    $config->save();
     
  3. CupidonSauce173

    CupidonSauce173 Zombie

    Messages:
    276
    GitHub:
    cupidonsauce173
    ??? So we use the same method for a normal config files then a array ?
     
  4. Diduhless

    Diduhless Slime

    Messages:
    96
    GitHub:
    Diduhless
    Can you speak better please
     
  5. CupidonSauce173

    CupidonSauce173 Zombie

    Messages:
    276
    GitHub:
    cupidonsauce173
    Sorry, I'm asking if it'd the same way as normal config files since this one is an array one.
     
  6. Diduhless

    Diduhless Slime

    Messages:
    96
    GitHub:
    Diduhless

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.