Author Topic: I rarely see any new addons being made.  (Read 2478 times)

yeah sorry i meant to put that

not sure if still on topic but another cool trick is the ability to declare variables inside of if statements
for example

if((%var = getData()) == 5)
{
   // use %var here
}


except 9 times out of 10 it's unnecessary and just makes your code more unreadable
it can make number checks elegant and easy, though

%string = "You have" SPC %apples SPC "apple" @ (%apples != 1) ? "s." : ".";
« Last Edit: April 25, 2017, 08:03:52 PM by Darksaber2213 »

it can make number checks elegant and easy, though

%string = "You have" SPC %apples SPC "apple" @ (%apples != 1) ? "s." : ".";


But there's literally no point to that.

Unless you really, really need every last nanosecond (like you're programming for the Atari 2600 or something) it just makes your code harder to follow for whoever has to read it later (which might be you in a few weeks/months/years)
« Last Edit: April 25, 2017, 08:54:29 PM by Electrk. »

one of my favorite torquescript cheats is a ? b : c. i end up using it like 90% of the time in every add-on and it saves so much time.

check out my murder gamemode and you'll see i use it for the most part of the code.

not sure if still on topic but another cool trick is the ability to declare variables inside of if statements
for example

if((%var = getData()) == 5)
{
   // use %var here
}

I like to use that for isObject checks.
if(isObject(%player = %client.player))
{
     %player.kill();
}


it just makes your code harder to follow for whoever has to read it later
I've noticed that.  I want to standardize what cases I use it in.

it can make number checks elegant and easy, though

%string = "You have" SPC %apples SPC "apple" @ (%apples != 1) ? "s." : ".";

But there's literally no point to that.
I personally like more polished code
instead of saying you have "5 apple", I prefer it to be correct English with "you have 5 apples"
that way it doesn't sound like somebody outsourced the scripting to india

Unless you really, really need every last nanosecond (like you're programming for the Atari 2600 or something) it just makes your code harder to follow for whoever has to read it later (which might be you in a few weeks/months/years)
I doubt it speeds up execution any
it just speeds up writing it and is easier to read than having an if statement with almost identical prints

I personally like more polished code
instead of saying you have "5 apple", I prefer it to be correct English with "you have 5 apples"
that way it doesn't sound like somebody outsourced the scripting to india

I didn't mean there was no point to make it plural or singular.  I was talking about the ternary operator.

I didn't mean there was no point to make it plural or singular.  I was talking about the ternary operator.
but then you have 4 lines on your screen dedicated to just the plural check, which is pointless

I didn't mean there was no point to make it plural or singular.  I was talking about the ternary operator.
echo("server has " @ %playercount @ " player" @ (%playercount == 1 ? "." : "s."));

vs

if(%playercount == 1)
   echo("server has 1 player.");
else
   echo("server has " @ %playercount @ " players.");

seems a lot bulkier and harder to read just to not use a feature

yeah, I guess in this context it makes sense

EDIT: no I take it back it still looks ugly
« Last Edit: April 29, 2017, 03:08:18 PM by Electrk. »

Not many people really care about Enviroments TBH.
I am working on a Retrowave/Synthwave Enviroment, though it won't come out for a while.

in torque ternary ops are mostly useless but in other languages that treat functions as objects it can be incredibly useful, since having the ability to pass functions as parameters (and return them) in general opens up a lot of functionality/modularization.