The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > Graphic & Game Programming > TorqueScript


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 01-04-2008, 04:04 PM
MrPickle's Avatar
MrPickle MrPickle is offline
Sr. Programmer
Join Date: Nov 2007
Location: England, Lincolnshire
Posts: 283
iTrader: (0)
MrPickle is on a distinguished roadMrPickle is on a distinguished roadMrPickle is on a distinguished road
ScriptObject

What is a ScriptObject?

A script object is basically an object that can store data, it's normally used in place of lots of global variables.

How to use a ScriptObject

To create the object all you need to do is:
Code:
new ScriptObject();
But that's not very useful!
How to make it useful you say?
Code:
new ScriptObject(MyScriptObject){
   dynamicField = "Whatever";
 };

MyScriptObject
is the name of our ScriptObject, This is used for when we need to get information later on. It can be named anything, but if there is already and object with that name it will get overwritten. You do not need to give your ScriptObject a name.

dynamicField is the bit that stores the script objects data, it can be named anything and it's also legal to use arrays with it.

"Whatever" is whatever you want it to hold, it can hold anything, objects, vector, numbers strings. If you make it call something, eg myfunction(), it would store whatever that function returns, the " "'s are only necessary if the thing it's storing is a string.

How to get information from your ScriptObject

All you need is your ScriptObject's Name or Variable, that's if you assigned it one and the dynamic field that you want to get the data from.

Here are two examples:
Code:
%a = MyScriptObject.dynamicField; 
//MyScriptObject is the name of our ScriptObject.
//dynamicField is the data we want to get from the ScriptObject.
Code:
%a = %scriptObject.dynamicField; //%scriptObject is our ScriptObject.
//dynamicField is the data we want to get from the ScriptObject
A few more things about ScriptObjects

You can assign ScriptObjects classes, these allow you to make functions without giving it a name:
Code:
new ScriptObject(){
class = MyScriptObject;
};
Script objects can have their own functions:
Code:
function MyScriptObject::function(%this, %var1, %var2, %var3){ //%this is the script object.
//whatever
}
To make your own ScriptObject functions your ScriptObject needs to have a name or class. In this case MyScriptObject was the class of our ScriptObject.

ScriptObjects can be stored in variables local and global:
Code:
%ScriptObject = new ScriptObject();
$ScriptObject = new ScriptObject();
If the script object is outside of a function it will be created when that file is executed, if it's in a function it will be created whenever that function is called.

You can copy a script object:
Code:
new ScriptObject(MyScriptObject : CopyThis);
CopyThis is the name of the ScriptObject that we're copying.

Hope this helped

__________________
PM me and tell me your name or a phrase and I shall write it in Elf for you. English Tengwar to be precise.
Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by MrPickle : 01-22-2008 at 09:34 AM. Reason: COMPLETELY forgot about classes
Reply With Quote
The Following 2 Users Say Thank You to MrPickle For This Useful Post:
ccoonen (01-05-2008), HelloWorld (01-05-2008)
  #2 (permalink)  
Old 01-05-2008, 11:41 AM
ccoonen ccoonen is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Location: Wisconsin
Posts: 308
iTrader: (0)
ccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished road
Thanks for the info buddy! If my work ever lets me stop doing AS3... I'll definitely check out TorqueScript
Reply With Quote
  #3 (permalink)  
Old 01-06-2008, 11:26 AM
MrPickle's Avatar
MrPickle MrPickle is offline
Sr. Programmer
Join Date: Nov 2007
Location: England, Lincolnshire
Posts: 283
iTrader: (0)
MrPickle is on a distinguished roadMrPickle is on a distinguished roadMrPickle is on a distinguished road
I've added a new bit about copying already existing ScriptObjects, I didn't know you could do that till today

__________________
PM me and tell me your name or a phrase and I shall write it in Elf for you. English Tengwar to be precise.
Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #4 (permalink)  
Old 01-22-2008, 09:35 AM
MrPickle's Avatar
MrPickle MrPickle is offline
Sr. Programmer
Join Date: Nov 2007
Location: England, Lincolnshire
Posts: 283
iTrader: (0)
MrPickle is on a distinguished roadMrPickle is on a distinguished roadMrPickle is on a distinguished road
I completely forgot about assigning ScriptObjects a class, embarrassing.

__________________
PM me and tell me your name or a phrase and I shall write it in Elf for you. English Tengwar to be precise.
Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 03:23 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50