DCEI.GetValueFromDataPath() is a powerful API that allows you to get Data Window values in Lua at runtime. For example, if in the editor you’ve defined an Ability "Hero Marksman Ability" with a base mana cost of 20, then in code you can read that base mana cost via DCEI.GetValueFromDataPath({ "abilities", "Hero Marksman Ability", "cost", "mana" })

You can right-click on any field in the data editor and select “Copy Data Path” and paste it into Lua for the correct path.

Untitled

Particularly if the data name is dynamic rather than static; you should use DCEI.ValidateDataPath() prior to running this API to make sure the data and field exists:

local data_path = {"units", "Standard MeleeUnit", "components", "unitStats", "radius"}
if DCEI.ValidateDataPath(data_path) then
    local data_path_val = DCEI.GetValueFromDataPath(data_path)
    DCEI.LogMessage(data_path_val)
end

Use Case

This can be useful for displaying game values in the UI; such as if you want to show the mana cost or cooldown of an ability in your UI.

Anytime you need to access a data value in script, using this function will help you and prevent messy situations where you hard-code values in your Lua script based in data, and you have to change the value in both Lua and Data anytime you make changes. With this API, you can make changes in data only and automatically fetch the value in Lua with this API.