- Edited
Hi, how do I convert a std::vector<std::string> to a Variant for returning from a c++ GDExtension?
Variant GDSerialPort::tester()
{
UtilityFunctions::print("testerrrrrr");
Variant v;
std::vector<std::string> l = get_available_ports();
//cout << "..." << endl;
if(l.size() == 0){
//cout << "No devices found" << endl;
UtilityFunctions::print("No devices found");
l.push("No devices found");
}
/*
else
{
std::vector<std::string>::iterator it = l.begin();
while (it != l.end()) {
//cout << *it << endl;
UtilityFunctions::print(std::string(*it).c_str());
it++;
}
}
*/
v = l; // *** THIS BIT ***
//Variant v = 3;
//Variant v = "helllllllllo";
return v;
}
Whilst we are at it,
Here is how to read a passed Variant of an array of strings?
Variant GDSerialPort::alice(Variant v2)
{
UtilityFunctions::print("Aliced");
UtilityFunctions::print(v2);
UtilityFunctions::print(v2.get(1));
//Variant v;
//Variant v = 3;
Variant v = "Alice";
return v;
}
from
func _ready():
var y = alice(["you", "Whaaaaat!"])
Thankyou