ranjith.j Posted September 13, 2013 Share Posted September 13, 2013 Hi, I am trying to use char type variable, but it is saying 'char' is unknown token. eg:- char varName; can any body help please. Regards, Ranjith. Link to comment
ulf.schroeter Posted September 15, 2013 Share Posted September 15, 2013 UNIGINE script is not C++ ! There is no char script data type. Please read the documentation on UNIGINE data types. Link to comment
binstream Posted September 19, 2013 Share Posted September 19, 2013 Ulf is right, here are some details: https://developer.unigine.com/en/docs/1.0/scripting/language/variables Link to comment
ranjith.j Posted September 26, 2013 Author Share Posted September 26, 2013 Thank You. Actually I am planning to store some byte values. Because Unigine has no char or byte data type I am using string. I am adding byte by byte to string by as a character using format("%s%c",dataString,byteValue); But problem is it is not storing 0 value. Because 0 is null character it is not storing this value. Can any one suggest how can I store a 0 value into the string or any other solution to store set of bytes. Link to comment
ulf.schroeter Posted September 26, 2013 Share Posted September 26, 2013 Simply store your values as an array of int values. Although this is not perfectly memory efficent this shouldn't be a real problem in scripting. Link to comment
ranjith.j Posted September 27, 2013 Author Share Posted September 27, 2013 Thank you ulf, I am using one C++ external plugin. In this one function is receiving a byte* (byte pointer) argument and one more function is returning byte* pointer. I unable to store it in an array of int. I don't want to change the external plugin code as it will be effected on other projects. Is there any other way to store byte values. Link to comment
ulf.schroeter Posted September 27, 2013 Share Posted September 27, 2013 Then you possibly could wrap this in your own plugin (which uses the external one and exposes your functions to UNIGINE script) Define a function that takes int array as argument and within the C++ code store these int values in a matching byte array and call the external C++ plugin function with the byte array. Same approach for any char return value. Simply convert byte to int and return this int from your C++ plugin to UNIGINE script. Link to comment
ranjith.j Posted September 30, 2013 Author Share Posted September 30, 2013 I unable get/set the data using int array. I tried in three different ways to get data 1) I declared an array in unigine script and sending this as argument to c++ plugin Unigine Script int data[100]; fun(data); C++ code: void fun(int data[]); it is giving error : arrays can't be used in expressions 2) returning int array from the c++ plugin and trying receive in script Unigine Script int data[] = fun(); C++ code: int* fun(); it is also not working 3) I also tried uisng external variable. I declared an global int array in c++ code and exported to use it in the script. when I tried to read the data from the array in unigine script it is giving error: can't read int data from int. Am I doing any mistake, please help me. Link to comment
ulf.schroeter Posted September 30, 2013 Share Posted September 30, 2013 https://developer.unigine.com/en/docs/1.0/cpp_api/usage/arrays Link to comment
Recommended Posts