SRL Archive - News and General

Common Redundancies in Scripts


xxlegitxx

2007-08-11 00:09:52

These are common redundancies I find in scripts that can be shorted with a beneficial effect on your script:


if ( not(LoggedIn)) then LoginPlayer;
to:

LoginPlayer;
LoginPlayer calls in LoggedIn anyway.




if (WearingItem(i)) then TakeOffItem(i);
to:

TakeOffItem(i);
Redundant.




Mouse(x, y, randx, randy);
Wait(100 + Random(100));
to:

Mouse(x, y, randx, randy, leftclick);
Mouse has a small random wait after the procedure, making it unnecessary to include another.




GameTab(1);
SetUpAutoCast(AutoSpell, Defensive); OR SetFightMode(oFightMode); OR GetCombatLevel;
to:

SetUpAutoCast(AutoSpell, Defensive); OR SetFightMode(oFightMode); OR GetCombatLevel;




GameTab(2);
GetHP; OR GetSkillAmount(skill); OR GetSkillLevel(skill); OR NextLevelAt(skill); OR GetXP(skill); OR XpTilNextLevel(skill, round); OR HpPercent; OR GetHp; OR GetAllLevels; OR RealEatIfNeeded;
to:

GetHP; OR GetSkillAmount(skill); OR GetSkillLevel(skill); OR NextLevelAt(skill); OR GetXP(skill); OR XpTilNextLevel(skill, round); OR HpPercent; OR GetHp; OR GetAllLevels; OR RealEatIfNeeded;




GameTab(4);
FindItemsArray(color, tol, Text, num); OR WeHaveLogs(WhereX, WhereY); OR FindFishingEquipment(FishingEquipmentColor, FishingEquipmentName); OR FindPickHeadColor; OR FindPick; OR FindInvArrows(arrowx, arrowy); OR EquipArrows; OR ClickPouch(Pouch, Option, tol); OR ClickTalisman; OR FindAxeHeadColor; OR AttachHead; OR FindHead;
to:

FindItemsArray(color, tol, Text, num); OR WeHaveLogs(WhereX, WhereY); OR FindFishingEquipment(FishingEquipmentColor, FishingEquipmentName); OR FindPickHeadColor; OR FindPick; OR FindInvArrows(arrowx, arrowy); OR EquipArrows; OR ClickPouch(Pouch, Option, tol); OR ClickTalisman; OR FindAxeHeadColor; OR AttachHead; OR FindHead;
Note: FindTalismanInInventory needs to be updated to include (GameTab(4)) before checking for talismans.




GameTab(5);
WearingItem(i); OR TakeOff(i); OR CheckEquipItems(number); OR ArrowAmount; OR GetArrowColor; OR AttachHead;
to:

WearingItem(i); OR TakeOff(i); OR CheckEquipItems(number); OR ArrowAmount; OR GetArrowColor; OR AttachHead;




GameTab(6);
PrayerClick(Prayer); OR ClickPrayer(slot, Activated); OR AllPrayersOff;
to:

PrayerClick(Prayer); OR ClickPrayer(slot, Activated); OR AllPrayersOff;
Note: ExistsPrayer needs to be updated to include "GameTab(6)" before checking the prayer slots.




GameTab(7);
Cast(TheSpell); OR CastSpell(SpellNumber); OR CastOn(Spell, Monster, MonsterColor, Tolerance); OR GetLumbridgeMins;
to:

Cast(TheSpell); OR CastSpell(SpellNumber); OR CastOn(Spell, Monster, MonsterColor, Tolerance); OR GetLumbridgeMins;




GameTab(8);
CurrentWorld;
to:

CurrentWorld;




GameTab(11);
SetRun;
to:

SetRun;




GameTab(12);
DoEmote(EmoteNumber); OR RandomEmote;
to:

DoEmote(EmoteNumber); OR RandomEmote;
These procedures and functions already select the game tab, rendering it useless to select the gametab beforehand.


