Author Topic: OH MY GOSH IM LEARNING TO CODE  (Read 4827 times)

Yes but there are reasons that the traditional types exist.

So you don't need things like useless duplicates of operators.

Code: [Select]
if(%blah $= %blergh) {
        //...
}
Code: [Select]
if(%blah == %blergh) {
        //...
}
My comment wasn't decrying traditional types, it was explaining Torque. I acknowledge Torque is the one that's wrong.

Why, why, why are my parents forcing me to learn Python?

I want to learn TorqueScript, dammit!
Trust me - you're better off. If you don't like Python, you could go for Javascript or Lua instead - each one has different upsides and downsides.
Python has very wide adoption - documentation is abundant even on individual libraries, and it does have a lot of other libraries you can use for a lot of different applications.
Javascript is, obviously, used in browsers - though use outside the browser is picking up with Node.js and other embedded V8 environments (V8 being the Javascript engine used in Google Chrome).
Lua is widely embedded in many different games and game engines - case in point is Garry's Mod, although it uses a variant (GLua - it supports C-like operators like &&, || where normal Lua only supports 'and', 'or').

Torque, on the other hand, will teach you a lot of bad habits with regards to its quirks and certain behaviours of the language. You're much better off learning another language first and applying the concepts you learn there to Torquescript. Plus, it's pretty awesome that it's your parents who are making you learn to code - my parents wanted me to learn to play the bagpipes.

