SRL Archive - Simba (Testing) Scripts

Need some input on my function


BraK

2010-06-10 14:37:02

I'm just getting started back scripting and I'm Making my new Fletcher.This is one of the funtions I made for it. I tested it and it works fine. Wondering what everyone else would think of it. Praise it, flame it, or criticize it. It does not matter any input would be appreciated. :)



program testxbank;
{$i srl/srl.scar}

Var
Brakdebug:boolean;

procedure Setupcwars;
Begin
Setupsrl;
brakdebug:=true;
end;

function Findbitmapquad( bitmap:integer; var x:integer; var y:integer; quad:integer): boolean;
//has 5 areas top left, top right, bottom left, bottom right, and center.

var
xs,xe,ys,ye,w,h:integer;
Begin
getclientdimensions(w,h)
case (Quad) of
1:begin xs:=2; xe:=(w/2); ys:=2; ye:=(h/2); end; //top left quadrant
2:begin xs:=(w/2); xe:=(w-2); ys:=2; ye:=(h/2); end; //top right quadrant
3:begin xs:=2; xe:=(w/2); ys:=(h/2); ye:=(h-2); end; //bottom left quadrant
4:begin xs:=(w/2); xe:=(w-2); ys:=(h/2); ye:=(h-2); end; //bottom right
5:begin xs:=(w/4); xe:=(w/4*3); ys:=(h/4); ye:=(h/4*3); end; //center square
End;
result:=FindBitmapin(bitmap,x,y,xs,ys,xe,ye)
end;

function xbank:boolean; //closes the bank using [x] button

var
Xbankbmp,x,y:integer;
begin
brakdebug:=True; // not gonna be part of script
xbankbmp:= BitmapFromString(16, 6, 'meJxT0jLMbu6NzK2MLqwRFpUAIkF' +
'h0YCUvMC0QggXiDyiU13DEsw9/Lm4uJS0DHNbJ4VkFgORb1IWRIGo' +
'hAwcARU7BkcDkYmLF1x9TFED0EygeiASk1WCI6CxbhFJUPX2HnD1Q' +
'PcAVQK1AJGsipaUoiqQBCKg4RDHIJsPcT/EfKAaBTVdOAJyIYqByM' +
'jRHc18iBpFTT2gGiACMiAIqNjePwJiPgB0HEdm');
result:=FindBitmapquad(xbankbmp,x,y,2)
Begin
If (result) then
begin
Mouse(x,y,5,5,true);
if brakdebug then
writeln('>>Close Bank function works<<') // will be part of script
end else
writeln('>>Closebank Failed<<')
End;
freebitmap(xbankbmp);
end;

begin
setupcwars;
if xbank then
Writeln('Woot');
end.


Edit:Added scar tags. Just so everyone is on the same page. I don't use Fixed size windows so I don't use hard locations.

Edit2: Added Extra piece to only search a specific section of the screen for the bitmap.

Edit3: Made new funtion so that quadrant could be used on multiple procedures/functions. Moved debug into function.

EvilChicken!

2010-06-10 14:43:47

Looks allright :)
What's wrong with SRL's banking procedures, though?

And, please use
 tags when posting code, it makes it [I]so[/I] much more readable.

Ogre

2010-06-10 14:51:22

This would be much more effective if you only searched in the area that the button is in, also is the mouse randomness too much to click off of it? Another thing, you don't have to get the bitmap of the whole button, just searching for the bmp of part of it would work as well.

Also, just in case you didn't know, SRL has a CloseBank function you can use. Although I know you're just getting back into scripting so you're probably making stuff like this to practice.

BraK

2010-06-10 14:53:31

I couldn't get closebank to work in castle wars. Castle wars is gonna be a big part of one of my next projects. So I have to make a castle wars bank function too. It's going to be fun. That is just a piece of the button. Editted for scar tags.

Ogre

2010-06-10 14:55:39

If the bank is slightly different, you might want to check out the CloseBank function in SRL and try to base yours off of that, as it's probably doing it the most effective way.

noidea

2010-06-10 14:55:55

Also, there is no need for that begin after your bitmap ;)

BraK

2010-06-10 15:04:58

From: noidea
Also, there is no need for that begin after your bitmap ;)


I couldn't get it to compile in simba without it.

Edit:@noidea: Nevermind I had a syntax error with it removed but I got it fixed.

lordsaturn

2010-06-11 14:32:40

A simple GetColor would do nicely. Or if you are positive that the BankScreen is open you can just Mouse(212, 90) or whatever the coord is because the X to close the BankScreen will be in the same spot every time.

if (GetColor(x, y) = STATIC_COLOR) or BankScreen then
Mouse(483, 28, 1, 3, True);
Check out Bank.scar in the core folder of SRL.

BraK

2010-06-11 15:09:01

From: lordsaturn
A simple GetColor would do nicely. Or if you are positive that the BankScreen is open you can just Mouse(212, 90) or whatever the coord is because the X to close the BankScreen will be in the same spot every time.

if (GetColor(x, y) = STATIC_COLOR) or BankScreen then
Mouse(483, 28, 1, 3, True);
Check out Bank.scar in the core folder of SRL.


I'm not using smart or reflection or a standard screensize. When i get smart to work for win 7 x64 i'll start scripting in it…maybe.:) It's still new to me as I didn't know it existed til i came back a few days ago.

MylesMadness

2010-06-11 15:13:08

Why would you auto in resized? You could just use srl on fixed and not have to write a lot of this.

Frement

2010-06-11 15:15:29

From: MylesMadness
Why would you auto in resized? You could just use srl on fixed and not have to write a lot of this.


Maybe he thinks he has better chances of not getting banned when "playing" like everyone else? :) I've thought of that too, but I dont care that much. I have never been banned from autoing.

BraK

2010-06-11 15:18:06

From: Frement
Maybe he thinks he has better chances of not getting banned when "playing" like everyone else? :) I've thought of that too, but I dont care that much. I have never been banned from autoing.


Meh I gives me some challenges to get back into coding. You can't let your skills rust after all. Mine are pretty rusted too. :sasmokin:

Edit: I'll start scripting in fixed for a bit.

Tim0suprem0

2010-06-12 00:22:53

From: BraK
Meh I gives me some challenges to get back into coding. You can't let your skills rust after all. Mine are pretty rusted too. :sasmokin:

Edit: I'll start scripting in fixed for a bit.


/offtopic dude back from Iraq???

BraK

2010-06-12 15:16:44

From: Tim0suprem0
/offtopic dude back from Iraq???


Yes just got back from second tour.

noidea

2010-06-13 00:44:29

Sorry I missed you on the irc mate.

[18:03:54] <Brak> do you know of a way to load DTMs from case of
[18:27:57] <Brak> nvm

if you never found out, it'd be like:

var thedtm: integer;
begin
case thing of
1: thedtm := dtmcreation();
2: thedtm := dtmcreation();
end;
end;

BraK

2010-06-14 08:48:51

I got some good guidance from you guys. Thanks NoIdea, Ogre, and Wizzup for all the help. Funny thing is that after bouncing idea's around, and being inspired by everyone my script looks nothing like it did before. Although I'm more determined to get the bank procedures down for the place I'm banking at.