Results 1 to 13 of 13

Thread: Function Compiles and then...nothing?

  1. #1
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Function Compiles and then...nothing?

    Rep Plus for person who figures this out (nobody has yet)

    I have set this up so it should write something no matter what. For some reason, it writes nothing. This function worked fine before I tried to modify it.

    Dont pay attention to the comment stuff, its only partly changed and makes no sense.

    Edit: sorry, forgot the script

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}
    function ColorCheck(Color: Integer; Smart: Boolean): Boolean;
    var
      Dots, W, H, x, y : Integer;
    begin
      Dots := BitmapFromString(17, 15, 'beNpjYPgPAwxEA2pp+W9' +
           'm9o+HB1nkHxjgNASoXkHhDxvbS1T1QPDmzRusWoDmA9V/ZGA4h6oF' +
           'qP7SpUs47GG8ycCwB8yAizx69Ojo0aNIIlh0Ycgy4lVPMmDn5mOgG' +
           'fj3T/jfPz6S1P/5w/T1K8Pdu8RqAaoHordvGc6cId4eRqD5YPUkhS' +
           'RxIQ8AaQdf5g==');
      SetTargetBitmap(Dots);
      GetBitmapSize(Dots, W, H);
      if(FindColorTolerance(x, y, Color, 0, 0, W, H, 10)or(Color=65536))then Result:=False
      else Result:=True;
      FreeBitmap(Dots);
      if(Smart=True)then SetTargetDC(SmartGetDC)
      else ResetDC;
    end;

    function FindGoodPoint(x1, y1, x2, y2: Integer; Smart: Boolean; var Color: Integer):TPoint;  //finds good coords, duh!
    var
      y, x: Integer;
    begin
      y:=y1-1;
      repeat
      begin
        y:=y+1;
        x:=x1;
        repeat
        begin
          x:=x+1;
          Result.x:=x;
          Result.y:=y;
          Color:=GetColor(x, y);
        end;
        until(ColorCheck(GetColor(x, y), Smart)or(x=x2+1));
      end;
      until(ColorCheck(GetColor(x, y), Smart))or((y=y2)and(x=x2+1));
      if((y=y2)and(x=x2+1))then
      begin
        Result.x:=-1;
        Result.y:=-1;
      end;
    end;
    {*******************************************************************************
    function CheckMovement(MinPoints, MaxPoints: Integer): Integer;
    By: Macrosoft
    Description: NumberOfPoints is the amount of referance points
                   you would like the function the use.  The higher
                   this is set, the more accurate, but also the
                   more slow.
          For Result[0]:
                 Returns 0 if stuck.
                 Returns 1 if not moving.
                 Returns 2 if moving.
          For Result[1]:
                 Returns the number of points used.
                 Returns 0 if not enough points were able to be made.
    *******************************************************************************}

    function CheckMovement(MinPoints, MaxPoints: Integer; Smart: Boolean): array of Integer;
    var
      RPoint: array of Tpoint;
      RColor: array of Integer;
      NColor, a, PtsUsed: Integer;
    begin
      SetArrayLength(Result, 2);
      PtsUsed:=MaxPoints;
      SetArrayLength(RPoint, PtsUsed);
      SetArrayLength(RColor, PtsUsed);
      SetArrayLength(NColor, PtsUsed);
      for a:=0 to MaxPoints-1 do
      begin
        RPoint[a]:=FindGoodPoint(570, 33, 683, 135, Smart, RColor[a]);
        if(RPoint[a].x=-1)then
        begin
          PtsUsed:=PtsUsed-1;
          Continue;
        end;
        a:=a+1;
      end;
      if(PtsUsed<MinPoints)then
      begin
        WriteLn('Not enough points were made');
        Result[1]:=0;
        Exit;
      end;
      SetArrayLength(RPoint, PtsUsed);
      SetArrayLength(RColor, PtsUsed);
      SetArrayLength(NColor, PtsUsed);
      Wait(250);
      a:=0-1;
      repeat
      begin
        a:=a+1;
        NColor:=GetColor(RPoint[a].x, RPoint[a].y);
      end;
      until(not(NColor=RColor[a]))or(a=PtsUsed-1);
      if(not(NColor=RColor[a]))then
      begin
        Result[0]:=2;
        WriteLn('We are moving!');
        Result[1]:=PtsUsed;
        WriteLn(IntToStr(PtsUsed)+' out of '+IntToStr(PtsUsed)+' points used');
        Exit;
      end else
      begin
        if(FlagPresent)then
        begin
          WriteLn('We are stuck');
          Result[0]:=0;
        end else
        begin
          WriteLn('We have stopped!');
          Result[0]:=1;
        end;
        Result[1]:=PtsUsed;
        WriteLn(IntToStr(PtsUsed)+' out of '+IntToStr(PtsUsed)+' points used');
      end;
    end;

    {*******************************************************************************
    function WaitForStop(Smart: Boolean): Integer;
    By: Macrosoft
    Description: Waits until the character stops moving.
    NumOfPts is the amount of referance points
        you would like the function the use.  The higher
        this is set, the more accurate, but also the
        more slow.
    Returns 1 if you are caught on something and the flag
      remains while you are still
    Returns 2 if stopped.
    *******************************************************************************}


    function WaitForStop(MinPts, MaxPts: Integer; Smart: Boolean): Integer;
    var
      Strikes, SStrk: Integer;
      i: array of Integer;
    begin
      SStrk:=0;
      Strikes:=0;
      SetArrayLength(i, 2);
      repeat
      begin
        i:=CheckMovement(MinPts, MaxPts, Smart);
        if(i[1]=0)then
        begin
          WriteLn('Error with CheckMovement');
          Result:=0;
        end;
        if(i[0]=1)then Strikes:=Strikes+1 else Strikes:=0;
        if(i[0]=0)then SStrk:=SStrk+1 else SStrk:=0;
      end;
      until(Strikes=2)or(SStrk=2);
      if(SStrk=2)then
      begin
        Writeln('You are caught on something!');
        Result:=1;
        Exit;
      end;
      Writeln('Walked to destination!');
      Result:=2;
    end;

    begin
      SetupSRL;
      CheckMovement(5, 7, False);
    end.

  2. #2
    Join Date
    Jan 2007
    Location
    Illinois.. >.<
    Posts
    1,158
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    No function there?

  3. #3
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    there is now, sry about that, Im tired, can you tell?

  4. #4
    Join Date
    Jan 2007
    Location
    Illinois.. >.<
    Posts
    1,158
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Lol, just a bit.. Which function exactly? I see three.. All of them?

  5. #5
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    well, after many experiments, i think the problem is in CheckMovement

    Rep++ for whoever helps!!!!!!

  6. #6
    Join Date
    Jan 2007
    Location
    Illinois.. >.<
    Posts
    1,158
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Lol, im confuzzled right now.. Explain a little?

  7. #7
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ok, the function is supposed to get the color of points and then check the color again to see if they changed.

  8. #8
    Join Date
    Jan 2007
    Location
    Illinois.. >.<
    Posts
    1,158
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    And they get the color using FindGoodPoint and then getcolor from the TPoint that it returns correct?

  9. #9
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yes
    Im sure there is just some small error that i am not catching.

  10. #10
    Join Date
    Jan 2007
    Location
    Illinois.. >.<
    Posts
    1,158
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    My brain hurts and i still haven't found anything.. I thought at first it had something to do with line 81? The line where you have:
    SCAR Code:
    a := a + 1;
    inside the for to do loop cause im pretty sure that you don't need to add that in a for to do loop, it automatically increases the variable.. I removed that but it was a no go.. I even tried writing a little case statement towards the end..
    SCAR Code:
    case Result[0] of
        0 : Writeln('We are stuck');
        1 : Writeln('We have stopped');
        2 : Writeln('We are moving');
      end;
     
      case Result[1] of
        0 : Writeln('Not enough points were made');
      end;
    But that didnt work either.. So the function isn't returning any values so it seems? That's all i can think of.. But i'll look it over some more later..

  11. #11
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    lol, i spent an hour looking at it and couldn't find anything.
    ill keep looking

    my way is better than a case statement because it exits sooner (faster that way)

  12. #12
    Join Date
    Jan 2007
    Location
    Illinois.. >.<
    Posts
    1,158
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yeah no doubt, i just figured at the end i would put it to check it..

  13. #13
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    does someone else want to try to help me?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Procedure compiles but doesnt do anything
    By impiwimpi in forum OSR Help
    Replies: 3
    Last Post: 02-02-2009, 07:52 AM
  2. Function compiles, But nothing happens?
    By Macrosoft in forum OSR Help
    Replies: 19
    Last Post: 08-14-2008, 12:35 AM
  3. TPA Trouble [Compiles but does nothing]
    By Claymore in forum OSR Help
    Replies: 4
    Last Post: 07-08-2008, 06:00 PM
  4. need help, script compiles right but work?
    By shadowrec0n in forum OSR Help
    Replies: 9
    Last Post: 02-15-2008, 09:09 PM
  5. it compiles but does nothing my script not working
    By ShowerThoughts in forum OSR Help
    Replies: 3
    Last Post: 08-23-2007, 09:01 PM

Posting Permissions

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