Results 1 to 7 of 7

Thread: A little script I am having trouble making :/

  1. #1
    Join Date
    Aug 2010
    Location
    Slovenia
    Posts
    52
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default A little script I am having trouble making :/

    Hi, I am trying to figure out something, but as I am still new to this im having a hard time... :/

    What I wnat to do is to let the script figure out if its on top of a webpage or at the bottom by using some bitmaps so the next procedure would be able to use it.


    Something like this (hope it makes some sense :S):

    Simba Code:
    program New;
      {$i SRL\SRL.scar}

    var
     //Bitmaps    

    procedure LoadBitmaps;
    begin

    end;

    procedure GetPosition(Position : Integer);
    begin
     if(FindBitmap(A, x, y) and FindBitmap(B, x, y))then
       Position := Up;
     if(FindBitmap(C, x, y) and FindBitmap(D, x, y))then
       Position := Down;
      else
       begin
        Writeln('NotFound');
       end;
    end;


    procedure asdf;
    begin
     if(Up)then
       //DoSomething
     if(Down)then
       //DoSomething
      else
       //DoSomething
    end;


    begin
      SetupSRL;
      LoadBitmaps;
      GetPosition;
      asdf;
    end.

    Any help would be greatly apreciated.
    Thank you in advance

  2. #2
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    First of all, position is a parameter, it's given to the procedure, you want it to be a function which takes no parameters and returns a string.

    Read some scar tutorials and learn what I just wrote, than fix your errors.

    After you're done with that, instead of doing "Position := Up;", replace it with "Result := 'Up';"

    As far as I can tell the rest should compile just fine.

  3. #3
    Join Date
    Feb 2009
    Location
    AZ, USA
    Posts
    460
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Will it always be at the very top or bottom?
    Is your account in an old-school random? Help SRL-OSR solve randoms!

  4. #4
    Join Date
    Aug 2010
    Location
    Slovenia
    Posts
    52
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @Ferocity:
    Yah, I was almost certan it had to be a function, but as I didnt realy figure them out I didn't know how to use it properly (Is the only difference between a procedure and a function that a function returnes a result and a procedure doesn't?).

    I'll try fixing it when I come back from school..hell I'm gona try fixing it there lol.. Thanks.

    @Ogre:
    Yah, It should be almost at the very top and the very bottom

  5. #5
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yes, that's the only difference:

    SCAR Code:
    Procedure Blah;
    Begin
     RandomDeclaredVarHere := 5000;
    End;

    SCAR Code:
    Function Blah : RandomVarTypeHere;
    Begin
      Result := 5000;
    End;

    Assuming you used the random declared variable in the first one in place of where you used the result in the second one, they would give the same thing. If you didn't really understand it, I'd be happy to try and help. Kinda bored xP.

    A little example:

    SCAR Code:
    program New;
    Var
      ARandomVariable : Integer; //Declares ARandomVariable as an integer.

    Procedure Blah1;
    Begin
      ARandomVariable := 5000; //Sets ARandomVariable to 5000.
    End;

    Function Blah2 : Integer; //Declares that this Function is going to return an integer.
    Begin
      Result := 5000; //Declares that the result of this Function is now equal to 5000.
    End;

    begin
      Blah1; //Call this to set ARandomVariable.
      Writeln(IntToStr(ARandomVariable)); //Call this to write ARandomVariable to the debug box.
      Writeln(IntToStr(Blah2)); //Calls Blah2, which returns 5000, and writes the result (5000) to the debug box.
    end.
    Last edited by Sandstorm; 10-14-2010 at 02:56 PM.

  6. #6
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I have a question... so the parameter variables are references to the variables, instead of local variables?

  7. #7
    Join Date
    Aug 2010
    Location
    Slovenia
    Posts
    52
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks sandstorm! I'look through the code more coosely when I get home (2 days. Im writing from my phone..) but from what I've seen it looks good, thanks

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
  •