SRL Archive - General Botting Help

Short-circuit evaluation?


Thomas

2015-05-16 03:00:23

Does Simba allow for Short-circuit evaluation?
http://en.m.wikipedia.org/wiki/Short-circuit_evaluation

Example 1:
if (actionbar.getAdrenalinePercent() = 100) and (berserkTimer.getTime() > 60000) then
begin
sendKeys('b', 200, 40);
berserkTimer.start();
healthTimer.start();
exit;
end;

If I put the timer check before the adrenenaline check, and the timer check results false, will the script still check the adrenbar%?

Example 2:
Would this:
function areaCheck(): boolean;
begin
if length(ogl.getModels(403123861, mainScreen.getBounds())) or length(ogl.getModels(584121683, mainScreen.getBounds())) then
exit(true);
end;
Be the exact same as this:
function areaCheck(): boolean;
begin
if length(ogl.getModels(403123861, mainScreen.getBounds())) then
exit(true);
if length(ogl.getModels(584121683, mainScreen.getBounds())) then
exit(true);
end;

adc

2015-05-16 03:10:45

program new;

function checkOne(): boolean;
begin
Writeln('One');
exit(false);
end;

function checkTwo(): boolean;
begin
Writeln('Two');
exit(true);
end;


begin
if(checkOne() and checkTwo()) then
Writeln('Three');
end.

Short answer; yes.

Thomas

2015-05-16 03:39:55

From: adc
program new;

function checkOne(): boolean;
begin
Writeln('One');
exit(false);
end;

function checkTwo(): boolean;
begin
Writeln('Two');
exit(true);
end;


begin
if(checkOne() and checkTwo()) then
Writeln('Three');
end.

Short answer; yes.


I'm sure you mean no, because it does check the second statement:
program new;

function checkOne(): boolean;
begin
Writeln('One');
exit(false);
end;

function checkTwo(): boolean;
begin
Writeln('Two');
exit(true);
end;


begin
if(checkOne() or checkTwo()) then
Writeln('Three');
end.

adc

2015-05-16 04:01:16

You're using "or" there. checkOne() returns false, and thus it checks checkTwo(), which returns true, resulting in all three outputs. In my post, I used "and", which causes it to only output "One", as checkOne() returns false. If you change checkOne() to return true, it only prints "One Three", as checkTwo() is not checked.

@lovebotter, because I forgot to quote you.

Thomas

2015-05-16 04:40:45

From: adc
You're using "or" there. checkOne() returns false, and thus it checks checkTwo(), which returns true, resulting in all three outputs. In my post, I used "and", which causes it to only output "One", as checkOne() returns false. If you change checkOne() to return true, it only prints "One Three", as checkTwo() is not checked.

@lovebotter, because I forgot to quote you.


Oops, my bad, didn't see the first one to be false :) I assumed you had them both on true!
Thanks :)

masterBB

2015-05-16 05:22:35

In lape you can turn it on or off by putting {$B+} or {$B-} at the top of your script.

Thomas

2015-05-16 05:28:52

From: masterBB
In lape you can turn it on or off by putting {$B+} or {$B-} at the top of your script.



And default is on?
Could save me some resources if I change a few around :) assuming timers are least processing intensive.

tls

2015-05-16 14:13:52

From: lovebotter
And default is on?
Could save me some resources if I change a few around :) assuming timers are least processing intensive.


Why would a timer be process intensive?

Thomas

2015-05-16 14:20:31

From: tls
Why would a timer be process intensive?


They aren't but neither are some other functions.
Was just saying I should then change a few conditionals around based on least intensive, relatively. Mainly timers or small booleans first.