Author Topic: Pulling info from ED players journal  (Read 2583 times)

Incurable-Rash

  • Full Member
  • ***
  • Posts: 181
Pulling info from ED players journal
« on: April 26, 2020, 11:11:05 AM »
can an inline function be used to pull specific information from the elite dangerous saved journal or is there a better way to do it. right now I am using a AHK file that writes it to a notepad file for each thing I want, but was wondering if there is a way to do it without AHK.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Pulling info from ED players journal
« Reply #1 on: April 26, 2020, 11:18:11 AM »
An inline function can be used to read from a file directly, or you can use the "Value from file/URI" option of the "Set a Text Value" action to get the contents of a (text) file into a variable, and then use the inline function to do the parsing.

Incurable-Rash

  • Full Member
  • ***
  • Posts: 181
Re: Pulling info from ED players journal
« Reply #2 on: April 26, 2020, 11:56:01 AM »
The journal is always changing and updating, and the indicator for some of the values I am trying to retrieve are the same ie: gear up or down 1 or 0, or true false but this is repeated in other areas as well.

Incurable-Rash

  • Full Member
  • ***
  • Posts: 181
Re: Pulling info from ED players journal
« Reply #3 on: April 29, 2020, 03:28:19 PM »
Can you point me to something that would help me find out how to access the current file of the last updated file. I understand,I thing how how to access a static file up one that is updating or the file name changes I don't know how to do.

"you can use the "Value from file/URI" option of the "Set a Text Value" action to get the contents of a (text) file into a variable"

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Pulling info from ED players journal
« Reply #4 on: April 29, 2020, 07:29:15 PM »
Can you elaborate?

What do you mean by "the current file of the last updated file"? Is the "Set a Text Value" action not working?

Incurable-Rash

  • Full Member
  • ***
  • Posts: 181
Re: Pulling info from ED players journal
« Reply #5 on: April 29, 2020, 11:31:17 PM »
The players journal is always updating and the file name changes. To access the current info I need to have the search look in the current file being updated.
something like

Check Journal *.log
check for new journal
how often to check

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Pulling info from ED players journal
« Reply #6 on: April 30, 2020, 02:14:44 PM »
There are a number of ways to find the latest file in a directory. If you want to do it without manually iterating through all files, you can use a LINQ query.

Examples can be found on Stack Overflow (which is a staple of modern computer programming, however you shouldn't blindly copy anything from anywhere; Look up the methods used and try to gain an understanding of them).


Checking for a new version can be done by comparing the previous file retrieved as latest, to the current file retrieved as latest. If the same file is returned, you can check whether it has been changed using the "File.GetLastWriteTime" method.


How often to check can be determined by an artificial delay in your loop (I.E. using "Thread.Sleep()").



Have you checked whether the data you're looking for isn't already made available by something like EDDI? Unless you have a specific requirement that isn't met, you may be needlessly reinventing the wheel, so to speak.

Incurable-Rash

  • Full Member
  • ***
  • Posts: 181
Re: Pulling info from ED players journal
« Reply #7 on: April 30, 2020, 02:48:43 PM »
Right now I am using a AHK script, that was given to me, to pull the info from the journal and dump into a TXT file, and then VA pulls the info from that file. I was trying to see if I could do it all from inside VA script, similar to what I did with the inline function you helped me with. I am trying to do some of this with no knowledge of what I am doing and using the scripts I am able to acquire as a template to do other things. This is my backward way of learning some of this stuff, but mostly it just confuses me.

Incurable-Rash

  • Full Member
  • ***
  • Posts: 181
Re: Pulling info from ED players journal
« Reply #8 on: June 03, 2020, 11:36:51 AM »
I have been looking for something that could accomplish what I am trying to do. even if it is reinventing the wheel. I was wondering if I am on the right track with this, when altered.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

class Program
    {
        static void Main(string[] args)
        {
            //Provide folder path from which you like to get latest file
string Folder = @"C:\ C:\Users\PcGamer\Saved Games\Frontier Developments\Elite Dangerous\";
            var files = new DirectoryInfo(Folder).GetFiles("Journal*.log");
            string latestfile = "";

            DateTime lastModified = DateTime.MinValue;

            foreach (FileInfo file in files)
            {
                if (file.LastWriteTime > lastModified)
                {
                    lastModified = file.LastWriteTime;
                    latestfile = file.Name;
                }
            }
            //To see the value of latest variable, You can remove both lines
            Console.Write("Latest File Name: "+latestfile);
            Console.ReadLine();
        }
    }
}


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Pulling info from ED players journal
« Reply #9 on: June 03, 2020, 11:58:38 AM »
That could work, if you adapt it to an inline function, yes.

Incurable-Rash

  • Full Member
  • ***
  • Posts: 181
Re: Pulling info from ED players journal
« Reply #10 on: August 27, 2020, 11:29:57 AM »
public class VAInline
{
   enum status : uint
   {
       BalancedPower = 444,
   }
   
   public void main()
   {
      string statusInfo = VA.GetText("statusPips") ?? "";
     
      int pipsSectionStart = statusInfo.IndexOf("\"Pips") + 8;
   
                if (pipsSectionStart == 7)
      {
         VA.WriteToLog("Error getting status pips: '\"Pips:\"' section not found", "red");
         VA.SetText("statusPips", "");
         return;
      }
      int pipsSectionEnd = statusInfo.IndexOf(',', pipsSectionStart);
     
      string pipsNumber = statusInfo.Substring(pipsSectionStart, pipsSectionEnd - pipsSectionStart);
     
      int pipsInt;
      Int32.TryParse(pipsNumber, out pipsInt);
      status pips = (status)pipsInt;
     
      VA.SetText("statusPips", pips.ToString());
   }
}

Once again I am starting over, not sure what I am doing wrong here

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Pulling info from ED players journal
« Reply #11 on: August 27, 2020, 11:47:07 AM »
Starting over with what? Did you intend to post that in this topic?

Incurable-Rash

  • Full Member
  • ***
  • Posts: 181
Re: Pulling info from ED players journal
« Reply #12 on: August 27, 2020, 11:59:53 AM »
It may be the wrong place but it is similar to the topic getting info from a Json file called status. I figured if I could get that far adding in a get the latest Journal,txt file would be my next step. I am trying and not being very successful at this and if I stop I forget all the info about doing this I have learned, an age thing for me long term memory loss, but I keep trying.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Pulling info from ED players journal
« Reply #13 on: August 27, 2020, 12:20:44 PM »
If you want retrieve this information, EDDI can do that for you:

Quote from: https://github.com/EDCD/EDDI/wiki/VoiceAttack-Integration
{DEC:Status system pips} a decimal value indicating the power distributor allocation to systems
{DEC:Status engine pips} a decimal value indicating the power distributor allocation to engines
{DEC:Status weapon pips} a decimal value indicating the power distributor allocation to weapons


Otherwise, if you insist on reinventing every single wheel, you'll need to learn basic programming principles, techniques, and the C# syntax.

Incurable-Rash

  • Full Member
  • ***
  • Posts: 181
Re: Pulling info from ED players journal
« Reply #14 on: August 27, 2020, 08:55:55 PM »
First I have had to many problems with EDDI in the past, so I am not a fan. And thank you for the rest. I am trying not to rely on third party apps. I am using Autohotkey programing to retrieve most of the information I use, but I was hoping to at least make my profile as stand alone as possible, which under the current circumstances seems to be impossible for me.