Results 1 to 15 of 15

Thread: whats wrong with me 'if' statements?

  1. #1
    Join Date
    May 2008
    Location
    the world 0_o
    Posts
    150
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default whats wrong with me 'if' statements?

    What is wrong with my if statements?


    Simba Code:
    begin
     repeat
       if (not(MinethatOtherjoint)); and
             (not(Minethatjoint));   then
       Writeln('Couldnt find that purp lls');
       until InvFull;
    end.

  2. #2
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Your semi-colons..
    I am Ggzz..
    Hackintosher

  3. #3
    Join Date
    May 2008
    Location
    the world 0_o
    Posts
    150
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i put them inside and now it gives me a parenthesis error... btw if hows ur itemfinding function coming along? i want to do a waterfiends bot but with cockroach soldiers lol

  4. #4
    Join Date
    Nov 2011
    Location
    Jozi, South Africa
    Posts
    249
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by lordofballss View Post
    What is wrong with my if statements?
    Change this ...

    Simba Code:
    begin
     repeat
       if (not(MinethatOtherjoint)); and
             (not(Minethatjoint));   then
       Writeln('Couldnt find that purp lls');
       until InvFull;
    end.

    ... to this

    Simba Code:
    begin
     repeat
       if (not MinethatOtherjoint) and (not Minethatjoint) then
         Writeln('Couldnt find that purp lls');
     until InvFull
    end.
    Ciao
    NM

  5. #5
    Join Date
    May 2008
    Location
    the world 0_o
    Posts
    150
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thanks! im getting a type mismatch error though..Imma see if i can figure it out myself

  6. #6
    Join Date
    Feb 2011
    Location
    Earth
    Posts
    1,784
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    your probably trying to use a procedure as a function

    Currently: Working on Defending&Attacking in my Castle-Wars Script
    Project Rebuild: 90M/170M

  7. #7
    Join Date
    Nov 2011
    Location
    Jozi, South Africa
    Posts
    249
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Post your code
    Ciao
    NM

  8. #8
    Join Date
    Dec 2011
    Location
    Nj
    Posts
    2,341
    Mentioned
    1 Post(s)
    Quoted
    18 Post(s)

    Default


    For the basics of the basics of pascal, try my TuT. ||Photoshop Editing ||MapleResourceDung Script || Book a flight! BuySellTrip

  9. #9
    Join Date
    May 2008
    Location
    the world 0_o
    Posts
    150
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    here it is....

    Simba Code:
    program Script;
    {$DEFINE SMART}
    {$i SRL\SRL.simba}
    {$i ObjectDTM\ObjDTMInclude.simba}

    procedure DeclarePlayers;
    begin

      HowManyPlayers := 1;
      CurrentPlayer := 0;
      SetLength(Players, HowManyPlayers);

      Players[0].Name := '';
      Players[0].Pass := '';
      Players[0].Nick := '';
      Players[0].Member := True;
      Players[0].Active := True;
      Players[0].Pin := '';
    end;



    procedure Minethatjoint;       //Mines right rock
    var
      MyTPA : TPointArray;
      MyPoint : TPoint;
      x, y, i : Integer;

    begin
      FindColorsTolerance(MyTPA, 9209708, 388, 142, 424, 175, 10);
      if Length(MyTPA) = 0 then FindColorsTolerance(MyTPA, 11446662, MSX1, MSY1, MSX2, MSY2, 10);
      for i := 0 to High(MyTPA)do
      begin
        MyPoint := MyTPA[i]
        MMouse (MyPoint.x, MyPoint.y, 3, 3);
        if (IsUpTextMultiCustom(['ine'])) then
        begin
          GetMousePos(x, y);
          Mouse(x, y, 0, 0, 1);
          Wait(500+random(250));
          Exit;
        end;
      Wait(350+random(350));
      end;
    end;


    procedure MinethatOtherjoint;      //Mines left rock
    var
      MyTPA : TPointArray;
      MyPoint : TPoint;
      x, y, i : Integer;

    begin
      FindColorsTolerance(MyTPA, 15327132, 248, 201, 274, 227, 10);
        if Length(MyTPA) = 0 then
           FindColorsTolerance(MyTPA, 9801842, 248, 201, 274, 227, 10);
      for i := 0 to High(MyTPA)do
      begin
        MyPoint := MyTPA[i]
        MMouse (MyPoint.x, MyPoint.y, 3, 3);
        if (IsUpTextMultiCustom(['ine'])) then
        begin
          GetMousePos(x, y);
          Mouse(x, y, 0, 0, 1);
          Wait(500+random(250));
          Exit;
        end;
      Wait(350+random(350));
      end;
    end;



    begin

      Smart_Server := 10;
      Smart_Members := True;
      Smart_Signed := True;
      SetupSRL;
      //ObjDTM_Setup;
      DeclarePlayers;
    begin
     repeat
       if (not MinethatOtherjoint) and (not Minethatjoint) then
         Writeln('Couldnt find that purp lls');
     until InvFull;
    end;
    end.

  10. #10
    Join Date
    Nov 2011
    Location
    Jozi, South Africa
    Posts
    249
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Thumbs up

    This is the error you get ...

    [Error] (86:56): Type mismatch at line 85
    Compiling failed.
    What this means is that you have coded one variable type and then try to use it as another ie trying to use a boolean as an integer. PatDuffy actually gave you the answer a few posts back, and so did joeygupta.

    You need to change these two procedures to functions that return a boolean.

    This ...
    Simba Code:
    procedure Minethatjoint;
    procedure MinethatOtherjoint;

    ... to this!
    Simba Code:
    function Minethatjoint:boolean;
    function MinethatOtherjoint:boolean;

    Also in each function you need to set 'Result' to either true or false. 'Result' allocates if you will the answer of true or false to the name of the function. So that when you use this piece of code (below) - it will then work for you.

    See the trivial function code below to illustrate ...

    Simba Code:
    function EqualsOne:boolean;
    var
       x:Integer;
    begin
      if x = 1 then
         Result := True
      else
         Result := False
    end;

    Then a statement like this will have meaning and be correct ...

    Simba Code:
    ... other code ...

    if EqualsOne then                // ie If EqualsOne is true then do.
       ...
    else
       ...
    end;
    Last edited by NickMystre; 01-31-2012 at 01:00 PM.
    Ciao
    NM

  11. #11
    Join Date
    Dec 2011
    Location
    Nj
    Posts
    2,341
    Mentioned
    1 Post(s)
    Quoted
    18 Post(s)

    Default

    Quote Originally Posted by NickMystre View Post
    This is the error you get ...



    What this means is that you have coded one variable type and then try to use it as another ie trying to use a boolean as an integer. PatDuffy actually gave you the answer a few posts back, and so did joeygupta.

    You need to change these two procedures to functions that return a boolean.

    This ...
    Simba Code:
    procedure Minethatjoint;
    procedure MinethatOtherjoint;

    ... to this!
    Simba Code:
    function Minethatjoint:boolean;
    function MinethatOtherjoint:boolean;

    Also in each function you need to set 'Result' to either true or false. 'Result' allocates if you will the answer of true or false to the name of the function. So that when you use this piece of code (below) - it will then work for you.

    See the trivial function code below to illustrate ...

    Simba Code:
    function EqualsOne:boolean;
    var
       x:Integer;
    begin
      if x = 1 then
         Result := True
      else
         Result := False
    end;

    Then a statement like this will have meaning and be correct ...

    Simba Code:
    ... other code ...

    if EqualsOne then                // ie If EqualsOne is true then do.
       ...
    else
       ...
    end;
    Thank You NickMystre, I did not have time to write a complete reply, (My Birthday party!), so I only gave a link.

    For the basics of the basics of pascal, try my TuT. ||Photoshop Editing ||MapleResourceDung Script || Book a flight! BuySellTrip

  12. #12
    Join Date
    May 2008
    Location
    the world 0_o
    Posts
    150
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thanks guys! i sort of understand now. happy belated birthday joeygupta! ima test it and see how it works out thanks again!

  13. #13
    Join Date
    Nov 2011
    Location
    Jozi, South Africa
    Posts
    249
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Smile

    Quote Originally Posted by joeygupta View Post
    Thank You NickMystre, I did not have time to write a complete reply, (My Birthday party!), so I only gave a link.
    No worries. I hope that you had a ripper of a party.
    Ciao
    NM

  14. #14
    Join Date
    Dec 2011
    Location
    Nj
    Posts
    2,341
    Mentioned
    1 Post(s)
    Quoted
    18 Post(s)

    Default

    Quote Originally Posted by lordofballss View Post
    thanks guys! i sort of understand now. happy belated birthday joeygupta! ima test it and see how it works out thanks again!
    Thx Yo.



    Quote Originally Posted by NickMystre View Post
    No worries. I hope that you had a ripper of a party.
    Thank you as well!

    For the basics of the basics of pascal, try my TuT. ||Photoshop Editing ||MapleResourceDung Script || Book a flight! BuySellTrip

  15. #15
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Instead of doing:

    If X = 1 then
    Result....

    Do:

    Result:= (X = 1);

    Much cleaner.
    I am Ggzz..
    Hackintosher

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
  •