Results 1 to 16 of 16

Thread: how can i declare a variable = 0 at the start of a script?

  1. #1
    Join Date
    Feb 2013
    Posts
    104
    Mentioned
    1 Post(s)
    Quoted
    32 Post(s)

    Default how can i declare a variable = 0 at the start of a script?

    I am having trouble making a variable = 0 only at the start of the script. can someone please tell me where i can declare it to do this?

  2. #2
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Like this?

    Simba Code:
    program Test;
    Var
      Number:Integer;
    procedure DoStuff;
    begin
      Writeln('stuff')
    end;

    begin
      Number := 0
      repeat
        DoStuff;
        Until False;
    end.

  3. #3
    Join Date
    Feb 2013
    Posts
    104
    Mentioned
    1 Post(s)
    Quoted
    32 Post(s)

    Default

    Quote Originally Posted by rjj95 View Post
    Like this?

    Simba Code:
    program Test;
    Var
      Number:Integer;
    procedure DoStuff;
    begin
      Writeln('stuff')
    end;

    begin
      Number := 0
      repeat
        DoStuff;
        Until False;
    end.
    thats exactly where i put it and if all of my other coding was correct then it was declaring it as 0 randomly throughout the script

    i'm pretty sure its not my code, i'm still having the problem, it doesn't declare it as 0 randomly, everytime the script restarts and goes through the main process it happens.
    Last edited by blockay; 02-27-2013 at 02:31 AM.

  4. #4
    Join Date
    Apr 2012
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by blockay View Post
    thats exactly where i put it and if all of my other coding was correct then it was declaring it as 0 randomly throughout the script

    i'm pretty sure its not my code, i'm still having the problem, it doesn't declare it as 0 randomly, everytime the script restarts and goes through the main process it happens.
    Pm me your code and i'll tell you the error if you want. Or post it here.

  5. #5
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    It's 0 by default, and everytime it gets called again. It turns to 0 again.

    Creds to DannyRS for this wonderful sig!

  6. #6
    Join Date
    Feb 2013
    Posts
    104
    Mentioned
    1 Post(s)
    Quoted
    32 Post(s)

    Default

    begin
    run := 0;
    if (run = 0) then
    begin
    MarkTime(i)
    turnRunOn;
    z := 1;
    end;
    end;
    this is what i have, it doesn't work properly

  7. #7
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Quote Originally Posted by blockay View Post
    this is what i have, it doesn't work properly
    Try putting it in SIMBA tags instead of QUOTE tags. But anyway, I believe your issue is because (although I can't see all your code) that you're looping through that situation, re-initializing run to 0. If you only want it to equal 0 for the first run, never set it at all, just delete that line.

  8. #8
    Join Date
    Feb 2013
    Posts
    104
    Mentioned
    1 Post(s)
    Quoted
    32 Post(s)

    Default

    Simba Code:
    begin
    run := 0;
    repeat
    if (run = 0) then
    begin
    MarkTime(i)
    turnRunOn;
    z := 1;
    end;
    until (false)
    end;
    i have it like this, i don't believe that run := 0; is in the loop this way. but i will try to not declare := 0; and report back if it works or not

    edit: i tried it without having run:= 0; didn't work.
    Last edited by blockay; 02-27-2013 at 06:31 PM.

  9. #9
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Try showing us your entire script so we can see if the issue lies elsewhere as well?

  10. #10
    Join Date
    Feb 2013
    Posts
    104
    Mentioned
    1 Post(s)
    Quoted
    32 Post(s)

    Default

    Simba Code:
    program CutterShafter;
    {$I SRL/SRL.Simba}
    {$I P07Include.Simba}

    var
      x, aInteger, inventory, math, TreeColor3, k, y, i, z, run, logs, knife, TreeColor, TreeColors: integer;

    procedure DTM;
    begin
    TreeColor := 4162679;
    TreeColors := 2574918;
    TreeColor3 := 2902849;
    runIsOn := 1777019;
    end;

    Procedure P07_DeclarePlayer;
    Begin
      P07_PlayerName:='';
      P07_PlayerPass:='';
    end;

    Procedure CallThings;
    Begin
       {Going to Name the Bitmap string " Ring ", and declare the variable under Var}
        knife:= BitmapFromString(10, 10, 'meJwztnE1tfMwBpIOnowMDCUlNY' +
            'WFVVlZRX39M4FcoDgEAdllZXVA2dy88rS03HnzVkFkgbpMHdwgsvk' +
            'FlRkZ+ZMmzQVyFRQMrJy8IWZWVDQAzczOKU1JyV68eD1EFq4RYiZQ' +
            '47TpiyBSEFkgm9MqFIhmzlrW2TVl2fJNEFmIYyBScAVYNUIQr0cO3' +
            'D1AhFUKUxZZCuxUEAIANwhKdQ==');
        logs := BitmapFromString(7, 13, 'meJwL6F8f0L9eNqTcNq3VOqUJggL' +
            'AgnBxiBRcBKLGKrEeiGTDq0AooAjCBSIttyizqDKgiEV8jZ5fGhwB' +
            'BaW8s6U8MkwjiiDIODQfpBKsXcovH6gegoDKkB0AsQuoDFMQUyUQi' +
            'TvHYwoyMjDABYEILgg3FqgSohgA9ylm1w==');
    End;

    Procedure FreeThings;
    Begin
       FreeBitMap(logs);
       FreeBitMap(knife);
    End;

    procedure findTree;
    Begin
      if not (P07_FindObjCustom(x, y, [ree, tre], [TreeColor, TreeColor3, TreeColors], 1)) Then
        case RandomRange(1,1000) of
          1..250: P07_MakeCompassNorth;
          251..500: P07_MakeCompassEast;
          501..750: P07_MakeCompassSouth;
          751..1000: P07_MakeCompassWest;
        end;
    End;

    Function IsCutting: Boolean;
    var
      PBox: TBox;
    Begin
      PBox := IntToBox(238, 149, 286, 186);
      Result := (AveragePixelShift(PBox, 250, 350) > 350);
      Writeln(IntToStr(AveragePixelShift(PBox, 500, 650)));
    End;
    Function IsWcing: Boolean;
    var
      PBox: TBox;
    Begin
      PBox := IntToBox(238, 149, 286, 186);
      Result := (AveragePixelShift(PBox, 250, 350) > 150);
      Writeln(IntToStr(AveragePixelShift(PBox, 500, 650)));
    End;
    Function IsFletching: Boolean;
    var
      PBox: TBox;
    Begin
      PBox := IntToBox(250, 145, 273, 175);
      Result := (AveragePixelShift(PBox, 250, 350) > 75);
      Writeln(IntToStr(AveragePixelShift(PBox, 500, 650)));
    End;

    procedure makeShafts;
    Begin
        MarkTime(thaTime);
      If FindBitMapToleranceIn(logs, x, y, MIX1, MIY1, MIX2, MIY2, 50) Then
        Mouse(x, y, Random(3), Random(3), true);
        P07_ChooseOptionMulti(['weiner']);
        P07_MakeCompassNorth;
      If FindBitMapToleranceIn(knife, x, y, MIX1, MIY1, MIX2, MIY2, 50) Then
        Mouse(x, y, Random(3), Random(3), true);
        P07_ChooseOptionMulti(['use']);
        P07_MouseBox(24, 435, 130, 452, 3);
        Wait(RandomRange(400,500));
        ClickMouse2(Mouse_Right);
        Wait(RandomRange(300,400));
        P07_ChooseOptionMulti(['ake X', 'X']);
        Wait(RandomRange(750,900));
        SendKeys('88', 95, 35);
        Wait(RandomRange(300, 400));
        P07_UseKey(13);
        Wait(RandomRange(3000, 5000));
       If IsFletching then
         begin
           inventory := P07_InvCount;
             repeat
              repeat
                if TimeFromMark(thaTime) > 50000 then Break;
                  Wait(500);
              until (inventory < P07_InvCount);
             until (P07_InvCount < 4);
         end
      else
        if (P07_InvCount > 4) then
         begin
           inventory := P07_InvCount;
             repeat
              repeat
                if TimeFromMark(thaTime) > 50000 then Break;
                  Wait(500);
              until (inventory < P07_InvCount);
             until (P07_InvCount < 4);
         end;
       end;


    Procedure turnRunOn;
    begin
      if i > (math) then
        begin
          P07_MouseBox(665, 470, 686, 493, 3);
          Wait(RandomRange(400,500));
          ClickMouse2(Mouse_Left);
         If (Not FindColorTolerance(x,y,runIsOn,625,413,658,447, 4)) Then
          begin
            P07_Mousebox(625, 413, 658, 447, 3);
            Wait(RandomRange(200, 350));
            ClickMouse2(Mouse_Left);
            Wait(RandomRange(200, 350));
            P07_TabInventoryTab(4);
            z := (z + 1);
          end
         else
          If FindColorTolerance(x,y,runIsOn,625,413,658,447, 4) Then
            begin
              P07_TabInventoryTab(4);
              z := (z + 1);
            end;
        end;
    end;

    procedure ChopTree;
    begin
      If not IsWcing then
        If P07_FindObjCustom(x, y, ['Tree', 'own Tr'], [TreeColor, TreeColor3, TreeColors], 1) Then
          if Random(28) = 1 then
            begin
              ClickMouse2(mouse_right);
              P07_ChooseOptionMulti(['Chop']);
              Wait(RandomRange(500, 1000));
            end
          else
            begin
              ClickMouse2(mouse_left);
              P07_ChooseOptionMulti(['Chop']);
              Wait(RandomRange(550, 1000));
            end
          else
            If not (P07_FindObjCustom(x, y, ['ree', 'tre'], [TreeColor, TreeColor3, TreeColors], 1)) Then
              case random(1000) of
                1..250: P07_MakeCompassNorth;
                251..500: P07_MakeCompassEast;
                501..750: P07_MakeCompassSouth;
                751..1000: P07_MakeCompassWest;
            end;
        end;

    procedure waiting;
    begin
        MarkTime(thaTime);
        aInteger := P07_InvCount
      if IsCutting then
        repeat
          if TimeFromMark(thaTime) > 12000 then Break;
          Wait(500);
        Until (P07_InvCount > aInteger)
    end;

    begin
        run := 0;
        DTM;
        CallThings;
        P07_DeclarePlayer;
        SetupP07Include;
        ActivateClient;
        P07_MakeCompassNorth;
        Addonterminate('FreeThings')
        Wait(1000);
      repeat
        math := (100000 * z);
      If (Not P07_LoggedIn) Then
        begin
          P07_LogInPlayer;
          P07_MakeCameraAngleHigh;
        end;
      if (run = 0) then
          begin
            MarkTime(i)
            turnRunOn;
            z := 1;
           end;
      if(P07_InvFull) then
      repeat
        k := 1;
        IsFletching;
        makeShafts;
      until (P07_InvCount < 4)
      else
        if not (P07_InvFull) then
          begin
            repeat
              findTree;
              ChopTree;
              waiting;
          until (P07_InvFull)
        end;
      Until (false)
        FreeThings;
    End;

  11. #11
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    (responding publicly after a pm of his script)

    You never set the variable to 1. You will need to set
    Simba Code:
    run:=1;
    inside either your "turnRunOn" procedure or inside:
    Simba Code:
    if (run = 0) then
    begin
    MarkTime(i)
    turnRunOn;
    z := 1;
    end;

  12. #12
    Join Date
    Feb 2013
    Posts
    104
    Mentioned
    1 Post(s)
    Quoted
    32 Post(s)

    Default

    Quote Originally Posted by nivek1989 View Post
    (responding publicly after a pm of his script)

    You never set the variable to 1. You will need to set
    Simba Code:
    run:=1;
    inside either your "turnRunOn" procedure or inside:
    Simba Code:
    if (run = 0) then
    begin
    MarkTime(i)
    turnRunOn;
    z := 1;
    end;
    wow i feel so stupid. thanks
    i am trying to do too much at once i guess, i'll be sure this never happens again lol
    works great now well i did learn that if you don't declare a variable it begins at zero, that is good to know
    Last edited by blockay; 02-27-2013 at 07:08 PM.

  13. #13
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Quote Originally Posted by blockay View Post
    wow i feel so stupid. thanks
    i am trying to do too much at once i guess, i'll be sure this never happens again lol
    works great now well i did learn that if you don't declare a variable it begins at zero, that is good to know
    No worries! Also, booleans start as false all the time (if you happen to use those in the future).

  14. #14
    Join Date
    Feb 2013
    Posts
    104
    Mentioned
    1 Post(s)
    Quoted
    32 Post(s)

    Default

    Quote Originally Posted by nivek1989 View Post
    No worries! Also, booleans start as false all the time (if you happen to use those in the future).
    sweet alright, i definitely want to learn booleans now, a boolean is like FindObj() so it has variables and strings in the parenthesis(parameters)? and it uses those parameters to call upon a result
    Last edited by blockay; 02-27-2013 at 07:41 PM.

  15. #15
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    A boolean is just a variable that is only ever "True" or "False". All if statements are actually boolean checks. For example: your "if(run=0)" is evaluating whether or not "run" is set to 0 and creating a temporary boolean (that is evaluated to be true first run, false every other run) that determines whether or not it goes into the if.

    FindObj() returns a boolean telling you whether or not it found the object. The values in the parenthesis are values you pass to the procedure so it knows what it's looking for.

  16. #16
    Join Date
    Feb 2013
    Posts
    104
    Mentioned
    1 Post(s)
    Quoted
    32 Post(s)

    Default

    awesome. i'll definitely start using them
    thanks for all of your help i appreciate it

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
  •