Skip to main content

StatSource.GetValue

Declaration#

public virtual float GetValue(string formula, StatSource other)

Parameters#

NameDescription
formulaFormula to solve
otherOther Stat Source

Description#

Get the value of a formula

Usage#

Example
using NullSave.GDTK.Stats;using UnityEngine;
public class Example : MonoBehaviour{
    public void ExampleMethod(StatSource source)    {        // Get the maximum value of a stat name 'HP' and add 3        float value = source.GetValue("HP:max + 3");    }
}

Declaration#

public virtual float GetValue(string formula, Dictionary<string, StatSource> sources)

Parameters#

NameDescription
formulaFormula to solve
sourcesDictionary of other sources

Description#

Get the value of a formula

Usage#

Example
using NullSave.GDTK;using NullSave.GDTK.Stats;using System.Collections.Generic;using UnityEngine;
public class Example : MonoBehaviour{
    public void ExampleMethod(StatSource target)    {        Dictionary<string, StatSource> sources = new Dictionary<string, StatSource>()        {            { "", target },            { "global", ToolRegistry.GetComponent<GlobalStats>().source }        };
        target.GetValue("global:difficulty * 7", sources);    }}