Results 1 to 7 of 7

Thread: My First Script, need some help

  1. #1
    Join Date
    Aug 2006
    Posts
    30
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default My First Script, need some help

    Hi, this is my first script, basically what it does is click a bitmap(Door1) on minimap. It doesn't work, here is the code

    SCAR Code:
    program WalkFally;
    {.include SRL/SRL.scar}
    var
    Door1:integer;

    procedure North;
    begin
    MakeCompass('n');
    Writeln('Made Compass North.')
    end;

    procedure LoadBitmapDoor1;
    begin
      Door1 := BitmapFromString(13, 20, 'beNpjYGisT4eg+AIZXIiBgY' +
           'GgGlKVRaar4kcDqAyIolNU8CBSleFXSTtlQBSToIQVEVQGEUdThqw' +
           'SWRBTGVZET2XIPiUKAABDjPhp');
    end;

    procedure FBitmapDoor1;
    var
    x, y :integer;
    begin
    Writeln('Looking for bitmap...');
    If(findbitmap(Door1, x, y))Then
    Begin
    Writeln('Found bitmap!');
    end;
    end;

    begin
    setupsrl;
    activateClient;
    North;
    LoadBitmapDoor1;
    FBitmapDoor1;
    end.

    but.......if i add this (something random)
    Code:
    Writeln('kjkha')
    between this
    Code:
    If(findbitmap(Door1, x, y))Then
    and this
    Code:
    Begin
    then it works, but it makes completely no sense to me at all...

    and also, when i make it work with the above method, if i add in
    Code:
    Mouse(x, y, 0, 0, true)
    to make it click the bitmap, it doesn't do anything, the mouse just moves to the top-left corner of the client.


    thanks for your time, i really want to know this, its just that its guna bother me until i figure it out and i have been trying to do so for a while now....

  2. #2
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It dosnt find the bitmap!
    Try using something else

  3. #3
    Join Date
    Jan 2007
    Location
    Nomming bits in your RAM
    Posts
    385
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by N1ke! View Post
    It dosnt find the bitmap!
    Try using something else
    Seconded. Try using a DTM to find the door/door colors. I believe there is also an SRL procedure to find+open doors...

    Srl/Core/DoorProfiles.scar.

    There are quite a few door finders/etc. in there.

    Good luck scripting!
    ~Macro

    EDIT:
    Using proper formatting helps a lot while scripting, (In both reading and in writing) so I suggest using it. Basically, it's putting 2 spaces between begins, etc.
    Example:

    SCAR Code:
    procedure TestProcedure;
    var
      RandomInt:Integer; //2 spaces indent.
    begin //Current Indent + 2 after this.
      RandomInt := Random(2);
      case RandomInt of
        0: writeln('0'); //4 space indent in all. 2 for the Begin, and 2 for the case.
        1: writeln('1');
      end; //Go back to the case indent amount for ends.
      if(RandomInt>0)then
      begin
        writeln('99'); //4 space indent.
      end else //end. 2 space indent.
      begin
        writeln('98');
      end;
    end;

    I believe that is how everything is supposed to be spaced. I'm drawing on knowledge a few months old, though. :P

    Indenting is a bit hard to get used to. However, like I said, it makes the code much easier to read and easier to write. I'll space your code for you.

    SCAR Code:
    program WalkFally;
    {.include SRL/SRL.scar}
    var
      Door1:integer;
     
    procedure North;
    begin
      MakeCompass('n');
      Writeln('Made Compass North.')
    end;
     
    procedure LoadBitmapDoor1;
    begin
      Door1 := BitmapFromString(13, 20, 'beNpjYGisT4eg+AIZXIiBgY' +
           'GgGlKVRaar4kcDqAyIolNU8CBSleFXSTtlQBSToIQVEVQGEUdThqw' +
           'SWRBTGVZET2XIPiUKAABDjPhp');
    end;
     
    procedure FBitmapDoor1;
    var
      x, y :integer;
    begin
      Writeln('Looking for bitmap...');
      If(findbitmap(Door1, x, y))Then
      Begin
        Writeln('Found bitmap!');
      end;
    end;
     
    begin
      setupsrl;
      activateClient;
      North;
      LoadBitmapDoor1;
      FBitmapDoor1;
    end.

    There you go. Enjoy.
    Current Project: Catching up. XD. Potentially back for the summer, depending on how things go.

  4. #4
    Join Date
    Jul 2007
    Posts
    1,431
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    procedure FBitmapDoor1;
    var
      x, y :integer;
    begin
      Writeln('Looking for bitmap...');
      If(findbitmap(Door1, x, y))Then -------\
      writeln('ghfg');                    <--------- it writes ghfg only when it find bitmap
      Begin // it enters here either it found the bmp or not.. if findbmp then .. covers only writeln command
        Writeln('Found bitmap!');
        mouse(x,y,0,0); //it doesn't click there because x and y was not set, it clicks at 0, 0(up-left corner) , right?..(it hasn't anything to do with 0,0 after x,y - 0,0 are randomness.
      end;
    end;

    and yeah, use dtms and read more tuts...try reading only from trustworthy sources.. lot of fools are writing tuts w/o knowing anything..
    [CENTER][SIZE="4"]Inactive[/SIZE]I forgot my password[/CENTER]

  5. #5
    Join Date
    Aug 2006
    Posts
    30
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thanks everyone, yes i will put proper indentation from now. i m guna read some tuts on DTMs
    just 1 last thing, this is the script that does not work:
    SCAR Code:
    program WalkFally;
    {.include SRL/SRL.scar}
    var
      Door1:integer;

    procedure North;
    begin
      MakeCompass('n');
      Writeln('Made Compass North.')
    end;

    procedure LoadBitmapDoor1;
    begin
      Door1 := BitmapFromString(38, 21, 'beNrNlEsKAkEMRPtO3smNuPA' +
           'eLhTcCYJ4UQMNRVHJ1ET84FAM/X+dUOkxHpeD0e209/Lbs8ZwxPt5' +
           '39EHiR3ol2IUdO6+SSyP9WH20UHkvdvNYIUxVnHTP80rhUCE98Bi8' +
           'YLcLSU4jAdRVk7i9biDMBVtSQIvy7PIUkBxDoiyqyRy+BnKXcHFH8' +
           'tmVhm6RMR4mRDZNafYTv9AXMqqd9QScY5wvTRjzIcbm+W2IXKY5W1' +
           'Xs5q9Km8CE1Ge4v+S2PEqipGfGiRNYswFVVL69djxaha/AJJV77cY' +
           'mQkUose9RDQFwkTPWiWK5XLO5W6e2I+xr/H77wkjBymq');
    end;

    procedure FBitmapDoor1;
    var
      x, y :integer;
    begin
      Writeln('Looking for bitmap...');
      If(findbitmap(Door1, x, y))Then
      Begin
        Writeln('Found bitmap!');
      end;
    end;

    begin
      setupsrl;
      activateClient;
      North;
      LoadBitmapDoor1;
      FBitmapDoor1;
    end.


    but this one works, after i add in something random between then and begin in procedure FBitmapDoor1:

    SCAR Code:
    program WalkFally;
    {.include SRL/SRL.scar}
    var
      Door1:integer;

    procedure North;
    begin
      MakeCompass('n');
      Writeln('Made Compass North.')
    end;

    procedure LoadBitmapDoor1;
    begin
      Door1 := BitmapFromString(38, 21, 'beNrNlEsKAkEMRPtO3smNuPA' +
           'eLhTcCYJ4UQMNRVHJ1ET84FAM/X+dUOkxHpeD0e209/Lbs8ZwxPt5' +
           '39EHiR3ol2IUdO6+SSyP9WH20UHkvdvNYIUxVnHTP80rhUCE98Bi8' +
           'YLcLSU4jAdRVk7i9biDMBVtSQIvy7PIUkBxDoiyqyRy+BnKXcHFH8' +
           'tmVhm6RMR4mRDZNafYTv9AXMqqd9QScY5wvTRjzIcbm+W2IXKY5W1' +
           'Xs5q9Km8CE1Ge4v+S2PEqipGfGiRNYswFVVL69djxaha/AJJV77cY' +
           'mQkUose9RDQFwkTPWiWK5XLO5W6e2I+xr/H77wkjBymq');
    end;

    procedure FBitmapDoor1;
    var
      x, y :integer;
    begin
      Writeln('Looking for bitmap...');
      If(findbitmap(Door1, x, y))Then
      writeln('sd'); //<-------this is what i added in to make it work. just something random.
      Begin
        Writeln('Found bitmap!');
      end;
    end;

    begin
      setupsrl;
      activateClient;
      North;
      LoadBitmapDoor1;
      FBitmapDoor1;
    end.

    why is that?

  6. #6
    Join Date
    Jan 2007
    Location
    Nomming bits in your RAM
    Posts
    385
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    By work, you mean it writes 'Found Bitmap!'? If so, then that doesn't mean it 'worked'.

    SCAR Code:
    If(findbitmap(Door1, x, y))Then
      writeln('sd'); //THIS is what happens if it finds the bitmap.
      Begin
        Writeln('Found bitmap!');//The script does this regardless of if it finds the bitmap.
      end;

    Commented.

    You see, if 'if -> then' statements are only told to do one thing, then they don't need the begin/end. For example...
    SCAR Code:
    procedure HeyLookAProcedure;
    begin
      if(1>0)then
        writeln('Math does work O_O');
    end;
    and
    SCAR Code:
    procedure HeyLookAProcedure;
    begin
      if(1>0)then
      begin
        writeln('Math does work O_O');
      end;
    end;

    Work exactly the same. However,

    SCAR Code:
    procedure HeyLookAProcedure;
    begin
      if(1>0)then
      begin
        writeln('Math does work O_O');
        writeln('It''s a Miracle!!!!!!!!!!');
      end;
    end;
    Does everything in the begin+end, as it is supposed to, if 1>0, but...
    SCAR Code:
    procedure HeyLookAProcedure;
    begin
      if(1<0)then
        writeln('Math does work O_O');
      writeln('It''s a miracle!!!!!!!!!!');
    end;
    Does the second writeln (The It's A Miracle!!!... one), even though the condition is false. This is because, without a begin and end (after if/then), it only pays attention to the line afterwards (and the else after that, if applicable).

    ~Macro
    Current Project: Catching up. XD. Potentially back for the summer, depending on how things go.

  7. #7
    Join Date
    Aug 2006
    Posts
    30
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    OOOOOOOOOOOOOOOOOOHHHHHHHHHHHHHHHHHHHHH dam

    i would have never known that lol, i thought it doesnt matter if you put a begin/end !!!
    thanks once again i rep you

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •