Jump to content

[SOLVED] How to register multiple definitions of single extern class?


photo

Recommended Posts

I am trying to export to UnigineScript multiple classes (with different names of course) that are tied to the same actual C++ class. App compiles but gives errors on world load

Interpreter::addExternClass(): "foo" class is already defined

If I try to use this class in UnigineScript:

Interpreter::parse(): unknown token "foo"

Is there a way to accomplish this without creating a new C++ class?

Link to comment

Hi Adam, you can do it like this: 

        ExternClass<NameOfCPlusPlusClass> *instance = MakeExternClass<NameOfCPlusPlusClass>();
	Interpreter::addExternClass("ScriptClassName",instance);

	ExternClass<NameOfCPlusPlusClass> *instance2 = MakeExternClass<NameOfCPlusPlusClass>();
	Interpreter::addExternClass("ScriptClassName2",instance2);
Link to comment

Sorry for delayed response -- I have been away from work.

 

maxi, the example you gave matches my current implementation. Two separate ExternClass<foo> pointers are created, each passed to Interpreter::addExternClass with separate names. This results in the errors I initially posted, with the Interpreter failing to register the second one claiming it has already been defined.

 

Should I submit a test scenario?

Link to comment

Here you go.

 

Build with Visual Studio 2013

copy resulting PluginTest.DLL into bin directory of existing Unigine project

add "PluginTest" to extern_plugin setting in Unigine project's launcher or in system config

Launch Unigine project

Interpreter::addExternClass(): "fooAgain" class is already defined

fooAgain class is thereafter unavailable to UnigineScript.

PluginTest.zip

Link to comment
×
×
  • Create New...