Author Topic: Function Torque commands Guide help? Or help in general? (Scripting)  (Read 2155 times)

Yea yea yea I'm new at coding don't correct me if I'm saying things wrong, because I know most of it will probably be wrong. I really want to know how to use Torque Functions and the coding underneath it. I know the basic format, just not where to get these commands or functions... DumpConsole() or something like that is something I tried to use, but I'm so unfamiliar with all the commands popping up.. This is what I know so far (Below)

Function (Insert something like Test/Servercmd here)
[
( Code like echo("Hello World"); )
]
 
And basically it will display it in the console if you say test(); I think.

And before you ask look around the forums and try badspots posts and guide links, props to me... the function guide is wierd and I literally see just a bunch of text about some person or some other stuff no Torque functions guide.

Yes I've searched most of the forums for functions guides but I end up finding Bull-crap like someone telling someone how to make a specific code for a certain thing but some oddway how which gets me confused, I've searched up Torque engine commands, but I'm specifically looking for blockland styled functions/Commands or something related to that as so that I could make specific types of things I want to make. I know the basics and I can understand if I can just find a tutorial with a good functions guide and where to get all the commands that go with it.

God Help me I've been playing blockland for so long, I want to be able to make something unique and fun but I can't even find a good guide...


* I have tried to learn, but the farthest I've gotten is script/server testing scripts like Variables...

I want to be able to make my own events and make weapons have special properties or even make a nice game mode with hunger, fear, or even a enemies or player leveling system (Yea vce is good for that, but it different when you need to scale them equally)



Basically I just need some help or even a nice good guide that can take me through.

Yea my rant is big af and probably something someone would just facepalm at, but I really want to be able to do the amazing things that only coding/scripting can do so please.... help... me...

you should probably be more specific about what you want
the best guide is other addons that are doing similar things to what you want

syntax for generic functions:

function example(%param1,%param2)
{
        echo("this happens when you run the function" SPC %param1+%param2);
}


to call the function, type example(3,6); in the console (use tilde ~ key). the %param1 stuff are parameters you can add to your function. there can be as many as you want.

if you want to make a server command, just type 'servercmd' before the function name and then it can be accessed through /example 1 5

http://docs.garagegames.com/torque-3d/official/content/documentation/Scripting/Simple/Functions.html
« Last Edit: July 26, 2017, 08:07:52 PM by PhantOS »

dont get too ahead of yourself with the creating gamemodes and stuff. it might take over a year of constant experimenting and learning before you can tackle stuff like that

pretty sure he's trying to make an event to change playertype based on team

the more correct way would be to have options to select the team and target players specifically based on that
the easier way is to just hard code it and loop through all players on the server and check their team

to figure out what variables are being used to specify team, you may want to use .dump() on your client (findclientbyname("phflack").dump(); would dump my client info)

put a brick near the team spawn that changes the playertype. that way when that team's players spawn they will walk over the brick and change playertypes

function example(%param1,%param2)
{
        echo("this happens when you run the function" SPC %param1+%param2);
}

I really don't like people using SPC for unnecessary situations - It is a bit slower than using @ and it looks bad to me, makes me think people are lazy to use it
If you're using it for things like %x SPC %y SPC %z I would be ok with it

Of course you can use still use it but I don't recommend teaching beginners this because it can result in weird situations of using it - I remember when I started to use SPC and things starting looking pretty ugly and unnecessary to put SPC at

personally i like it when whole strings in quotes are trimmed proper. "the lazy dog ran over the " gives me an asthma attack

"the lazy dog ran over the" SPC  is just a bit neater string wise than "the lazy dog ran over the " @. either way it boils down to preference

either way it boils down to preference
Yea which is why I'm not going to give crap to anyone for using it (even though I said I don't like people using it) but it's just something to think about; but if you're using it for performance or using it heavily in a function it's not recommended to use SPC over @ unless you actually have to use it

https://forum.blockland.us/index.php?topic=214415.0

http://tsforblockland.weebly.com/

http://blockland.wikia.com/wiki/Category:Scripting

https://forum.blockland.us/index.php?topic=287458.0

Those should help you. You need to ask questions specific to what you're trying to do. You also need to understand that programming takes time. You aren't going to be a wizard at writing code for a while. These are the steps you should take:

1. discover problem
2. research problem (bl forums search, google, etc)
3. if you can't figure out the problem, then come here and explain what you're trying to do, and the problem you've ran into.

You can also add some developers on steam or send a private message. You can add me if you want, steam is:

Elmling (with the 100 emoji).

Alright elm I'll try and add you on steam, but here's one I really want to know how to do so I can modify it, and change it to my own variables. Ex: A hunger bar that goes down every *X amount of seconds/min, unless you do something about it.

You can also add me on steam for help too (Visolator)
To make a hunger system you have to either make a function or a class function - both involve the client and the player. Then you make a schedule repeating the function call.

There are all kinds of ways you can make a hunger system

you can also ask on the blockland content creators discord for help
https://discord.gg/r6ERkqy

If you wanna learn TorqueScript, I recommend reading the documentation provided by GarageGames.

Official Torque Game Engine Documentation
Here's a list of things you can read (read it in this order):
Scripters > Reference > TorqueScript Overview
Reference > Console Functions (virtually all of these functions work within Blockland)
Reference > Console Objects (virtually all of these objects work within Blockland)

Here's some extra links for making add-ons:
GameMode Reference
Event System Reference

It's good education to look inside other add-ons. Many of the default add-ons include helpful comments too to get you going.
Console fiddling can be useful. Try trace(1); (to activate) and trace(0); (to deactivate) and it will print TorqueScript functions being executed into the console. (can be useful when making packages)

Good luck!

reading over the documentation sounds so much more painful than just looking at other addons