Game Development Community

An honest confession...

by Efra · in Torque Game Builder · 05/26/2006 (12:43 am) · 4 replies

I have an honest confession to make. Please don t kill me for it. My job is web designer/developer and I am used to languages like PHP, AS, and so on. On the GarageGames website it said that experience in these areas would be sufficient to understanding and using TorqueScript. But I have to confess, it is a little over my head.
I think the Torque learning-curve is still pretty high for designers with no Cx background.

The reason for my post is to discuss a method that would lower the bar for designers and would still make TorqueScript as powerful as it is. My proposal is to support classes like this:

class ClassName 
{
	//variables
	%variable = TRUE;

	//getter/setter functions
	function getFunction()
	{
		return %this.variable;
	}
}


%object = new ClassName;

As you will probably know, this is the same way of writing classes as in PHP and ActionScript2.0. I think it will greatly lower the learning curve of TorqueScript OOP, but still leave its power intact. This way would attract more artists to the GarageGames community. But of course, I am not as smart as you guys ;-)

Thank you for reading,

Efraim

About the author

Recent Threads

  • Bouncy Player

  • #1
    05/26/2006 (3:17 am)
    Efraim,
    you can get the same effect of your code with the following:
    function ClassName::onAdd(%this)
    {
       %this.variable = TRUE;
    }
    
    function ClassName::getFunction(%this)
    {
       return %this.variable;
    }
    
    function ClassName::setFunction(%this, %value)
    {
       %this.variable = %value;
    }
    
    %object = new ScriptObject()
    {
       class = "ClassName";
    };
    
    %object = new t2dSceneObject()
    {
       class = "ClassName";
    };

    You can use the ClassName::onAdd() method as your constructor to initialize all member variables with default values if needed. The syntax is just a bit different for doing the same thing. It is not that hard once you get the grasp ;)

    It is improbable (I think) that Torque script will change.

    -Michael
    #2
    05/26/2006 (6:39 am)
    @Efraim- Coming from the same situation as you - hopefully I can save you some grief. In addition to what Michael said, one important thing to realize is that Torquescript is not a fully object oriented language. It uses packages and namespaces though. The OO support is really just that each object has an ordered list of namespaces. Using this you can acheive inheritance and polymorhphism. Take a look at this thread for some more obscure issues I ran into when I was working with classes in torquescript.

    One trick I find useful is to call %myObj.functionXXX() where functionXXX does not exist. Then torque prints to the console the namespace lookup path it's using for that object. It can be very useful for debugging & figuring out what's going on.
    #3
    05/31/2006 (2:36 pm)
    Don't think torqueScript has the same level of OO capabilities of ActionScript 2
    I was playing lately with AS2 and is a very nice and friendly OO language indeed,
    but the Flash implementation comes with some problems.
    And in AS2 I was always thinking: gosh where is my console input...
    my powerful eval(), exec(), ....
    So even when you can create objects in unlimited ways with AS2, the fact is that torqueScript
    supports more powerful techniques.
    #4
    06/14/2006 (8:03 am)
    Hmm, makes sence!
    Thank guys!!!

    Efraim