Results 1 to 13 of 13

Thread: Beginner question - How do i end script

  1. #1
    Join Date
    May 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Beginner question - How do i end script

    Hey all, just started out yesterday and I'm starting to learn about the scripting by making a simple bot for flash games. The game I'm working on is Demonic Defense 4 here is the script i have so far:
    Code:
    program SaveTheGoldfish;
    
    procedure StartGame;
    begin
       MoveMouse(275, 230);
       ClickMouse(275, 230, 1);
       Wait(10500);
       MoveMouse(116, 168);
       ClickMouse(116, 168, 1);
       Wait(300);
       MoveMouse(113, 264);
       ClickMouse(113, 264, 1);
       Wait(300);
       MoveMouse(128, 170);
       ClickMouse(128, 170, 1);
       Wait(500);
       MoveMouse(278, 134);
       HoldMouse(278, 134, 1);
       MoveMouse(209, 133);
       ReleaseMouse(209, 133, 1);
       Wait(500);
       PressKey(52);
       Wait(500);
       MoveMouse(314, 160);
       ClickMouse(314, 160, 1);
       Wait(100);
       MoveMouse(314, 160);
       ClickMouse(314, 160, 1);
       Wait(100);
       MoveMouse(314, 160);
       ClickMouse(314, 160, 1);
       Wait(100);
       MoveMouse(314, 160);
       ClickMouse(314, 160, 1);
       Wait(100);
       MoveMouse(314, 160);
       ClickMouse(314, 160, 1);
       Wait(100);
       MoveMouse(314, 216);
       ClickMouse(314, 216, 1);
       Wait(100);
       MoveMouse(314, 216);
       ClickMouse(314, 216, 1);
       Wait(100);
       MoveMouse(314, 216);
       ClickMouse(314, 216, 1);
       Wait(100);
       MoveMouse(248, 269);
       ClickMouse(248, 269, 1);
    end;
    
    procedure DefendTower;
    var
      x, y:Integer;
      begin
        if FindColorSpiralTolerance(x, y, 0       , 142, 187, 547, 397, 5) or
           FindColorSpiralTolerance(x, y, 9539985 , 142, 187, 547, 397, 5) or
           FindColorSpiralTolerance(x, y, 6684672 , 142, 187, 547, 397, 5) or
           FindColorSpiralTolerance(x, y, 6710784 , 142, 187, 547, 397, 5) or
           FindColorSpiralTolerance(x, y, 5598082 , 142, 187, 547, 397, 5) then
           begin
            MoveMouse(x, y);
            HoldMouse(x, y, 1);
            MoveMouse(60, 77);
            ReleaseMouse(60, 77, 1);
            end;
      end;
    
         procedure KillScript;
    begin
      while(isKeyDown(27)) do
      TerminateScript;
    end;
    
         procedure LevelEnd;
         var
      x1, y1:Integer;
    begin
           if FindColorSpiralTolerance(x1, y1, 4016735, 253, 211, 326, 234, 5) then
          TerminateScript;
    end;
    
      begin
        StartGame;
        Wait(3000);
        repeat
        LevelEnd;
        KillScript;
        DefendTower;
        until(false);
      end.
    Ok so, what i want to know is how to make the repeat end once LevelEnd; has completed. At the moment it just kills the script outright (using TerminateScript once it detects the level has ended. How would i create maybe a Boolean that tells the "Until" part to be false so the script stops.
    So far i have tried adding a variable into the KillScript; (under x1, y1:Integer so that once the color is detected it changes to true, but i keep getting errors and i still have no idea how to make the Until detect that and stop repeating.

    Hope you understand what I'm asking :P thanks for help in advanced!

  2. #2
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    turn LevelEnd into a function that return a boolean value. then repeat, until(levelEnd);

  3. #3
    Join Date
    May 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ah would you be amazing and quickly show me what you mean? not sure how to make it return a Boolean value

    Sowwi if i sound stupid xD started learning this scripting last night, the only other language i know is batch script and thats easy as hell.

  4. #4
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

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

    Default

    Thanks for the great link ill look over it in detail over the next few days . could someone still show me how i can correct my code to do what x[Warrior]x3500 said though would love to get this working. thanks!

  6. #6
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    if you look over the procedures and functions section of the guide provided above, you should be able to figure out how to

  7. #7
    Join Date
    May 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I have and i still don't get how to return a Boolean. i have changed it too:
    Code:
         function LevelEnd: Integer;
         var
      x1, y1:Integer;
    begin
           if FindColorSpiralTolerance(x1, y1, 4016735, 253, 211, 326, 234, 5) then
          Result := 1;
    end;
    and
    Code:
      begin
        StartGame;
        Wait(3000);
        repeat
        LevelEnd;
        KillScript;
        DefendTower;
        until(levelEnd);
      end.
    but that's returning a Integer not a Boolean. No idea still how to get it to return true if the function completes.

  8. #8
    Join Date
    Dec 2011
    Location
    Kosovo
    Posts
    831
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    You should try to see the Yohos tut again and try tutorial island
    Goals:
    Understanding TPAs
    Making Proggy for fighting
    Getting on SRL members
    Get 500 posts

  9. #9
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    function LevelEnd: Integer; -> function LevelEnd: boolean;

  10. #10
    Join Date
    May 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thanks ill try that

  11. #11
    Join Date
    May 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    works perfect and i can see what i was doing wrong now thanks loads for the help !
    quick question if anyone's still here,
    Code:
    PressKey(52);
    this outputs the number 4 but in the Simba handbook it says that "R: 52". Also the "DELETE: 46" didn't work correctly either.

  12. #12
    Join Date
    May 2008
    Location
    ;)
    Posts
    576
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Risen91 View Post
    works perfect and i can see what i was doing wrong now thanks loads for the help !
    quick question if anyone's still here,
    Code:
    PressKey(52);
    this outputs the number 4 but in the Simba handbook it says that "R: 52". Also the "DELETE: 46" didn't work correctly either.
    Use sendkeys/typesend?

  13. #13
    Join Date
    Dec 2011
    Posts
    733
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    instead of using the number, use the constant associated with your key to be pressed. to seee a list of every possible key that simba can press, type vk_ then press control-space

    this will popup the code completion list, which will show all of the possible matching vk values. for 'R', try VK_R. for delete, VK_DELETE
    My scripts: LunarPlanker
    ---
    My Utilities: Cross Platform, Open Source, SPS Path Generator

    Join the Unoficial SRL Skype Group by clicking here, or visiting this thread.

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
  •