Author Topic: Where can I learn to script?  (Read 1926 times)

I wanna make a few items (weapons) for my server that do certain actions. For example if you touch a certain team with a weapon then the player gets sent to a brick or certain point.

Is there a place where you can learn this type of stuff or do I have to search through addons and view examples to get the hang of it?

looking at what's already been done and copying it is probably your best bet

what do you mean by touch with a weapon, do you mean hit with a projectile, or physically the players touched eachother?

as for teleporting to a position, it's not difficult to set position through a script (it's something like %player.setPosition(%pos) or something, use %player.dump(); to check commands)

looking at what's already been done and copying it is probably your best bet

what do you mean by touch with a weapon, do you mean hit with a projectile, or physically the players touched eachother?

as for teleporting to a position, it's not difficult to set position through a script (it's something like %player.setPosition(%pos) or something, use %player.dump(); to check commands)
Yeah I meant hit (melee) , but how would would I make it teleport someone to a brick? or would I have to put a cordinate?

Yeah I meant hit (melee) , but how would would I make it teleport someone to a brick? or would I have to put a cordinate?

so if its a public build -which is better for that type of stuff unless you're making events- you can do something like
Code: [Select]
%pl.setTransform(BrickGroup_888888.NTObject["ingame_brick_name", getRandom(0, BrickGroup_888888.NTObjectCount_ingame_brick_name)]);

Not sure if you're looking to learn how to script, or just get an add-on or two put together. But if you are serious about learning TorqueScript, and have no prior programming experience, I would recommend starting with this list. Start up a game, open your console (use the '~' key), and type some of the commands on that page into it. Play around with them and just get familiar with how basic command work.

Once you're comfortable with the console, I would recommend checking out Weebly's TorqueScript For Blockland, a website which teaches basic add-on making. Also, if you videos help you learn, I would recommend Bloxland's Blockland Scripting tutorials on YouTube. Neither of these resources are going to teach you everything you need to know. But they'll give you a good idea of where to start.

I would also recommend reading the official TorqueScript Scripting Reference. It gets pretty technical, and isn't exactly an easy read for a beginner. But it talks about concepts like packages, datablocks, etc., which are very important in TorqueScript. I would recommend reading it after going through one (or both) of the tutorial series I posted above.

Do understand (assuming you've never programmed before) that learning to script isn't going to be easy. But it's definitely worth it. Take your time and be patient. Learning to program, like any skill, takes time to develop and master. And don't get frustrated if it takes you awhile to understand something. School doesn't really prepare you for this kind of stuff, unfortunately.



As for making the melee weapon you want to make, you'll need to

  • Figure out how to teleport a player to a brick. adel's code looks good. After you've played with the console a little, see if you can get his code to work. You'll probably need to use a different BrickGroup if the bricks you are using for testing aren't public
  • Figure out how to create an item that teleports a player when it hits them.
  • Figure out how to make sure a player can only teleport people on the other team. It sounds like you are using Slayer to create teams, so you'll have to integrate you're weapon with that. It'll be pretty simple. I can help you with it when you get to this point.

I recommend you work on your programming skills a bit first, though. There's not too much we can help you with until you have some basic knowledge of how TorqueScript works.

also tip for using the script i said you could use

with the new duplicator, you can set the pref "Admin Bypass Trust (Edit)" to true and then do /plantas 888888 then plant to place public bricks

if you dont want to do that, instead just set it to BrickGroup_your_blid

so here's also a bit of explanation about my code:
BrickGroup_blid = all the bricks of a certain BLID

BrickGroup_blid.NTObject["Brick_Name", Number] = Number is which one of the bricks with the name "Brick_Name" the function is called on

BrickGroup_blid.NTObjectCount _Brick_Name = the amount of bricks called "Brick_Name"

so, BrickGroup_888888.NTObject["Brick_Name", getRandom(0,BrickGroup_888888.NTObjectCount_Brick_Name) points to a random brick called "Brick_Name" which is in the brick group 888888 aka public bricks.

looking at what's already been done and copying it is probably your best bet

what do you mean by touch with a weapon, do you mean hit with a projectile, or physically the players touched eachother?

as for teleporting to a position, it's not difficult to set position through a script (it's something like %player.setPosition(%pos) or something, use %player.dump(); to check commands)
also tip for using the script i said you could use

with the new duplicator, you can set the pref "Admin Bypass Trust (Edit)" to true and then do /plantas 888888 then plant to place public bricks

if you dont want to do that, instead just set it to BrickGroup_your_blid

so here's also a bit of explanation about my code:
BrickGroup_blid = all the bricks of a certain BLID

BrickGroup_blid.NTObject["Brick_Name", Number] = Number is which one of the bricks with the name "Brick_Name" the function is called on

BrickGroup_blid.NTObjectCount _Brick_Name = the amount of bricks called "Brick_Name"

so, BrickGroup_888888.NTObject["Brick_Name", getRandom(0,BrickGroup_888888.NTObjectCount_Brick_Name) points to a random brick called "Brick_Name" which is in the brick group 888888 aka public bricks.
Not sure if you're looking to learn how to script, or just get an add-on or two put together. But if you are serious about learning TorqueScript, and have no prior programming experience, I would recommend starting with this list. Start up a game, open your console (use the '~' key), and type some of the commands on that page into it. Play around with them and just get familiar with how basic command work.

Once you're comfortable with the console, I would recommend checking out Weebly's TorqueScript For Blockland, a website which teaches basic add-on making. Also, if you videos help you learn, I would recommend Bloxland's Blockland Scripting tutorials on YouTube. Neither of these resources are going to teach you everything you need to know. But they'll give you a good idea of where to start.

I would also recommend reading the official TorqueScript Scripting Reference. It gets pretty technical, and isn't exactly an easy read for a beginner. But it talks about concepts like packages, datablocks, etc., which are very important in TorqueScript. I would recommend reading it after going through one (or both) of the tutorial series I posted above.

Do understand (assuming you've never programmed before) that learning to script isn't going to be easy. But it's definitely worth it. Take your time and be patient. Learning to program, like any skill, takes time to develop and master. And don't get frustrated if it takes you awhile to understand something. School doesn't really prepare you for this kind of stuff, unfortunately.



As for making the melee weapon you want to make, you'll need to

  • Figure out how to teleport a player to a brick. adel's code looks good. After you've played with the console a little, see if you can get his code to work. You'll probably need to use a different BrickGroup if the bricks you are using for testing aren't public
  • Figure out how to create an item that teleports a player when it hits them.
  • Figure out how to make sure a player can only teleport people on the other team. It sounds like you are using Slayer to create teams, so you'll have to integrate you're weapon with that. It'll be pretty simple. I can help you with it when you get to this point.

I recommend you work on your programming skills a bit first, though. There's not too much we can help you with until you have some basic knowledge of how TorqueScript works.
I can't thank you guys enough for helping me out (I would probably be banned for spamming). I'll spend a couple days/weeks/months learning this stuff, and correcting my mistakes C:.
p.s thanks again!

Banned for spamming? If you have tons of questions just keep them in 1 thread, nothing wrong with having a question every other day.