Results 1 to 9 of 9

Thread: Main Loop Help?

  1. #1
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default Main Loop Help?

    Hey guys, working on the next version of PMS. Going to make a big? change to the main loop, but not sure about how to go about doing it...

    Currently, I have something like this (Shortened)

    SCAR Code:
    If (TimeFromMark(WeMined) > 90000) Then
          Begin
            Players[CurrentPlayer].Loc:='Cant Find Rock :(';
            StatsGuise('NP:Cnt.Fnd.Rock');
            Logout;
            Break;
          End;

    So, If the time between mining rocks is over 1 minute and 30 seconds, then Log Out.

    And then later in the loop I have

    SCAR Code:
    Players[CurrentPlayer].Active := LoggedIn;
        PlayerCurTime := GetSystemTime;
        Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked + (PlayerCurTime - PlayerStartTime);
        Logout;

    This sets the current players true/false status to true if logged in, false if logged out.

    The problem is, sometimes the script gives the "can't find rock for 1 minute 30 seconds" error, and sets a character to false, yet the character is just fine, outside of a random, and near rocks (weird huh?)

    So what I want to do instead is allow a character to get the "can't find rock for 1 minute 30 seconds" error THREE TIMES before setting it to false.

    I was thinking of something like, if the error occurs, log out (BUT KEEP THE PLAYER STATUS TRUE), and continue on looping the characters like normal, if the error happens again (and totals 3 times eventually) THEN set the character to false.

    That's the best I can explain it for now hopefully you all understand, ask for clarification if needed!

    Thanks A Bunch!
    YoHoJo


    Edit:
    Hmm Maybe something like
    Players[CurrentPlayer].Integers[84] Can be the error counter
    Each time the problem happens Inc Integer84
    And do something like

    SCAR Code:
    If Players[CurrentPlayer].Integers[84] < 3 Then
     Players[CurrentPlayer].Active := True;
    else
    Players[CurrentPlayer].Active := LoggedIn;

    Would that do it? !

  2. #2
    Join Date
    Aug 2009
    Location
    Inside the Matrix...yes it has me, and it has you too.
    Posts
    1,896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @ the edit, i was going to suggest something like this, from what i got from what you explained i think it would work.
    But 84 player integers? What the hell? O_o
    NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN

  3. #3
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I thinks that the time counter is still going while you are in the random. Well I just said that but it's obvious .
    So what I would try is something like this:
    SCAR Code:
    if FindNormalRandoms then
      ResetPlayerCounters ...
    so that after the player solved the random successfully the counter restarts so that error doesn't come up.
    I think you can implement counting the failures too but I think you shouldn't increment it after solved randoms.
    However when a player can't find the rock can mean you moved to a weird place somehow(you never know) and then logging in, standing there for 1,5 minutes then logout is maybe suspicious.
    Last edited by Sabzi; 03-19-2010 at 09:35 PM.

  4. #4
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Nice notice Sabzi, but like I said I shortened the procedure before posting it just so you guys could see the main concept, before/after randoms I have:

    SCAR Code:
    RT:=GetSystemTime;
          If FindNormalRandoms Then
           IncEx(WeMined, GetSystemTime - RT);

    And Bionicle, I started integers at 80 for some reason :]
    I have 1, 80,81,82,83 I think?

  5. #5
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Nice notice Sabzi, but like I said I shortened the procedure before posting it just so you guys could see the main concept, before/after randoms I have:

    SCAR Code:
    RT:=GetSystemTime;
          If FindNormalRandoms Then
           IncEx(WeMined, GetSystemTime - RT);
    Oh, yes that pretty much solves the problem(not the original I mean).
    But that should be DecEx, no? That would make sense why the problem still occurs.

  6. #6
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    I thought that too, and so did TONS of other people, but Icefire said to do it that way, and I even made a test script to see if the concept worked, and it did, still doesn't make sense to me either though!

    Edit:
    The concept test script:

    SCAR Code:
    program New;
       {.include SRL\SRL.scar}
    var Time,DontWorry:Integer;


    begin
      MarkTime(Time);
      Wait(2000);
      DontWorry:=GetSystemTime;
      Wait(1000);
      IncEx(Time,GetSystemTime - DontWorry);
      Writeln(IntToStr(TimeFromMark(Time)))
    end.

  7. #7
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I understand now. Thanks for the concept script. The timer is a variable that holds the previous SystemTime and when you call TimeFromMark it just do:
    GetSystemTime - PreviousSystemTime
    So if you increment the previous system time the end result will be smaller.
    It's hard to think about that first. I first thought that "WeMined" is already in milisecs took to mine after TimeFromMark(I don't know why I thought that)
    On-topic: Best idea is still yours to make a player variable counting the failures .
    Last edited by Sabzi; 03-19-2010 at 09:53 PM.

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

    Default

    tl;dr: Check out my abyssal crafters main loop. It was t3h sex.
    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

  9. #9
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    More suggestions?
    Or more conformation that my idea (on first post) will work?

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
  •