Author Topic: Torque script: Q&A  (Read 1425 times)

This is now going to be a simple Question and Answer thread. If you have a question regarding Torque SCRIPT just post it here and hope it gets answered.
« Last Edit: July 28, 2009, 12:34:38 PM by blaman »

There are a crazy number of threads about this, considering that each person has their own way of learning something. Try and find where I posted a thread going "help me learn torque script pls" - you won't because I just got on with it. Try it out.

I guess you have a point.
I just don't know what to start with. Scrap the "post how you learned."
Should I start with some small console scripts and such? Or should I memorize all the operators and symbols and stuff? Any pointers at all?

Tom

I guess you have a point.
I just don't know what to start with. Scrap the "post how you learned."
Should I start with some small console scripts and such? Or should I memorize all the operators and symbols and stuff? Any pointers at all?
http://www.mediafire.com/download.php?oyymvmmcmyv
Read though that script. It is fully commented, so you can see what each function is doing.

Hmm. That was pretty useful. Much better then reading through most scripts and I did indeed learn some. Going to read through it a few more times tonight. Thanks for that.

http://www.mediafire.com/download.php?oyymvmmcmyv
Read though that script. It is fully commented, so you can see what each function is doing.

I've been looking everywhere for this, thanks for posting it

http://www.mediafire.com/download.php?oyymvmmcmyv
Read though that script. It is fully commented, so you can see what each function is doing.
Some questions.
Quote
   schedule(300000, 0, "unmute", %blid);
What does the 0 mean/do?
Quote
if(%target == -1) return;
Would 0 work there?
Quote
%client, "", "You are currently muted.");
What does the empty "" mean/do.

What does the 0 mean/do?
What does the empty "" mean/do.

I see these everywhere and I've yet to figure it out as well. I also have absolutely no idea what arguments do/are, like in this case:

Code: [Select]
function projectile::onCollision(%this,%obj,%col,%pos,%norm,%a,%b,%c)
Allot of times I see arguments pop up in functions referenced here which never pop up anywhere in the function itself. Plus I have no idea what half of the arguments mean and where they come from. It's the final basic fator I've been trying to figure out which none of the tutorials seem to care about and it's driving me off the wall.

All i know is they're handles that store some number or something, but why do we need to reference them when we aren't even using them? And how can you figure out where these values come from? They're usually always local values too which only further confuses me since theoretically they should be deleted once their function has run it's course, plus because of this I have no idea how to track them since they go poof as soon as they're done with.
« Last Edit: July 28, 2009, 10:07:55 AM by Muffinmix »

Like the %this, %obj. I still cannot figure out where they come from or what they do.

Like the %this, %obj. I still cannot figure out where they come from or what they do.

I know %this is the individual function's ID handle (if more then one same function is running simultaneously, like through scheduling and whatnot, they have different %this values to keep them apart). Something like that

%obj is the ID of the thing that called the function. When studying a script, I have a hard time finding out what %obj is as well.

Don't quote me on any of this though, I'm as clueless as you are.

@Muffin I seem to be having the same trouble with arguments. The more I read over them the more I get confused. Also, anybody mind explaining "argc" and "argv"? I don't really get what they do or mean.

Code: [Select]
schedule(%time,0,%function,[%arg0, ... %argN])
%object.schedule(%time,%function,[%arg0, ... %argN]);
the 0 tells the engine that it's scheduling just normal function, not an object.function

Code: [Select]
messageAll('',"Message Here");
messageAll('MsgItemPickup',"Message Here",%slot,%item);
The first argument is the message type. Blank just means a normal chat message. Other special tagged strings can be used, MsgItemPickup updates your items HUD and optionally displays stuff in chat.

Alright. I'm going to change the topic title and main post. It seems a simple Q&A is working here where less experienced users can ask a question and a more advanced user can answer.

Code: [Select]
function projectile::onCollision(%this,%obj,%col,%pos,%norm,%a,%b,%c)
Allot of times I see arguments pop up in functions referenced here which never pop up anywhere in the function itself. Plus I have no idea what half of the arguments mean and where they come from. It's the final basic fator I've been trying to figure out which none of the tutorials seem to care about and it's driving me off the wall.
Much of the time for projectile collision functions, the extra arguments need to be kept so the parent/original projectile collision function works. The names can be anything (%this doesn't necessarily have to refer to the projectile, it could be a datablock, a client, a player depending on where you use it) and the projectile collision arguments are annoying/hard to remember, so people may just substitute any number of miscellaneous arguments like "%a, %b, %c" if they don't specifically have to use them.

Much of the time for projectile collision functions, the extra arguments need to be kept so the parent/original projectile collision function works. The names can be anything (%this doesn't necessarily have to refer to the projectile, it could be a datablock, a client, a player depending on where you use it) and the projectile collision arguments are annoying/hard to remember, so people may just substitute any number of miscellaneous arguments like "%a, %b, %c" if they don't specifically have to use them.

Aha! So the arguments are actually interchangeable? Like if %arg3 was originally %col in the parent but it's %a in one of the children functions referencing the parent, will %col = %a inside that specific child function?

Something like
Code: [Select]
//Parent:
function someFunction(%this,%obj,%slot,%col)
{
things;
}

//Daughter:
function Name::someFunction(%this,%obj,%slot,%a)
{
overwritting/additional things;
Parent someFunction(%this,%obj,%slot,%col) //or is %arg3 %a in this case?
}
maybe?
« Last Edit: July 28, 2009, 01:14:58 PM by Muffinmix »