My comment wasn't decrying traditional types, it was explaining Torque. I acknowledge Torque is the one that's wrong.
Yes I know. :(

<3.

Trust me - you're better off. If you don't like Python, you could go for Javascript or Lua instead - each one has different upsides and downsides.
Python has very wide adoption - documentation is abundant even on individual libraries, and it does have a lot of other libraries you can use for a lot of different applications.
Javascript is, obviously, used in browsers - though use outside the browser is picking up with Node.js and other embedded V8 environments (V8 being the Javascript engine used in Google Chrome).
Lua is widely embedded in many different games and game engines - case in point is Garry's Mod, although it uses a variant (GLua - it supports C-like operators like &&, || where normal Lua only supports 'and', 'or').

Torque, on the other hand, will teach you a lot of bad habits with regards to its quirks and certain behaviours of the language. You're much better off learning another language first and applying the concepts you learn there to Torquescript. Plus, it's pretty awesome that it's your parents who are making you learn to code - my parents wanted me to learn to play the bagpipes.
I agree with all of this. Learn something like Python or Lua first. Then move on to whatever if you want. But please, stay away from Torque Script until you really understand how things work. He will teach you awful habits that suck.

Torque Script is the weird meth smoking kid. Stay away from him.

On a totally unrelated note, I'm ashamed that I pretended to use weird fake enums in Torque Script.
Code: [Select]
$Pref::BlockyTraitors::Enum::ROLE_DEAD = 1;
$Pref::BlockyTraitors::Enum::ROLE_INNO = 2;
$Pref::BlockyTraitors::Enum::ROLE_TATER = 3;
$Pref::BlockyTraitors::Enum::ROLE_WATCH = 4;

Lugnut should make a class for us.



He is the teacher.


Teach us Torque!





<3.
<3

On a totally unrelated note, I'm ashamed that I pretended to use weird fake enums in Torque Script.
Code: [Select]
$Pref::BlockyTraitors::Enum::ROLE_DEAD = 1;
$Pref::BlockyTraitors::Enum::ROLE_INNO = 2;
$Pref::BlockyTraitors::Enum::ROLE_TATER = 3;
$Pref::BlockyTraitors::Enum::ROLE_WATCH = 4;
It is actually good to do that (though you wouldn't want something like that in the Pref namespace) - makes your code easier to read. No need to write comments if your code's behaviour is obvious from reading the code itself. I personally would have used something like $BlockyTraitors::Role::Dead.

I'm learning to code in flash, it's really fun.
http://puu.sh/1385U
69 lines of code, fairly challenging. When you learn the ropes it's a real joy to do this stuff though.
Code: [Select]
import flash.events.Event;
import flash.display.Sprite;

//written by Samuel Struik
//8 September 2012
/*
T = make a rectangle move across the screen three times. once this is done, the rectangel will begin following the mouse.
O = rect_mc, feedback_txt
M = Use booleans to toggle the mouse following and the automatic movement. use if statements to increment variables and make the rectangle return to its original side.
*/
//**variables
//shapes
var rect_mc:Sprite = new Sprite();
rect_mc.graphics. beginFill(0x333333);
rect_mc.graphics.drawRect(-5, -5, 10, 10)
rect_mc.graphics.endFill();
stage.addChild(rect_mc);
rect_mc.y = 200
rect_mc.x = -21
//numbers, booleans
var dragToggle:Boolean = false;
var crossCount:Number = 0;
var moveDirec:Number = 1;

//**Event Listeners
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

//**functions
function enterFrameHandler(e:Event):void{
//if the dragToggle boolean isn't active
if(!dragToggle){
if(moveDirec == 1){
//use the equation of acceleration to make the object decellerate
rect_mc.x += (575 - rect_mc.x)/8
if(rect_mc.x > 571){
//when the movieclip's x coordinate is larger than 571, increment the crossCount variable by one and make the direction variable change.
crossCount ++;
moveDirec = 2;
//display the variable in the text field.
crossFeedback_txt.text = ""+String(crossCount)+"";
}
}
if(moveDirec == 2){
//use the equation of acceleration to make the object decellerate
rect_mc.x += (-25 - rect_mc.x)/8
//when the movieclip's x coordinate is smaller than -25, increment the crossCount variable by one and make the direction variable change.
if(rect_mc.x < -21){
crossCount ++;
moveDirec = 1;
//display the variable in the text field.
crossFeedback_txt.text = ""+String(crossCount)+"";
}
}
}
if(dragToggle){
//yet again, using the equation of acceleration to make the square move smoothly.
rect_mc.x += (stage.moulove - rect_mc.x)/6
rect_mc.y += (stage.mouseY - rect_mc.y)/6
background_mc.gotoAndPlay(2);
}
if(crossCount == 5){
dragToggle = true;
//inform the user of the square's new behaviour.
crossFeedback_txt.text = "The square will now follow your cursor.";
}
//displaying the x and y coordinates of the shape and the mouse, for debugging.
rectxy_txt.text = "rect_mc.x = "+String(rect_mc.x)+"\nrect_mc.y = "+String(rect_mc.y)+"";
moulovey_txt.text = ""+String(moulove)+" = moulove\n"+String(mouseY)+" = mouseY";
}

Why, why, why are my parents forcing me to learn Python?

I want to learn TorqueScript, dammit!
Don't be so frustrated, once you learn one language, it's much easier to learn the next language. ;)

Why, why, why are my parents forcing me to learn Python?

I want to learn TorqueScript, dammit!
Python is a great language to get started on.
Once you get a hang of it the rest are easy.

Only if my parents taught me how to code.....




Our County doesn't have any coding schools,


at all. :C

Lugnut should make a class for us.
um nothanks
Don't even-
:(
Javascript is, obviously, used in browsers - though use outside the browser is picking up with Node.js and other embedded V8 environments (V8 being the Javascript engine used in Google Chrome).
i found this and couldn't figure out what it does

i'm trying to learn torquescript and now i know the extremely basic stuff but idk what to do with it :/

i found this and couldn't figure out what it does
It's Javascript with the browser APIs (DOM manipulation, browser interaction and such) cut out and replaced with APIs for stuff like HTTP serving, raw TCP/UDP sockets, file operations, etc. running under V8. (plus obviously support for accessing your own libraries written in C++ or JS)
I worked for a while on a wrapper that spawns a Blockland dedicated server as a child process and uses Node.js to provide access to its console output, and I also write utilities to make my college work easier using it since you can use the REPL library to make an interactive JS environment with your own code pre-loaded into it.
The API documentation has everything you'd need to get started, assuming you know JS syntax and the base objects and such. Notably the Net library for TCP sockets.

Running it on its own just provides an interactive Javascript session too, which is handy for stuff like testing code concepts/snippets. Running a file is just node aaa.js much like with any other script environment.