BehaviorTree / BehaviorTree.CPP

Behavior Trees Library in C++. Batteries included.
https://www.behaviortree.dev
MIT License
3.03k stars 665 forks source link

Duplicate scripting enum values disambiguation #850

Closed mguzzina closed 3 months ago

mguzzina commented 3 months ago

Is your feature request related to a problem? Please describe. If I have two different enums that have the same value name but different value it's not that easy to figure out that the value of the registered enums might be wrong in the scripting conditions.

Describe the solution you'd like Having a way to disambiguate the enum names during scripting would be great.

If it is too hard (or impossible) I would be happy with having a way to tell that such duplicate values exist, so that at least I can enforce not having duplicate value names. In this case it would be even better if the library enforced it directly.

Additional context Let's say I have two enums:

enum class Color1
{
    RED = 1,
    GREEN = 2,
    BLUE = 3,
};

enum class Color2
{
    BLUE = 1,
    GREEN = 2,
    RED = 3,
};

And I register them both as scripting enums in two separate nodes:

BT_REGISTER_NODES(factory)
{
    factory.registerNodeType<Something1>("Something1");
    factory.registerScriptingEnums<Color1>();
}
BT_REGISTER_NODES(factory)
{
    factory.registerNodeType<Something2>("Something2");
    factory.registerScriptingEnums<Color2>();
}

I don't know what values RED, GREEN or BLUE will have in scripting, which I assume depends on the order I load plugins in.

mguzzina commented 3 months ago

It looks like it's already implemented on master.