SRL Archive - OSR Help

Boolean help


alw98

2013-06-17 11:31:33

Alright, I know this is a stupid question, but for the life of me I cannot figure out how to set a boolean to true or false. Help!

rj

2013-06-17 11:42:07

varhere:= true
varhere := false

Kevin

2013-06-17 11:44:15

From: alw98
Alright, I know this is a stupid question, but for the life of me I cannot figure out how to set a boolean to true or false. Help!



function booleanReturn: boolean;
begin
if(somethingHappened)then
Result:= True;//defaults to false all the time, so no need to set to false.
end;

alw98

2013-06-17 12:11:53

I can not get this to work.
This is a snippet of the code:
procedure Startup;
begin;
if loot:=0 then
waitt:= true
end;
procedure StealSilk;
var
x, y, w, h: integer;
begin
GetClientDimensions(w, h);
if FindColor(x, y, COLOR, 0, 0, w-1, h-1)then
colorpresent:=true
if waitt:=true
begin
loot := (loot + 1);
Mouse(x, y, 0, 0, True);
Writeln('Silk Found!');
waitt:=false
wait until;
colorpresent:=false then
waitt:=true
end else
wait(100);
end;

Kevin

2013-06-17 12:23:56

First of all, code looks nicer in [simba[ tags than in quote tags - and formatting helps a ton in reading! :)


procedure Startup;
begin//no semicolon after a begin
if (loot=0) then//If checks are if(var=something). Use '=' and not ':=' in if
waitt:= true;//This should have a semicolon, and where are loot and waitt declared?
end;

procedure StealSilk;
var
x, y, w, h: integer;
begin
GetClientDimensions(w, h);//I'm assuming this is for a RSPS and not base runescape, otherwise there are better and simpler ways to solve this portion.
if FindColor(x, y, COLOR, 0, 0, w-1, h-1)then
colorpresent:=true//Where is this declared?
if (waitt=true)
begin
loot := (loot + 1);
Mouse(x, y, 0, 0, True);
Writeln('Silk Found!');
waitt:=false
wait until;//What are you trying to wait for? this is gonna break since you don't have anything. I'll write something in the next code section for an example.
colorpresent:=false then//You can't use then without an if. Idk your goal here.
waitt:=true
end else
wait(100);
end;


procedure waitTillNotMoving;
var
ttime: integer;
begin
MarkTime(ttime);
repeat
wait(randomRange(50,100));
until((not IsMoving) or (TimeFromMark(ttime) > 5000));//IsMoving is a boolean that says whether you're currently moving in RS. The time from mark makes sure we don't wait more than 5 seconds as a failsafe if ismoving doesn't ever say false. ALWAYS include failsafes.
end;

alw98

2013-06-17 12:35:58

I have all the variables declared as globals, and that end part is because I am stealing from a stall. It is a check to see that after clicking, the variable becomes false so it wont click again. Once the color on the stall goes away, the boolean becomes true and it starts over again. Edited code:
program SilkStealer;
{$i srl\srl.simba}
const
COLOR = 000; //replace 000 with the numbers you get for each stall.
AMOUNT = 000; //replace 000 with the amount gained from when you steal from the stall
var
loot, money :Integer;
waitt, colorpresent :Boolean;
procedure Startup; //***********From Here
begin//no semicolon after a begin
if (loot=0) then//If checks are if(var=something). Use '=' and not ':=' in if
waitt:= true;//This should have a semicolon, and where are loot and waitt declared?
end;

procedure StealSilk;
var
x, y, w, h: integer;
begin
GetClientDimensions(w, h);//I'm assuming this is for a RSPS and not base runescape, otherwise there are better and simpler ways to solve this portion.
if FindColor(x, y, COLOR, 0, 0, w-1, h-1)then
if (waitt=true)
begin
loot := (loot + 1);
Mouse(x, y, 0, 0, True);
Writeln('Silk Found!');
waitt:=false;
repeat
if FindColor(x, y, COLOR, 0, 0, w-1, h-1)then
colorpresent:= true; //You can't use then without an if. Idk your goal here.
else
colorpresent:= false;
until (not colorpresent);
waitt:=true;
end else
wait(100);
end;//************* To Here
procedure Proggy;
begin
Writeln('');
Writeln('********************************');
Writeln('Thanks for using my script!');
Writeln('We have stolen: ' + IntToStr(loot) + ' loot');
Writeln('We have stolen: ' + IntToStr(money) + ' money');
Writeln('********************************');
Writeln('Much credit to abu_jwka for helping me script most of it!')
Writeln('');
end;
begin
ClearDebug;
SetUpSRL;
AddOnTerminate('Proggy');
repeat
ClearDebug;
StealSilk;
money := (loot * AMOUNT);
until (IsKeyDown(114)); //pres F3 to stop and continue to Proggie!
end.

That's the whole thing there. It works now except for it doesnt find the color anymore.

Kevin

2013-06-17 12:58:20

If Color is still 000, then it probably won't ever find it. Also, since this is official RS (I think?) you can instead do this for your finds and you won't need the GetClientDimensions anymore:
 if FindColor(x, y, COLOR, MSX1, MSY1, MSX2, MSY2)then//this will even limit it to the main screen so you don't search the minimap or inventory or chat bars.

alw98

2013-06-17 13:02:03

Nah its for a RSPS. Anyways, i figured it out! First off- 000 is a shade of black, which just so happens to be one of the one for simba fonts.
Second- It wasnt working because startup wasnt in my main loop. Time to try it out!

Valithor

2013-06-17 13:17:55

I'm not a member, but here's a few tips I've got for you.
The code that you currently posted won't even compile. Here's the corrections that I made to your "StealStall" procedure:

procedure StealSilk;
var
x, y, w, h: integer;
begin
GetClientDimensions(w, h);
if FindColor(x, y, COLOR, 0, 0, w - 1, h - 1) then
if waitT then
begin
loot := (loot + 1);
Mouse(x, y, 0, 0, True);
Writeln('Silk Found!');
waitt := false;
repeat
if FindColor(x, y, COLOR, 0, 0, w - 1, h - 1) then
begin
colorpresent := true;
end else
colorpresent := false;
until (not colorpresent);
waitt := true;
end
else
wait(100);
end;

Also, keep in mind that you never call your "Starup" prodecure anywhere. Perhaps try using another color finding method such as
"FindColorSpiralTolerance()". The tolerance will help in color finding. Just a few thoughts.