Topic was automatically imported from the old Question2Answer platform.
Asked By
Merlin1846
This function is capable of converting any string that has gone through json back into a vector2() their by makeing it easyer to store vector2()s in a file, and retrieve them.
cords = "(1324, 1654)"
cords.erase(cords.find("("),1)
cords.erase(cords.find(")"),1)
cords.erase(cords.find(","),1)
var x = cords.left(cords.find(" "))
var y = cords.right(cords.find(" "))
cords = Vector2(x,y)
just wanted to let everyone use it because I couldn’t find one that was already made.
I think this could work equally as well in your use case:
var cords = "(1324, 1654)"
var some_vector = var2str("Vector2" + cords)
Edit: Wouldn’t saving the Vector2 to JSON using str2var() be more convenient? This way, the string can be passed directly to var2str() without the need to concatenate it.