robert.blodgett Posted September 7, 2016 Share Posted September 7, 2016 Calling a script function in system script is giving a strange error in the log, I'm not sure what the "int: 1" is about, nor the "extern class", nor the "Machine::run()" ... Machine::run(): "int: 1" is not an extern class The c++ code: std::vector<NodeReferencePtr> trackedDevices; ... const Variable var = Engine::get()->runSystemFunction((Variable)"updateTrackedDevices", (Variable)(trackedDevices[0]), (Variable)(trackedDevices[1]), (Variable)(trackedDevices[2]), (Variable)(trackedDevices[3])); The script function I'm trying to call: void updateTrackedDevices(NodeReference basestation_0, NodeReference basestation_1, NodeReference controller_0, NodeReference controller_1) { ... Link to comment
silent Posted September 8, 2016 Share Posted September 8, 2016 Hi Robert, Please, follow this guide to get a correct cast to a Variable: https://developer.unigine.com/en/docs/2.3/code/fundamentals/memory_management#create_pass_variable Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
robert.blodgett Posted September 8, 2016 Author Share Posted September 8, 2016 That looked like the right answer, but instead, I'm getting this compile error: 1>...\professional_windows_2.3\include\UnigineInterpreter.h(1653): error C2664: 'void Unigine::Variable::setExternClassObject(void *,const Unigine::TypeInfo &,void *,int,int)' : cannot convert argument 2 from 'Unigine::TypeInfo' to 'const char *' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1> ...\professional_windows_2.3\include\UnigineInterpreter.h(1653) : while compiling class template member function 'Unigine::TypeToVariable<Unigine::NodeReferencePtr>::TypeToVariable(void *,Type)' 1> with 1> [ 1> Type=Unigine::NodeReferencePtr 1> ] 1> UnigineLibrary.cpp(825) : see reference to function template instantiation 'Unigine::TypeToVariable<Unigine::NodeReferencePtr>::TypeToVariable(void *,Type)' being compiled 1> with 1> [ 1> Type=Unigine::NodeReferencePtr 1> ] 1> UnigineLibrary.cpp(825) : see reference to class template instantiation 'Unigine::TypeToVariable<Unigine::NodeReferencePtr>' being compiled This is the c++ code: Variable v1 = TypeToVariable<NodeReferencePtr>(Interpreter::get(), trackedDevices[0]).value; // line 825 Variable v2 = TypeToVariable<NodeReferencePtr>(Interpreter::get(), trackedDevices[1]).value; Variable v3 = TypeToVariable<NodeReferencePtr>(Interpreter::get(), trackedDevices[2]).value; Variable v4 = TypeToVariable<NodeReferencePtr>(Interpreter::get(), trackedDevices[3]).value; const Variable var = (*theEngine)->runSystemFunction((Variable)"updateTrackedDevices", v1, v2, v3, v4); Link to comment
silent Posted September 9, 2016 Share Posted September 9, 2016 Hi Robert, I'm afraid you will have to redesign script function: void updateTrackedDevices(Node basestation_0, Node basestation_1, Node controller_0, Node controller_1) { NodeReference ref = node_cast(basestation_0); <...> } And Instead of passing NodeReferencePtr you should pass NodePtr. Something like that: Variable v1 = TypeToVariable<NodePtr>(Engine::get()->getWorldInterpreter(),ref->getNode()).value; or that: Variable v1(Engine::get()->getWorldInterpreter(),ref->getNode()); Sorry for the inconvenience caused. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
robert.blodgett Posted September 9, 2016 Author Share Posted September 9, 2016 thanks I'll try that. Link to comment
Recommended Posts