Results 1 to 7 of 7

Thread: Access to session logs

  1. #1
    Developer
    Join Date
    Mar 2006
    Posts
    1,367

    Default Access to session logs

    If you had the ability to access session logs, for implementing something like what's mentioned here, what would you want the function call to look like?

    (string [int] refers to a map where the keys are the approximate line numbers in the file corresponding to non-blank lines)

    - string [int] session_log( string date )
    - string [int] session_log( int days_before_today )
    - ????

  2. #2
    Senior Member
    Join Date
    Mar 2006
    Posts
    729

    Default Re: Access to session logs

    My personal preference would be just

    string session_log( string date )

    and have access to a function which would return the EOL char(s) for the system in use. This would allow using contains_text on the log as a whole, and we can always use split_string to make a map of strings using the systems eol char(S) as the splitting point.

    A function could be written easy enough to return days before today.

  3. #3
    Developer
    Join Date
    Mar 2006
    Posts
    1,367

    Default Re: Access to session logs

    I decided to implement

    string [int] session_logs( string player, int day_count )[hr]Also, since it's relevant, split_string can now be called with just one parameter. If the last parameter is left off, KoLmafia will assume you want to use the system default line separators for it.

  4. #4
    Senior Member
    Join Date
    Mar 2006
    Posts
    729

    Default Re: Access to session logs

    string [int] split_string( string source ) added to the scripting wiki.

    Because the parameter name "day_count" changed since the first post I would like to be sure theat it means days before today rather than assuming so I have not added it. Also Should this function be added to string handling routines or your character or miscellaneous or another page?

  5. #5
    Developer
    Join Date
    Mar 2006
    Posts
    1,367

    Default Re: Access to session logs

    The parameter passed to the function is now the number of days you want including today. The indices into the map are now the days from today. So, suppose you wanted the last 30 days worth of session logs (which is really where this was made). Instead of having to write a for loop, it's a single function call. If you wanted to read things line by line, you would then take a single day and split it, using the new split_string method.

    PHP Code:
    int [itemfood_list;
    int [itembooze_list;

    string [intmy_logs session_logsmy_name(), 30 );

    foreach 
    day in my_logs
    {
     
      print"Parsing day " day "..." );

     
      if my_logs[day] == "" )
     
          continue;

     
      string [intlines my_logs[day].split_string();
     
      foreach line in lines
       
    {
     
          // It will always be "eat # itemname"
     
          if lines[line].index_of"eat" ) == )
     
              food_liststring_to_itemlines[line].substring(6) ) ] = day;

     
          // It will always be "drink # itemname"
     
          if lines[line].index_of"drink" ) == )
     
              booze_liststring_to_itemlines[line].substring(8) ) ] = day;
     
      }
    }

    print( 
    "Food history:" );
    foreach 
    food in food_list
        print
    food " (" food_list[food] + " days ago)" );

    print( 
    "\n\n" );
    print( 
    "Booze history:" );
    foreach 
    booze in booze_list
        print
    booze " (" booze_list[booze] + " days ago)" ); 

  6. #6
    Senior Member
    Join Date
    Mar 2006
    Posts
    729

    Default Re: Access to session logs

    OK and 1 more question, if you only have 15 days worth of logs, and ask for 30 will kolmafia just return what it has, or will this result in an error?

    I will put more details on the wiki later. Time is not my friend at the moment.

  7. #7
    Developer
    Join Date
    Mar 2006
    Posts
    1,367

    Default Re: Access to session logs

    It'll return 30 days worth of logs, but the remaining 15 will all be empty.

Similar Threads

  1. Bug - Fixed r12587 adventure count doesn't update in session logs
    By Captain Kirk in forum Bug Reports
    Replies: 3
    Last Post: 09-08-2013, 02:53 PM
  2. Bug Session logs omit turn number in certain instances
    By Lilac in forum Bug Reports
    Replies: 6
    Last Post: 04-29-2013, 07:40 PM
  3. Session Logs
    By Sputnik1 in forum Community Support
    Replies: 0
    Last Post: 10-26-2011, 03:20 AM
  4. Feature report arena flyer % in session logs, similar to insults
    By forgot my password in forum Bug Reports
    Replies: 1
    Last Post: 08-06-2010, 02:04 PM
  5. Why does print not work in session logs?
    By dj_d in forum Scripting Discussion
    Replies: 6
    Last Post: 09-03-2009, 04:09 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
  •