Better way to get value of global script variable?
by Demolishun · in Torque Game Engine · 02/19/2007 (8:33 pm) · 4 replies
Here is how I am getting and setting a global script variable from C++.
Getting value:
Setting value:
Is there a better way?
It works, but seems a little clunky.
Thanks,
Frank
Getting value:
StringTableEntry mCopiedCellList;
mCopiedCellList = StringTable->insert("$clipboard::cells");
SimObject *tobj = Sim::findObject(Con::evaluatef("return %s;",mCopiedCellList));Setting value:
Con::evaluatef("%s=%d;",mCopiedCellList,clipboard->getId());Is there a better way?
It works, but seems a little clunky.
Thanks,
Frank
About the author
I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67
#2
Thanks,
Frank
02/19/2007 (9:42 pm)
Oh yes. This is excellent. It also looks like it has get versions of the above too. I am guessing this faster than the evaluatef command. Although, it is kind of neat to be able to run script from the C++ interface too. I should have known to look in the console.h/.cc files a little closer. That is where I got evaluatef from.Thanks,
Frank
#3
and:
Thank you Chris,
Frank
02/20/2007 (7:37 pm)
Perfect:Con::getVariable(mCopiedCellList)instead of:
Con::evaluatef("return %s;",mCopiedCellList)and:
Con::setIntVariable(mCopiedCellList,clipboard->getId());instead of:
Con::evaluatef("%s=%d;",mCopiedCellList,clipboard->getId());Thank you Chris,
Frank
#4
02/20/2007 (8:21 pm)
Glad I could help. :)
Associate Chris Haigler
Jester Dance
Hope this helps. :)