Scripting .....
by Le Roi · 06/15/2006 (12:59 am) · 6 comments
So I was at it again last night (keep the schedule you know :)) , and I designed my Actor and Controller classes with interfaces and base classes etc.
Then I turned to script these objects , and oops .... torque script does not know what an interface is ...
So i went to the forums , and after searching found 2 ways to do what I wanted ,
First way was to use the OO-TorqueScript - but I did not want to modify my engine (having already added the maximize box was enough for me ;)) - and used method 2 :
On the forums I found a whole post and replies about using the ":" (or scope as I like to call it) operator in your object definition
new ScriptObject(BaseClass)
{
someVar = 0;
};
new MyObject( :BaseClass)
{
};
This actually brings me to my point , after searching the forums and the site I came upon the TGE "Preview Documentation" on the garagegames site
(there is no link to this - I checked , only a search will reveal this)
There I found Chapter 5 - Scripting
EDIT : I Found the relevant pages on the TGB Wiki :) *hehe*
Boy did that help alot , I hope someone puts this chapter on the TGB Wiki page , because this really explains alot about how the scripting works etc.
Anyways I got my Actor/Controller working , then I realized that even if you associate a class in the TGB to your animated sprite , it won't recognize it unless the variable is declared beforehand and globally , this presented a problem for me as I have to create Actor objects dynamicly , luckily I started delving into the documentation and found the sceneGraph() documentation.
So basicly , I loaded my Level (without my sprite in it) with loadLevel() and then manually did a addToScene() to add my Actor.
I'm finally beginning to understand how this all fits together , but I think that newbies will be very confused when they fist start out with the tgb
(see my Perspective blog) and try to apply a "programming" approach.
I'll try and get a "getting started for coders" tutorial out on the wiki that explains to newbies (like me) how to get started making a basic level and adding/removing objects to it purely from a scripting p.o.v.
Thus the TGB at this stage is for me a "staging tool" - I use it to quickly prototype level ideas and test other stuff , once I'm done with this I'll save the level and then open it with a text editor , copy all the stuff I need to my custom classes and be done with it.
Don't get me wrong , the TGB is very useful - I love the editor , and I also love the fact that I can see immediately how a animation looks like for example and the GUI tools just rock , I haven't tried the other tools yet (particle) etc. - but I'm sure that they too will rock.
One final thing I must state is the wonderful IDE "Torsion" (http://www.sickheadgames.com/torsion.php) ,
I haven't really looked at other IDE's
(except for one who shall not be named , where when I moved a script file to another folder , lost my script file (just deleted it!)) anyways
this one(torsion) really sped up my development and debugging , it really is a great tool , It automaticly picks up your project and all associated files , and lets you debug and step into the script like any other IDE ,
one feature I would love though is the concept of a "watch" - but I saw on the forums somewhere that they are working on it.
Anyways thats my post for today
Cheers
Le Roi
Then I turned to script these objects , and oops .... torque script does not know what an interface is ...
So i went to the forums , and after searching found 2 ways to do what I wanted ,
First way was to use the OO-TorqueScript - but I did not want to modify my engine (having already added the maximize box was enough for me ;)) - and used method 2 :
On the forums I found a whole post and replies about using the ":" (or scope as I like to call it) operator in your object definition
new ScriptObject(BaseClass)
{
someVar = 0;
};
new MyObject( :BaseClass)
{
};
This actually brings me to my point , after searching the forums and the site I came upon the TGE "Preview Documentation" on the garagegames site
(there is no link to this - I checked , only a search will reveal this)
There I found Chapter 5 - Scripting
EDIT : I Found the relevant pages on the TGB Wiki :) *hehe*
Boy did that help alot , I hope someone puts this chapter on the TGB Wiki page , because this really explains alot about how the scripting works etc.
Anyways I got my Actor/Controller working , then I realized that even if you associate a class in the TGB to your animated sprite , it won't recognize it unless the variable is declared beforehand and globally , this presented a problem for me as I have to create Actor objects dynamicly , luckily I started delving into the documentation and found the sceneGraph() documentation.
So basicly , I loaded my Level (without my sprite in it) with loadLevel() and then manually did a addToScene() to add my Actor.
I'm finally beginning to understand how this all fits together , but I think that newbies will be very confused when they fist start out with the tgb
(see my Perspective blog) and try to apply a "programming" approach.
I'll try and get a "getting started for coders" tutorial out on the wiki that explains to newbies (like me) how to get started making a basic level and adding/removing objects to it purely from a scripting p.o.v.
Thus the TGB at this stage is for me a "staging tool" - I use it to quickly prototype level ideas and test other stuff , once I'm done with this I'll save the level and then open it with a text editor , copy all the stuff I need to my custom classes and be done with it.
Don't get me wrong , the TGB is very useful - I love the editor , and I also love the fact that I can see immediately how a animation looks like for example and the GUI tools just rock , I haven't tried the other tools yet (particle) etc. - but I'm sure that they too will rock.
One final thing I must state is the wonderful IDE "Torsion" (http://www.sickheadgames.com/torsion.php) ,
I haven't really looked at other IDE's
(except for one who shall not be named , where when I moved a script file to another folder , lost my script file (just deleted it!)) anyways
this one(torsion) really sped up my development and debugging , it really is a great tool , It automaticly picks up your project and all associated files , and lets you debug and step into the script like any other IDE ,
one feature I would love though is the concept of a "watch" - but I saw on the forums somewhere that they are working on it.
Anyways thats my post for today
Cheers
Le Roi
#2
Specifically what do you want to see in a "watch" feature?
06/15/2006 (4:58 am)
I'm glad to see you liking Torsion.Specifically what do you want to see in a "watch" feature?
#3
I would pay you( well, at least give you a very big hug, or convince a very pretty girl to give you a very big hug) to do this once you are done with your own struggles. I have had a heck of time trying to figure out how to do things in torque script and I'm getting no where fast.
The docs that come with TGB are barely passable for the way I learn. The tutorials are ok, but I am really wanting something more technical. I hit my breaking point this week and set TGB aside until final release, hoping that when it ships they will provide more docs on the technical side. I am a software developer and have been working with OO languages for the past ten years, I find myself fighting with torque script more than learning it.
I probably just need to keep grinding away at it until the light bulb comes on. But honestly I haven't had this much trouble learning a new language/tech since I was a neophyte coder in college.
06/15/2006 (6:44 am)
"I'll try and get a "getting started for coders" tutorial out on the wiki that explains to newbies (like me) how to get started making a basic level and adding/removing objects to it purely from a scripting p.o.v."I would pay you( well, at least give you a very big hug, or convince a very pretty girl to give you a very big hug) to do this once you are done with your own struggles. I have had a heck of time trying to figure out how to do things in torque script and I'm getting no where fast.
The docs that come with TGB are barely passable for the way I learn. The tutorials are ok, but I am really wanting something more technical. I hit my breaking point this week and set TGB aside until final release, hoping that when it ships they will provide more docs on the technical side. I am a software developer and have been working with OO languages for the past ten years, I find myself fighting with torque script more than learning it.
I probably just need to keep grinding away at it until the light bulb comes on. But honestly I haven't had this much trouble learning a new language/tech since I was a neophyte coder in college.
#4
06/15/2006 (7:48 am)
Torsion already has 'watches' in it. Look at the tabs under the code window and click 'watch'. Torsion is the best thing that's been released for TGE, outside the MMOKit of course *shameless plug*
#5
06/15/2006 (8:34 am)
@Ian: I'm curious, could you give a couple of specific examples of things you have struggled with in Torque Script?
#6
@Tom: Thanks for torsion - it rules - anyways I discovered the "watch" window thanks @Jonathon , what I actually meant was that when I right-click on a variable , in the pop-up menu that if it could display a "quick watch" function , when clicked this will popup the object/variable and list all of its members etc. (i'm thinking of visual studio so bear with me ;)).
@Ian: I'll try and get it up soon , you'll be the first to proof read it *hehe*
06/15/2006 (10:26 am)
Thanks for the feedback guys@Tom: Thanks for torsion - it rules - anyways I discovered the "watch" window thanks @Jonathon , what I actually meant was that when I right-click on a variable , in the pop-up menu that if it could display a "quick watch" function , when clicked this will popup the object/variable and list all of its members etc. (i'm thinking of visual studio so bear with me ;)).
@Ian: I'll try and get it up soon , you'll be the first to proof read it *hehe*
Torque 3D Owner Pisal Setthawong