Jump to content

Can't seem to call script function in my own system script.


photo

Recommended Posts

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

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

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:

Link to comment
×
×
  • Create New...