Game Development Community

SimSet console methods

by gamer · in General Discussion · 04/17/2006 (10:59 am) · 5 replies

Hi, I am trying to use SimSet in torquescript. :
%a=new SimSet();// it's fine
%a.listObjects();// (0): unable to find object: '' attempting to call function 'listObjects'
it's unable to find any of the console methods I see in simbase.cc;
I looked in simebae.cc I find for example:
ConsoleMethod(SimSet, listObjects, void, 2, 2, "set.listObjects();")
{
argc; argv;

object->lock();
SimSet::iterator itr;
for(itr = object->begin(); itr != object->end(); itr++)
{
SimObject *obj = *itr;
bool isSet = dynamic_cast(obj) != 0;
const char *name = obj->getName();
if(name)
Con::printf(" %d,\"%s\": %s %s", obj->getId(), name,
obj->getClassName(), isSet ? "(g)":"");
else
Con::printf(" %d: %s %s", obj->getId(), obj->getClassName(),
isSet ? "(g)" : "");
}
object->unlock();
}

what am I missing?
thanks

#1
04/17/2006 (12:38 pm)
Are you doing this from the console?
#2
04/17/2006 (2:44 pm)
Yes, I realized that I can do it from a file but not from console. Why?
thanks
#3
04/17/2006 (2:46 pm)
Can you use % variables from the console? Does it work with:
$a=new SimSet();
$a.listObjects();
#4
04/17/2006 (2:56 pm)
Yes $a global variable is fine, not %. why?
#5
04/18/2006 (4:20 pm)
Every line that you type into the console is it's own scope, and since % variables are only valid for a single scope, they are out of scope on the second line you type in.