Also, sometimes you need to hover your mouse over something before clicking. So do MMouse, then take this procedure from Mouse:

Wait(60 + Random(30));
GetMousePos(b, c);
HoldMouse(b + 1, c, left);
repeat
Wait(20 + Random(30));
a := a + 1;
until (a > 4);
GetMousePos(b, c);
ReleaseMouse(b, c, left);
Unless there is some better way?

And I need you guys to post anything else that is superfluous.

LordGregGreg

2007-08-11 10:02:46

From: xxlegitxx
These are common redundancies I find in scripts that can be shorted with a beneficial effect on your script:


if ( not(LoggedIn)) then LoginPlayer;
to:

LoginPlayer;
LoginPlayer calls in LoggedIn anyway.



if (WearingItem(i)) then TakeOffItem(i);
to:

TakeOffItem(i);
Redundant.


OK, i took a look at the first few, and yeah, they are redundant in a way , but they are like that for a reason.

Double checking what is going on (like if you are loged in or not) is used as a failsafe way to make sure you script doesnt do anytrhing stupid

including an if before hand allows the scriopt to save extra processing time by not using a method it doesnt need to.

Hugolord

2007-08-11 10:05:41

From: lordgreggreg
From: xxlegitxx
These are common redundancies I find in scripts that can be shorted with a beneficial effect on your script:


if ( not(LoggedIn)) then LoginPlayer;
to:

LoginPlayer;
LoginPlayer calls in LoggedIn anyway.



if (WearingItem(i)) then TakeOffItem(i);
to:

TakeOffItem(i);
Redundant.


OK, i took a look at the first few, and yeah, they are redundant in a way , but they are like that for a reason.

Double checking what is going on (like if you are loged in or not) is used as a failsafe way to make sure you script doesnt do anytrhing stupid

including an if before hand allows the scriopt to save extra processing time by not using a method it doesnt need to.


but most of them already check automatically

Santa_Clause

2007-08-11 10:12:17

From: lordgreggreg
From: xxlegitxx
These are common redundancies I find in scripts that can be shorted with a beneficial effect on your script:


if ( not(LoggedIn)) then LoginPlayer;
to:

LoginPlayer;
LoginPlayer calls in LoggedIn anyway.



if (WearingItem(i)) then TakeOffItem(i);
to:

TakeOffItem(i);
Redundant.


OK, i took a look at the first few, and yeah, they are redundant in a way , but they are like that for a reason.

Double checking what is going on (like if you are loged in or not) is used as a failsafe way to make sure you script doesnt do anytrhing stupid

including an if before hand allows the scriopt to save extra processing time by not using a method it doesnt need to.


LoginPlayer already has a failsafe in it…that's why we don't do if(not(LoggedIn)).

xxlegitxx

2007-08-11 10:44:47

From: lordgreggreg

OK, i took a look at the first few, and yeah, they are redundant in a way , but they are like that for a reason.

Double checking what is going on (like if you are loged in or not) is used as a failsafe way to make sure you script doesnt do anytrhing stupid

including an if before hand allows the scriopt to save extra processing time by not using a method it doesnt need to.


Double checking logging in is simply getting a color, as bullzeye pointed out to me. Getting a color, then getting it again a split second afterwards is unlikely to change much. And if you include an if before an unnecessary function, you actually waste processing time, as inconsequential as it may be.

This is what you're doing by including another if:

if ( not(LoggedIn) then
begin
ClickHereToPlay := BitmapFromString(33, 1, 'z78DA758E510E80300843' +
'AF54C0E2F6E94CB8FF9134123392693FFA41FA4A23A6F0888443D' +
'26DC000A7DCE7F458F23EE444E721444B6A0F53D58FE44F4365B7' +
'067D37AC3D95AADF2F50962C79');
if (not (LoggedIn)) then <-- You see, the script already includes the 'if' statment
begin
// Beginning player not active...
...
...
end;
end;