Author Topic: Torque tutorials or something?  (Read 1046 times)

I'll be for real... I really want to grasp the concept of Torque Script and I have looked at Iban's tutorial, but I feel like I'm not even learning it correctly I'm pretty sure he just skips a lot of things (not really much to learn). Do not say to look at a script to learn, even tho it helps a little I really am not learning the proper way. There aren't a lot of torque script tutorials and it is really irritating. Does anyone know a good tutorial or some way to learn it!? Thx for reading!

Confucius say, just as man learns to read by reading book, man learn to code by reading code.

the blockland coding help forum is probably the best place to learn torque script, you can also look at addons that people have already made, if you need help don't be afraid to make posts here

if you need help with functions you can also look at the garage game documentation
http://docs.garagegames.com/tgea/official/content/documentation/Scripting%20Reference/Console%20Functions/TorqueScript_Console_Functions_1.html

have you ever programmed before and you're just not getting torquescript, or do you not understand the concept of algorithmic thinking?

try learning scratch for the basic idea behind code, then start figuring out how things work with text (not "blocks") then you'll be fast on your way to a fun and aggravating career in the programming industry

have you ever programmed before and you're just not getting torquescript, or do you not understand the concept of algorithmic thinking?

try learning scratch for the basic idea behind code, then start figuring out how things work with text (not "blocks") then you'll be fast on your way to a fun and aggravating career in the programming industry

I know python, but I am not getting torque script that well

what specifically are you not getting

what specifically are you not getting

the script object mambo jumbo stuff

the script object mambo jumbo stuff

What are you trying to do, using script objects?

script objects are literally just things you can use to organize stuff

i mean, i might have a stuffty view of them, but think of them SLIGHTLY like pythons modules

like suppose you make a tcpObject called "socket"

tcpObject is a subclass of a script object, i think

then you just go socket.connect("bullstuffhere.com", 808080); or whatever the syntax is

compare to python, guess what

import socket
socket.connect("stuff here")


now imagine you make a
new scriptObject(bob)
{
name = "Bob";
age = "1613";
phone_number = "867-5309";
}; //note the trailing ;. you can omit the whole bracketed portion if you want, but leave the ;. like new ScriptObject(bob);


now you can do stuff like echo(bob.phone_number); and get "867-5309" back.

you can also define methods for use with bob

function bob::getPhoneNumber(%this)
{
return %this.phone_number;
}
echo(bob.getPhoneNumber());
867-5309

Do you see what's going on? %this is set to bob because we're calling it on bob.
suppose we had...

function person::getPhoneNumber(%this)
{
return %this.phone_number;
}
new ScriptObject("bob")
{
name = "bob";
class = "person";
phone_number = "867-5309";
}
echo(bob.getPhoneNumber());
867-5309


do you see the difference? that's how it works.

a recent add-on i made had a bunch of different stuff going down. build rotation, votes, ticks, shop, etc
i made one overarching object
new ScriptObject("superobject");
then, for any new functions, i could just do
function superobject::functionname(args)
and for any variables i needed to be persistent
superobject.variable = value;

this let me tie everything into one object, it didn't clutter the namespace (which is a real problem - suppose you have an object or variable named "socket" in python, then you import socket. what happens? ostuff happens.), plus it made me feel professional

I wrote this a month or so back, if you needed yet another explantation: http://forum.blockland.us/index.php?topic=243713.msg6984828#msg6984828


Yours is better
Different explanations are worded for different people. It isn't really who's is better but that hopefully he'll be able to learn from either one of the two.

so script objects are like structs in C?