I have a lookup table in my Squirrel script, and I'm using wxString to do some string operations. No matter what I do, though, I cannot use the wxString as a key value in the table! It gives me the error: "the index 'instance' does not exist", and the script fails. I've searched high and low for a simple tostring function, with no success. There has to be SOME way to convert a wxString into a normal Squirrel String...
EDIT:
I ended up using a foreach to go through each key and check if it's equal... but that's pretty hacky and I'd really like to know the real way to do it.
For somebody who still searching the answer for this question :)
Right, you can use only squirrel native strings as table indexes because wxString objects are just a pointers from the squirrel's point of view.
It is possible to convert wxString to the native squirrel string this way:
function wxStr2sqStr(wxStr)
{
local sqStr = "";
sqStr += wxStr;
return sqStr;
}
The inverse conversion looks a bit more complex:
function sqStr2wxStr(sqStr)
{
local wxStr = ::wxString();
foreach (chr in sqStr)
{
wxStr.AddChar(chr);
}
return wxStr;
}