SRL Archive - News and General

LoginPlayer


xxlegitxx

2007-08-09 20:08:19

In a fair amount of scripts I've looked through, I'm constantly confronted with this bit of evil code:


if (not (LoggedIn)) then LoginPlayer;

and all its variations. It's redundant and only serves to waste time and cpu cycles. It can be cut down to this:


LoginPlayer;

Comments? Thoughts? Objections?

bullzeye95

2007-08-09 20:14:58

I don't really see the harm in it. LoggedIn is just a GetColor, which is faster (by a surprising amount) than writeln.

Run this:
program New;
var
I, T: Integer;
begin
T:= GetSystemTime;
for I:= 1 to 1000 do
GetColor(0, 0);
writeln(inttostr(GetSystemTime - T));
end.
It'll write how long it took for it to use GetColor 1000 times.

xxlegitxx

2007-08-09 20:24:53

True, less than .1 ms. But in terms of clean code, why bother including it? I see absolutely no benefit.

bullzeye95

2007-08-09 20:28:26

I usually just do it out of habit. I even find myself typing "if(not(Loggedin))then exit;" on procedures/functions that aren't used with RS sometimes :p

xxlegitxx

2007-08-09 20:35:01

Haha, nice. I love using SCAR for mundane tasks and cheap flash games. :P

Boreas

2007-08-09 23:26:14

Yes. Also a lot of people don't realize that Gametab() checks if you are already there, and they put a needless failsafe. There are a few other examples, which basically means, print out SRL and read through it whenever you're waiting for something.

xxlegitxx

2007-08-10 08:55:16

From: Boreas
Yes. Also a lot of people don't realize that Gametab() checks if you are already there, and they put a needless failsafe. There are a few other examples, which basically means, print out SRL and read through it whenever you're waiting for something.


Yea, I see that a lot. People also click the magic tab, then use SRL's Cast when SRL should click it for them, as well as a host of other similar things.

People put small random waits after Mouse or MMouse, when it already has a 100 + Random(100) wait by default. You think we should make a topic listing all the common redundancies found in scripts?

Boreas

2007-08-10 09:37:37

Be my guest.