Results 1 to 10 of 10

Thread: Help with manipulating DDTMS

  1. #1
    Join Date
    Feb 2007
    Posts
    142
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Help with manipulating DDTMS

    Alright, so i have my function set up, the DDTM is set up correctly, it compiles fine, it runs fine

    however, i am having trouble with my loop

    here's the function


    SCAR Code:
    Function WalkToStart:boolean;
    var x,y,c: integer;
    Begin
      For Z:=1 To 5 Do
      Begin
        wait(100+random(200));
        BDTMTol:=30
        BDTMArea:=1
        LoadBeginningDTM;
        repeat
        if (DTMRotated(Beginning,x,y,MMX1,MMY1,MMX2,MMY2)) Then
          Result:=True;
          if not (DTMRotated(Beginning,x,y,MMX1,MMY1,MMX2,MMY2)) Then
            Result:=False;
            begin
            If Result = True then
              begin
                Writeln('Found DTM at a tolerance of '+IntToStr(BDTMTol)+ 'and an area of '+IntToStr(BDTMArea))
                mouse(x,y,0,0,True);
                c:= 0;
                Exit;
              end else
              begin
                if Result=False then
                begin
                  BDTMTol:=BDTMTol+10;
                  BDTMArea:=BDTMArea+1;
                  c:=c+1;
                  Writeln('I Should Say This 6 Times If I Cant Find my DTM');
                  wait(1000);
                End;
              End;
            End;
          until (Result=True)or(c>5);
        End;
          Writeln('Could not find dtm at a tolerance of '+IntToStr(BDTMTol)+ ' and an area of '+IntToStr(BDTMArea))
    End;

    whenever it doesn't find my dtm, it's suppose to add a tolerance of 10 and then look for the dtm again, and what i want it to do is add the tolerance a total of 'C' times, hence the variable placed in the script as a failsafe

    If i set the tolerance to around 30, it will find the DDTM perfectly fine
    but if i set the tolerance to 20, it will not find the DTM, add the tolerance once, and then fail to find my DTM

    and of course i hope we all know that 20+10=30, which is the tolerance i had it set at when it found it perfectly fine

    that's the first problem

    the second problem is that it won't add a tolerance more than once

    if it fails to find the dtm, it will write in the debug box 10 times, which has to do with the C, but it fails to add tolerance more than one time

    SCAR Code:
    Successfully compiled
    SRL Compiled in 15 msec
    Creating the NickTPA.
    I Should Say This 6 Times If I Cant Find my DTM
    I Should Say This 6 Times If I Cant Find my DTM
    I Should Say This 6 Times If I Cant Find my DTM
    I Should Say This 6 Times If I Cant Find my DTM
    I Should Say This 6 Times If I Cant Find my DTM
    I Should Say This 6 Times If I Cant Find my DTM
    I Should Say This 6 Times If I Cant Find my DTM
    I Should Say This 6 Times If I Cant Find my DTM
    I Should Say This 6 Times If I Cant Find my DTM
    I Should Say This 6 Times If I Cant Find my DTM
    Could not find dtm at a tolerance of 30 and an area of 2
    Successfully executed

    and yes, it says it 10 times, not sure why, but i don't care about that right now, i'm more focused on the DDTM

    if you could offer any suggestions that would be lovely
    and sorry if my standards are a little off, i was just trying to learn and manipulate some DDTMs

    thanks

    DD

  2. #2
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    Do FreeDTM and AddDTM again to refresh the DDTM in the RAM.
    I made a new script, check it out!.

  3. #3
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Also, make sure you add 'Begin' s after every 'If () Then' so it runs the whole thing properly and not random lines (whcih could explain it writing the line 10 times instead of 6)

  4. #4
    Join Date
    Feb 2007
    Posts
    142
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ok, thanks guys

    i rewrote it, however the only thing i managed to fix was it looping it 6 times instead of 10

    i think i understand what you're saying markus, but i don't really know what that looks like or how to code it correctly, i've been playing around with it and trying to set my values in different places to allow Tol+5 to work, but still no luck, here's what i have so far

    SCAR Code:
    program New;
    {.include SRL\SRL.scar}

    var Beginning,Z,BDTMTol,BDTMArea:Integer;
    var BeginningMP: TDTMPointDef;
    var BeginningSP: array[0..3] of TDTMPointDef;
    var BeginningDTMSkel: TDTM;
    var c:integer;
    var FindDTMBeginning:Boolean;


    Procedure DeclarePlayers;
    Begin
        HowManyPlayers := 1;
        NumberOfPlayers(HowManyPlayers);
        CurrentPlayer := 0;

        Players[0].Name     := 'Username';
        Players[0].Pass     := 'Password';
        Players[0].Nick     := 'ser';
        Players[0].Active   := True;
    End;



    Procedure LoadBeginningDTM;
    Begin

      BDTMTol:=15
      BDTMArea:=1

      BeginningMP.x:=39;
      BeginningMP.y:=24;
      BeginningMP.areasize:=1;
      BeginningMP.areashape:=0;
      BeginningMP.color:=2527627;
      BeginningMP.tolerance:=BDTMTol;

      BeginningSP[0].x:=43;
      BeginningSP[0].y:=35;
      BeginningSP[0].areasize:=BDTMArea;
      BeginningSP[0].areashape:=0;
      BeginningSP[0].color:=12227455;
      BeginningSP[0].tolerance:=BDTMTol;

      BeginningSP[1].x:=24;
      BeginningSP[1].y:=3;
      BeginningSP[1].areasize:=BDTMArea;
      BeginningSP[1].areashape:=0;
      BeginningSP[1].color:=0;
      BeginningSP[1].tolerance:=BDTMTol;

      BeginningSP[2].x:=8;
      BeginningSP[2].y:=19;
      BeginningSP[2].areasize:=BDTMArea;
      BeginningSP[2].areashape:=0;
      BeginningSP[2].color:=0;
      BeginningSP[2].tolerance:=BDTMTol;

      BeginningSP[3].x:=21;
      BeginningSP[3].y:=32;
      BeginningSP[3].areasize:=BDTMArea;
      BeginningSP[3].areashape:=0;
      BeginningSP[3].color:=2525585;
      BeginningSP[3].tolerance:=BDTMTol;


      BeginningDTMSkel.MainPoint:=BeginningMP
      BeginningDTMSkel.SubPoints:=BeginningSP;
      Beginning:=AddDTM(BeginningDTMSkel);
    end;

    Function FindBeginningDTM:boolean;

    var x,y:integer;

    begin
      For Z:=1 to 5 Do
      Begin
        wait(100+random(200));
        begin
          LoadBeginningDTM;
        end;
        if (DTMRotated(Beginning,x,y,MMX1,MMY1,MMX2,MMY2)) Then
        Begin
          FindDTMBeginning:= True;
          mouse(x,y,0,0,True);
          Writeln('Found DTM at a tolerance of '+IntToStr(BDTMTol)+ 'and an area of '+IntToStr(BDTMArea));
        end;
        if not (DTMRotated(Beginning,x,y,MMX1,MMY1,MMX2,MMY2)) Then
        begin
          FindDTMBeginning:=False;
        end;
      end;
    end;


    Procedure WalkToBeginning;

    begin
      For Z:=1 To 5 Do
      begin
        FindBeginningDTM;
        if (FindDTMBeginning = True) then
        begin
          BDTMTol:=15; //i'm trying to reset my values here
          BDTMArea:=1;
          Exit;
        end else
        if (FindDTMBeginning=False) then
        begin
          repeat
            freeDTM(Beginning); //this is where i'm attempting to change what markus helped me with, but still kinda confused on how to code it correctly
            BDTMTol:=BDTMTol+5;//i'm trying to bump up my tolerences and such here in the case that it doesn't find my dtm
            BDTMArea:=BDTMArea+1; //this and Tol is what i'm really having trouble with
            c:=c+1;
            Writeln('I should say this 6 times'); //this works correctly now, just left it in here to say thanks
            FindBeginningDTM;
          until (FindDTMBeginning = True) or (c>5);
          begin
            if (FindDTMBeginning = True) then
            begin
              c:=0;
            end else
            begin
              Writeln('Could not find dtm at a tolerance of'+IntToStr(BDTMTol)+ 'and an area of '+IntToStr(BDTMArea))
            end;
          end;
        end;
      end;
    end;

    Procedure SetupScript;
    begin
      ActivateClient;
      DeclarePlayers;
      wait(100+random(200));
      LoginPlayer;
      MakeCompass('s');
    end;

    Begin
      SetupSRL;
      SetupScript;
      WalkToBeginning;
    End.

    it's very simplistic, i'm still just trying to play with the DDTM's
    still having trouble though, any help or pointers would be mucho appreciated

    thanks!

    DD

  5. #5
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    What Markus was saying that your RAM probably had a wrong version of your DDTM in its memory, so said to use 'FreeDTM(Beginnning)' at the beginnning of the DDTM setup so it removed it from the memory and would then add the new one (though if you've closed your scar at all, then it shouldn't be that and it might just be that you've gotten 1 of your co-ords wrong)

  6. #6
    Join Date
    Feb 2007
    Posts
    142
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    well, as i said earlier, the DDTM works perfectly at a higher tolerance
    but i'm not coding it correctly to allow it to bump up the tolerance and search for the dtm again, and that is what i need help with

    i know full and well that it won't find my dtm at a tolerance of 15, but it will find it perfectly at a tolerance of 30 (maybe even 25)
    i'm just trying to figure out how to code it correctly so that it will bump up the tolerance and find my DTM

    freeing the DTM in the loading procedure doesn't really make logical sense, i could be wrong
    i haven't written a lot of coding yet, but if you free the dtm in the same procedure/function you loaded it in, then you never give your dtm a chance to be found

    thanks for reading and spending time helping! I appreciate it alot! however, i'm still stuck
    i could just set the tolerance higher to begin with and let it be, but that wouldn't be much of a failsafe in my script now would it?

    plus i'm the kinda guy that sees xy=1 as x=1/y and y=1/x (simply put of course) and i can't seem to manipulate the coding i'm working with here to make that happen

    thanks guys, i still need a little help with the coding, because i'm kinda stuck, if i need to rewrite my entire function, then let me know now

    DD

    edit: forget what i said in this post, i managed to figure it out, thanks for everything guys!

  7. #7
    Join Date
    Jun 2007
    Posts
    1,312
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I know you said you got it fixed, but I want to point out something else to you. This is very inefficient, and I don't know why you would choose to do it this way, but I will show you how to do it your way first.
    SCAR Code:
    function WalkToStart:boolean;
    var x,y,c: integer;
    begin
      BDTMTol:=30     //This should be here, the for to do is completely pointless
      BDTMArea:=1     //as I see it...
      wait(100+random(200));
      LoadBeginningDTM;
      repeat
        if (DTMRotated(Beginning,x,y,MMX1,MMY1,MMX2,MMY2)) Then
          Result:=True;
        if not (DTMRotated(Beginning,x,y,MMX1,MMY1,MMX2,MMY2)) Then
          Result:=False;
        If Result = True then
        begin
          Writeln('Found DTM at a tolerance of '+IntToStr(BDTMTol)+ 'and an area of '+IntToStr(BDTMArea))
          mouse(x,y,0,0,True);
          c:= 0;
          Exit;
        end;
        BDTMTol:=BDTMTol+10;
        BDTMArea:=BDTMArea+1;
        c:=c+1;
        Writeln('I Should Say This 6 Times If I Cant Find my DTM');
        wait(1000);
      until (Result=True)or(c>5);
          Writeln('Could not find dtm at a tolerance of '+IntToStr(BDTMTol)+ ' and an area of '+IntToStr(BDTMArea))
    end;
    Much less code. Also, in your function, you never defined 'z' as an integer.
    This is how I would do it.
    SCAR Code:
    function WalkToStart:boolean;
    var x,y,c: integer;
    begin
      BDTMTol:=30     //This should be here, the for to do is completely pointless
      BDTMArea:=1     //as I see it...
      wait(100+random(200));
      LoadBeginningDTM;
      repeat
        case DTMRotated(beginning, x, y, MMX1, MMY1, MMX2, MMY2) of
          True:Result :=True;
          False:Result:=False;
        end;
        If Result then
        begin
          Writeln('Found DTM at a tolerance of '+IntToStr(BDTMTol)+ 'and an area of '+IntToStr(BDTMArea))
          mouse(x,y,0,0,True);
          FreeDTM(Beginning);
          Exit;
        end;
        BDTMTol:=BDTMTol+10;
        BDTMArea:=BDTMArea+1;
        inc(c);
        Writeln('I Should Say This 6 Times If I Cant Find my DTM');
        wait(1000);
      until (Result=True)or(c>5);
      Writeln('Could not find dtm at a tolerance of '+IntToStr(BDTMTol)+ ' and an area of '+IntToStr(BDTMArea));
      FreeDTM(Beginning);
    end;
    Even though I would not use a repeat until loop for finding a dtm.
    Active only during the Summer...

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

    Default

    Uhh, pretty non-understandable is situation for me here...

    Ask from nielsie95 to give you his DDTM editor, in case you made your DDTMS wrong, and colors won't change that much you'll need tolerance of 30?!? wtf
    [CENTER][SIZE="4"]Inactive[/SIZE]I forgot my password[/CENTER]

  9. #9
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Just an extra note, if you did want to keep your script pretty much the same and get the increased tolerance when it can't find it, you have to free the dtm at the end of the 'For' and load it again at the beginning, as if you only load it the once, that one stays in (I can attempt to add it in if you want)

  10. #10
    Join Date
    Jun 2007
    Posts
    1,312
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Negaal View Post
    Uhh, pretty non-understandable is situation for me here...

    Ask from nielsie95 to give you his DDTM editor, in case you made your DDTMS wrong, and colors won't change that much you'll need tolerance of 30?!? wtf
    I use tolerances of 50 =D
    Active only during the Summer...

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. DDTMs and their uses
    By Raskolnikov in forum Outdated Tutorials
    Replies: 13
    Last Post: 04-16-2008, 01:57 PM
  2. Need help with DDtms
    By Naum in forum OSR Help
    Replies: 9
    Last Post: 02-02-2008, 06:31 AM
  3. DDTMs
    By Jackrawl in forum OSR Help
    Replies: 19
    Last Post: 12-23-2007, 02:56 AM
  4. Ddtms?
    By RudeBoiAlex in forum OSR Help
    Replies: 6
    Last Post: 09-11-2007, 04:07 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
  •