Results 1 to 11 of 11

Thread: Need some help with breaking..

  1. #1
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default Need some help with breaking..

    Okay, I know I've been asking for help a lot lately, but things are working quite like I want them to. Right now, this main loop will break/switch players after one hour, and then every load after one hour it will break/switch players again.

    All I want it to do is break/switch players every hour.

    SCAR Code:
    procedure F_MainLoop;
    var
      Start : Integer;
    begin
      F_ScriptSetup;
      repeat
        F_PlayerSetup;
        MarkTime(Start);
        repeat
          Col_Trees;
          repeat
            Cut_ChopTrees;
          until(InvFull);
          Cut_DropLogs;
          Prg_ProgReport;
          Writeln('All logs dropped, starting to cut again...');
          if (TimeFromMark(Start) > 3600000) then
          begin
            Start := 0;
            if (HowManyPlayers = 1) then
              Brk_TakeBreak
            else
            begin
              Players[CurrentPlayer].Integers[13] := Players[CurrentPlayer].Integers[13] + 1;
              NextPlayer(Players[CurrentPlayer].Active);
            end;
          end;
        until((Players[CurrentPlayer].Integers[10] >= Players[CurrentPlayer].Integers[0]) or not LoggedIn);

        if AllPlayersInactive then
        begin
          Writeln('All players are now inactive, terminating script...');
          TerminateScript;
        end;
       
        NextPlayer(Players[CurrentPlayer].Active);
      until(AllPlayersInactive);
    end;

    If you can help me out that's great, thanks.

  2. #2
    Join Date
    Feb 2007
    Posts
    3,616
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    procedure F_MainLoop;
    var
      Start, Timer: Integer; ////
    begin
      F_ScriptSetup;
      MarkTime(Timer);  ////
      repeat
        F_PlayerSetup;
        MarkTime(Start);
        repeat
          Col_Trees;
          repeat
            Cut_ChopTrees;
          until(InvFull);
          Cut_DropLogs;
          Prg_ProgReport;
          Writeln('All logs dropped, starting to cut again...');
          if (TimeFromMark(Start) > 3600000) then
          begin
            Start := 0;
            if (HowManyPlayers = 1) then
              Brk_TakeBreak
            else
            begin
              Players[CurrentPlayer].Integers[13] := Players[CurrentPlayer].Integers[13] + 1;
              NextPlayer(Players[CurrentPlayer].Active);
            end;
          end;
          if(TimeFromMark(Timer) > 360000)then   ////
          begin /////
            NextPlayer(False); ////
            break; /////
          end; ////
        until((Players[CurrentPlayer].Integers[10] >= Players[CurrentPlayer].Integers[0]) or not LoggedIn);

        if AllPlayersInactive then
        begin
          Writeln('All players are now inactive, terminating script...');
          TerminateScript;
        end;

        NextPlayer(Players[CurrentPlayer].Active);
      until(AllPlayersInactive);
    end;


    Just add a MarkTime and if it is greater than 1 hour, switch players? Hope I understood the question correctly.

  3. #3
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by JAD View Post
    Just add a MarkTime and if it is greater than 1 hour, switch players? Hope I understood the question correctly.
    That stuff you added is already there, and it takes a break after one hour, but then after one hour it breaks after every load. I'm guessing when I reset the variable Start back to zero, it didn't work because after every load it things an hour has still passed.

    SCAR Code:
    if (TimeFromMark(Start) > 3600000) then
          begin
            Start := 0;
            if (HowManyPlayers = 1) then
              Brk_TakeBreak
            else
            begin
              Players[CurrentPlayer].Integers[13] := Players[CurrentPlayer].Integers[13] + 1;
              NextPlayer(Players[CurrentPlayer].Active);
            end;
          end;
        until((Players[CurrentPlayer].Integers[10] >= Players[CurrentPlayer].Integers[0]) or not LoggedIn);

    EDIT:

    Could it be cause I didn't break out of the loop? I noticed you have a break there and I didn't.

  4. #4
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Setting Start to zero and calling MarkTime are two entirely different things. That's probably why your script breaks after every load.
    :-)

  5. #5
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Method View Post
    Setting Start to zero and calling MarkTime are two entirely different things. That's probably why your script breaks after every load.
    Yeah apparently, so what do you suggest I do? I can't think of anything else. Lol.

  6. #6
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Call MarkTime..

    I thought that was obvious, sorry.
    :-)

  7. #7
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Method View Post
    Call MarkTime..

    I thought that was obvious, sorry.
    Wait, calling it again restarts it back to 0? I didn't not know that. XD

  8. #8
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    It doesn't reset it back to zero, but it essentially starts your timer over again (see Timing.scar for more information).
    :-)

  9. #9
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Method View Post
    It doesn't reset it back to zero, but it essentially starts your timer over again (see Timing.scar for more information).
    Alright well you learn something new every day.

    That should solve the problem, thanks Method. Rep+

  10. #10
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Just to let you know, you are better off using the System in MarkTime yourself. Its just better practice, not as clean, but you get used to the logic. Also, you can use it different ways.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  11. #11
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    Just to let you know, you are better off using the System in MarkTime yourself. Its just better practice, not as clean, but you get used to the logic. Also, you can use it different ways.
    Lol. I'll worry about that later, I just want to get this working so I can release it then finish my next project.

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
  •