Game Development Community

Gui Scripting command

by Xavier "eXoDuS" Amado · in Torque Game Engine · 04/14/2002 (10:03 am) · 2 replies

If you call a function from within a button you do something like command = "myfunction(%myparameter);";
but that if the function is defined alone:
function myfunction(%myparameter){};

what if i define the function inside the gui for example:

MyGui::myfunction(%this, %myparameter){};

how would i call it from the gui?
i tried
command = "MyGui::myfunction(%myparameter);";
but the paremeter didnt got through

#1
04/14/2002 (10:26 am)
Here is an example of how to do it:

if(!isObject(SomeObject)) 
{
   new ScriptObject(SomeObject) 
   {
      class = SomeObject;
      activated = 0;
   };
}
function SomeObject::activate(%this)
{
   // do something
   %this.activated = true;
}

And then in your Gui code, say for a button, the command would be this:
command = "SomeObject.activate();";
#2
04/14/2002 (10:48 am)
kewl thanks

after looking a bit more i found out i was calling it with :: instead of . in the command :)
stupid me :D
thanks anyway