Archive 17/01/2023.

[SOLVED] Using user Variables in node through script

setzer22

I’m trying to query a user variable through AngelScript. That is, set up a custom variable in a node through the editor and then getting its value having a reference to that node,

In C++ the documentation mentions the function:

const Variant& GetVar (StringHash key) const Return a user variable.

But that doesn’t appear (nor it’s recognised by the compiler) on the script API.

What am I missing?

Thank you!

cadaver

This is another case where Get / Set functions are converted to array accessor on the AngelScript API side. You can use node.vars with String or StringHash indexing. For example:

node.vars["Score"] = 0;
int score = node.vars["Score"].GetInt();
setzer22

I had missed that somehow while looking in the documentation. Thank you!