Archive 17/01/2023.

Calling a function from XML?

rogerdv

I have been thinking about the design of my RPG dialog system, and I need to know if there is some way to specify inside XML an AngelScript function to be called by the dialog parser. Is this possible? Can I also pass some sort of parameter?

Azalrion

Since you’re most likely reading the xml yourself simply just do something like:

<dialogEntry>
    <file>MyDialog.as</file> <!-- Might not need this if you plan to execute via script instance -->
    <function>Func()</function>
</dialogEntry>

Then when building your dialog class execute that function using ScriptFile or ScriptInstance.

From angelscript you can execute and pass parameters like so:

bool Execute(const String& functionName, const Variant[]@ parameters)