Poll

Which coding langauge is best for learning Torque?

C++
Java
Niether, does not matter

Author Topic: C++ and Torque Script  (Read 3725 times)

Code: [Select]
int main(void)
{
     cout >> "4";
}

I haven't done C++ in a while, so above will probably just give you a syntax error.

From the absolutely nothing of C++ that I know, I think you'd just have to include stdio.

From the absolutely nothing of C++ that I know, I think you'd just have to include stdio.
no I think it's another library for cout

Edit: Yep, for cout it's <iostream>
For printf(); it's stdio
« Last Edit: March 24, 2013, 02:31:13 PM by Aide33 »

Torque is a scripting language written in C++ so yeah they are going to be at least syntactically simililar

Also I wouldn't suggest Java, it's an ugly patchwork language with too many quirks to count.

Torque is a scripting language written in C++ so yeah they are going to be at least syntactically simililar

Also I wouldn't suggest Java, it's an ugly patchwork language with too many quirks to count.
Android, yo.

The syntax is more related to C# imo, but if you have a full knowledge of C++ you will be able to learn it pretty fast

The syntax is more related to C# imo, but if you have a full knowledge of C++ you will be able to learn it pretty fast

I see.

The syntax is more related to C# imo, but if you have a full knowledge of C++ you will be able to learn it pretty fast
You can also learn torquescript fast while not understanding c++ at all

They syntax isn't really that similar.  TorqueScript functions go something like
Code: [Select]
function doStuff(%cl,%arg1,%arg2)
{
     echo(2+2);
}
and C++ is more like
Code: [Select]
int main(void)
{
     cout >> "4";
}

I haven't done C++ in a while, so above will probably just give you a syntax error.
Yeah that's a syntax error.

Code: [Select]
#include <iostream>

int main()
{
    using namespace STD;
    cout >> add(2,2);
    int i
    cin << i;
    return 0;
}
int add(int x, int y)
{
    int z = x+y;
    return z;
}
« Last Edit: March 25, 2013, 07:32:53 AM by Evar678 »

You can also learn torquescript fast while not understanding c++ at all

If you can learn one language you can learn them all. Though you probably can't master them. I really think it's about first learning how to go about learning a programming language.

 I am by no means experienced in any language but I have an ok understanding of java, and it made doing anything in torque a thousand times easier then the last time I attempted it. Also being alright at math makes programming a lot easier.

Yeah that's a syntax error.

Code: [Select]
#include <iostream>

int main()
{
    using namespace STD;
    cout >> add(2,2);
    int i
    cin << i;
    return 0;
}
int add(int x, int y)
{
    int z = x+y;
    return z;
}
so is the code you posted. actually yours has more errors than his did lol.

Code: [Select]
#include <iostream>

int main()
{
    using namespace STD; // error - it's std not STD
    cout >> add(2,2); // will error as add hasn't be declared / defined, also wrong operators
    int i // missing semicolon, error here as well
    cin << i; // wrong operators
    return 0;
}
int add(int x, int y)
{
    int z = x+y;
    return z;
}

error spew from msvc++:
Code: [Select]
Error 1 error C2871: 'STD' : a namespace with this name does not exist c:\users\default_2\desktop\consoleapplication1\consoleapplication1.cpp 5 1 ConsoleApplication1
Error 2 error C2065: 'cout' : undeclared identifier c:\users\default_2\desktop\consoleapplication1\consoleapplication1.cpp 6 1 ConsoleApplication1
Error 3 error C3861: 'add': identifier not found c:\users\default_2\desktop\consoleapplication1\consoleapplication1.cpp 6 1 ConsoleApplication1
Error 4 error C2146: syntax error : missing ';' before identifier 'cin' c:\users\default_2\desktop\consoleapplication1\consoleapplication1.cpp 8 1 ConsoleApplication1
Error 5 error C2065: 'cin' : undeclared identifier c:\users\default_2\desktop\consoleapplication1\consoleapplication1.cpp 8 1 ConsoleApplication1
6 IntelliSense: name must be a namespace name c:\Users\Default_2\Desktop\ConsoleApplication1\ConsoleApplication1.cpp 5 21 ConsoleApplication1
7 IntelliSense: identifier "cout" is undefined c:\Users\Default_2\Desktop\ConsoleApplication1\ConsoleApplication1.cpp 6 5 ConsoleApplication1
8 IntelliSense: expected a ';' c:\Users\Default_2\Desktop\ConsoleApplication1\ConsoleApplication1.cpp 8 5 ConsoleApplication1

If you can learn one language you can learn them all. Though you probably can't master them. I really think it's about first learning how to go about learning a programming language.

 I am by no means experienced in any language but I have an ok understanding of java, and it made doing anything in torque a thousand times easier then the last time I attempted it. Also being alright at math makes programming a lot easier.
pretty much this.

also in terms of math, as long as you passed Algebra and have a decent brain in your head it's not that difficult.
« Last Edit: March 26, 2013, 06:53:17 PM by Kaphonaits² »

Who voted Java..?
I know Java and a tiny bit of torque, and the syntax is extremely different. 
C++ is much better to go along with torquescript rather than Java. 

Java is good for applications that you want to easily port to tons of OS's.  However, it is not good for making full blown games (as it is much slower than many other languages).


java makes me angry.
Its nice because it isn't too hard to learn, and it can be run on any computer OS.  However, a downside is that its slow. 

so is the code you posted. actually yours has more errors than his did lol.
except he did declare add, it's a function just below main. the parameters are two integers too so i don't see a problem there. though i am pretty sure cout is << and cin is >> but i can never remember.

Code: [Select]
#include <iostream>

using namespace std;

int add( int x, int y )
{
    return x + y;
}

int main()
{
    int i;

    cout << add( 2, 2 );
    cin >> i;
    return 0;
}
is how i would have done it, although recently i've been working more in C than C++.

except he did declare add, it's a function just below main. the parameters are two integers too so i don't see a problem there.
But it has to be declared above main