Results 1 to 12 of 12

Thread: Making a case to set a procedure..?

  1. #1
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Making a case to set a procedure..?

    I'm wondering how i would go about doing this:

    SCAR Code:
    if (RockType = 1) then
    AlignToCopperRocks;
    if(RockType = 2) then
    AlignToTinRocks;
    if(RockType = 3) then
    AlignToIronRocks;
    if(RockType = 4) then
    AlignToGoldRocks;

    but as a case. i tried:

    SCAR Code:
    case RockType of
        1: AlignToRocks := AlignToCopperRocks;
        2: AlignToRocks := AlignToTinRocks;
        3: AlignToRocks := AlignToIronRocks;
        4: AlignToRocks := AlignToGoldRocks;
      end;
    but then i had to identify AlignToRocks as something, i tried string and it didn't work (which i thought would happen). So i'm kinda out of ideas.

    I'm planning on doing

    SCAR Code:
    procedure Alignment;
    begin
      AlignToCenter;
      AlignToRocks;
    end;

    So the idea is i want AlignToRocks to change to one of the other Align procedures, depending on what the user set Rocktype to equal.

  2. #2
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    case RockType of
        1: AlignToCopperRocks;
        2: AlignToTinRocks;
        3: AlignToIronRocks;
        4: AlignToGoldRocks;
      end;

    Like this?
    Interested in C# and Electrical Engineering? This might interest you.

  3. #3
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I tried that too, but..hold on, i don't remember what happened, lemme try it again

    Edit: If i were to do that, then how would i do

    SCAR Code:
    procedure Alignment;
    begin
      AlignToCenter;
      AlignToRocks;
    end;

    Since that would make AlignToRocks not used at all..In otherwords, what do i call instead of AlignToRocks then?

  4. #4
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    That's a quite hard question to answer if I don't have the script infront of me

    Wanna post it? If not, you could PM it to me
    Interested in C# and Electrical Engineering? This might interest you.

  5. #5
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Its just a part of it, so it's fine.

    SCAR Code:
    procedure AlignToIronRocks;
    begin
      if (FindDeformed(x,y,MMIronRocks,MMX1,MMY1,MMX2,MMY2)) then
      begin
        Mouse(x,y,2,2,true);
        Status('Found iron rocks on minimap.');
        FFlag(4);
      end else
      begin
        Status('Did not find iron rocks on minimap.');
        Writeln('Did not find iron rocks on minimap. Account is lost.');
        LogOut;
        NextPlayer(False);
      end;
    end;

    basically it's that, but written four times, each time changing the rock. Meaning one is AlignToIronRocks, another is AlignToCopperRocks, and so on. Before that i have it use the mining symbol to get near enough to the center (even though it moves around) so that the entire mine should be on the minimap. From there i want it to do the AlignTo___Rocks, depending on which one the user wants, which would be determined by RockType. I don't know if that helps explain it at all..?

    The idea being that this would be the end of the walking procedure to get it back to the mines. That it would get to the middle of the mine, then get to the correct rocks, and then begin the mining part until full.

  6. #6
    Join Date
    May 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You could use a begin and end in a case, does that answer your question?
    ex:
    SCAR Code:
    case (RockType) of
      1: begin
            DoThis;
            ThenThis;
          end;
      2: This2;
      3: MeThree;
    end;

  7. #7
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Actually, i think that does.. Something like this then?

    SCAR Code:
    procedure AlignToRocks;
    begin
      case RockType of
        1: begin
              AlignToCopperRocks;
            end;
        2: begin
              AlignToTinRocks;
            end;
        3: begin
              AlignToIronRocks;
            end;
        4: begin
              AlignToGoldRocks;
            end;
      end;
    end;

    procedure Alignment;
    begin
      AlignToCenter;
      AlignToRocks;
    end;

  8. #8
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Well yes you COULD do that, but it wouldn't help.

  9. #9
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yeah..i knida had that feeling when looking over it..So then would this be right..?

    SCAR Code:
    procedure AlignToRocks;
    begin
      case RockType of
        1: AlignToCopperRocks;
        2: AlignToTinRocks;
        3: AlignToIronRocks;
        4: AlignToGoldRocks;
      end;
    end;

    procedure Alignment;
    begin
      AlignToCenter;
      AlignToRocks;
    end;

    I'll try running that and see what happens..

  10. #10
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Ohhh I see...

    If RockType is a String, you would do this:

    SCAR Code:
    case RockType of
        'Copper': AlignToCopperRocks;
        'Tin': AlignToTinRocks;
        'Iron': AlignToIronRocks;
        'Gold': AlignToGoldRocks;
      end;
    Interested in C# and Electrical Engineering? This might interest you.

  11. #11
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I set it as an integer, and put instructions as so:

    SCAR Code:
    RockType = 1; //1=Copper 2=Tin 3=Iron 4=Gold

    but anyway, I got it to work with.

    SCAR Code:
    procedure AlignToRocks;
    begin
      case RockType of
        1: AlignToCopperRocks;
        2: AlignToTinRocks;
        3: AlignToIronRocks;
        4: AlignToGoldRocks;
      end;
    end;

    procedure Alignment;
    begin
      AlignToCenter;
      AlignToRocks;
    end;

    I'm having a slight problem though, some of the bitmaps used in FindDeformed are larger than the others, and by the time it finds the rocks on the minimap, RS times out, or already timed out. Is there any way i could make it click something such as switch gametabs between searches so that it stays logged in? If i understand correctly, find deformed searches repeatedly each time lowering the tolerance, so if i could make it change gametabs between each search, i'd stay logged in, right?

    It's my understanding that i'd have to alter the FindDeformed function manually, and then put the altered version in my script though. I tried doing that, and it said it couldn't find the bitmap after one or two tries i think though, any help..?

    Also, thanks to everyone who's helped out so far

    Edit: Or should i drop the FindDeformed completely and use something else? Could i use a DTM for the minimap or something..? And if i did, would it work even if there were white dots (other players) standing between the rocks or something..?

  12. #12
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Okay, i changed some stuff around. Now it looks like this.

    SCAR Code:
    procedure AlignToTinRocks;
    begin
      Status('Looking for tin rocks on minimap..');
      if (FindDTM(MMTinDTM,x,y,MMX1,MMY1,MMX2,MMY2)) then
      begin
        Mouse(x,y,2,2,true);
        Status('Found tin rocks on minimap.');
        FFlag(0);
      end else
      begin
        Status('Did not find tin rocks on minimap on first try. Trying again.');
        repeat
          Wait(1000+random(500));
          Searches := Searches + 1;
        until (FindDTM(MMTinDTM,x,y,MMX1,MMY1,MMX2,MMY2)) or (Searches = 5)
        if (Searches = 5) then
        begin
          Status('Tried five times. Attempting FindDeformed. Expect lag..');
          if (FindDeformed(x,y,MMTinRocks,MMX1,MMY1,MMX2,MMY2)) then
          begin
            Status('Found tin rocks on minimap!');
            Mouse(x,y,2,2,true);
            FFlag(0);
          end else
          begin
            Status('Did not find tin rocks on minimap.');
            Writeln('Did not find tin rocks on minimap. Account is lost.');
            LogOut;
            NextPlayer(False);
          end;
        end;
      end;
    end;

    So, now it'll try the DTM a couple times and then use FindDeformed as a last resort. I could still use some help though. If i could alter FindDeformed to switch gametabs between each of it's searches, then RS wouldn't time out while it searched. But, when i tried doing that myself it screwed the whole thing up. Could anyone help me here?

    Edit: This is what i was thinking:

    SCAR Code:
    function FindDeformedNew(var Xoff, Yoff: Integer; BMP, a, b, c, d: Integer):
      Boolean;
    var
      acc, ref: Extended;
      XT, YT, times, tol: Integer;
    begin
      ref := 0.9;
      tol := 0;
      for times := 1 to 50 do
      GameTab(2); //Switches to Skills
      GameTab(4); //Switches to Inventory
      Wait(1000+random(100)); //Waits a bit
      begin
        FindDeformedBitmapToleranceIn(BMP, XT, YT, a, b, c, d, tol, 2, True, acc);
        if (acc >= ref) then
        begin
          Xoff := XT;
          YOff := YT;
          Result := True;
          Exit;
        end;
        if times mod 5 = 0 then
        begin
          ref := ref - 0.1;
          tol := tol + 10;
        end;
        Wait(1);
      end;
    end;

    When i try that i get
    "[Runtime Error] : Exception: Access violation at address 006A975B in module 'scar.exe'. Read of address 00000000 in line 114 in script C:\ProgramFiles\SCAR3.06\Scripts\MyPowerMiner\Walk ToMineV1.scar"
    But i only get that when running it. It compiles, starts, and once it gets to that part it gives me that.

    SCAR Code:
    begin //112
        FindDeformedBitmapToleranceIn(BMP, XT, YT, a, b, c, d, tol, 2, True, acc); //113
        if (acc >= ref) then //114
        begin //115

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Case help
    By Aser in forum OSR Help
    Replies: 3
    Last Post: 11-22-2008, 05:21 AM
  2. Case..Of Help
    By Drew_Dawg in forum OSR Help
    Replies: 7
    Last Post: 02-02-2008, 11:47 PM
  3. Using Case and Of
    By Fourscape in forum Outdated Tutorials
    Replies: 3
    Last Post: 08-18-2007, 08:40 PM
  4. Case - Else
    By stylen in forum OSR Help
    Replies: 0
    Last Post: 05-30-2007, 11:54 PM
  5. Need help making more accurate procedure
    By pwnaz0r in forum OSR Help
    Replies: 10
    Last Post: 02-06-2007, 04:27 AM

Posting Permissions

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