I've written a function that queries my world for objects that match a certain criteria and then returns one of those objects as a pointer.
But if my function finds no objects it should return a null value. My C++ function looks like this:
cObject *cWorld::QueryWorld(cPosition vecQuery)
{
cObject *tmp = pObjectList;
while (tmp)
{
if (tmp->rectBounds.Test(vecQuery))
return tmp;
tmp = tmp->pNext;
}
return 0;
}
I've written an binding function:
cObject *cWorld::bind_QueryWorldPos(cPosition &vecQuery) {return QueryWorld(vecQuery);}
Then bind it with sqplus:
SQClassDef<cWorld>(wxT("cWorld"))
.func(&cWorld::bind_QueryWorldPos, wxT("QueryWorldPos"))
BindVariable(&scene, wxT("world"));
Now if I run "::world.QueryWorldPos()" in Squirrel and the function finds no matches it returns an instance when I need it to return null.
Thanks for any help guys.