Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] - Export Statistics to CSV #62

Open
leha-sys opened this issue Nov 25, 2020 · 6 comments
Open

[Feature Request] - Export Statistics to CSV #62

leha-sys opened this issue Nov 25, 2020 · 6 comments

Comments

@leha-sys
Copy link

I'd like to suggest an 'Export to CSV' function.
I think that many users would find this quite useful.

@mrSkortch
Copy link
Owner

csv might be a bit tricky simply due to how the stats are organized. Would it be the whole stats file as one big csv, a file per player, or even just a file for a player's specific aircraft?

The way I see it, it'd have to be built similar to how the in game stats display works by getting a list of all aircraft, weapons, kills, etc and then having to populate the csv in that format. So you'd have something like a list of general stats across the horizontal part of the spreadsheet and the vast majority would list a stat of 0 or just be missing. There would be a ton of entries though, especially if more detailed stats are enabled that keeps track of individual object types killed by weapons. Not to mention the formatting would likely change between exports.

@leha-sys
Copy link
Author

leha-sys commented Dec 1, 2020

I might be wrong but in my opinion the whole stats file would be easy to export and use.

@mrSkortch
Copy link
Owner

The export would have to be the same basic code regardless, its just bigger in scale depending on the number of stats. Its not impossible by any means, just requires the time to sit down and code that, and honestly the json export has priority, which is much simpler.

The older stats format wouldn't be that bad, its the newer and more detailed stats that would be annoying. Just a sample of what I mean. These are the "middle ground" level of detail for the stats for two aircraft for the same player as saved in the stats file.

            ["A-10C"] = 
            {
                ["total"] = 32625.262,
                ["weapons"] = 
                {
                    ["CBU-97/CBU-105 SFW"] = 
                    {
                        ["hit"] = 0,
                        ["kills"] = 9,
                        ["shot"] = 15,
                        ["numHits"] = 10,
                    }, -- end of ["CBU-97/CBU-105 SFW"]
                    ["GBU-38"] = 
                    {
                        ["hit"] = 0,
                        ["kills"] = 3,
                        ["shot"] = 4,
                        ["numHits"] = 3,
                    }, -- end of ["GBU-38"]
                    ["AGM-65D"] = 
                    {
                        ["hit"] = 0,
                        ["kills"] = 4,
                        ["shot"] = 8,
                        ["numHits"] = 4,
                    }, -- end of ["AGM-65D"]
                    ["HYDRA-70 M151"] = 
                    {
                        ["hit"] = 0,
                        ["kills"] = 0,
                        ["shot"] = 7,
                        ["numHits"] = 0,
                    }, -- end of ["HYDRA-70 M151"]
                    ["kamikaze"] = 
                    {
                        ["numHits"] = 1,
                        ["kills"] = 0,
                        ["shot"] = 0,
                        ["hit"] = 0,
                    }, -- end of ["kamikaze"]
                }, -- end of ["weapons"]
                ["inAir"] = 17573.761,
                ["actions"] = 
                {
                    ["losses"] = 
                    {
                        ["pilotDeath"] = 1,
                        ["crash"] = 1,
                        ["eject"] = 0,
                    }, -- end of ["losses"]
                }, -- end of ["actions"]
                ["kills"] = 
                {
                    ["Ground Units"] = 
                    {
                        ["APCs"] = 14,
                        ["total"] = 39,
                        ["Unarmored"] = 25,
                    }, -- end of ["Ground Units"]
                }, -- end of ["kills"]
            }, -- end of ["A-10C"]
            ["JF-17"] = 
            {
                ["total"] = 55277.605,
                ["kills"] = 
                {
                    ["Ships"] = 
                    {
                        ["Unarmed"] = 7,
                        ["total"] = 7,
                    }, -- end of ["Ships"]
                    ["Ground Units"] = 
                    {
                        ["AAA"] = 3,
                        ["SAM"] = 1,
                        ["Unarmored"] = 12,
                        ["APCs"] = 23,
                        ["Tanks"] = 2,
                        ["total"] = 41,
                    }, -- end of ["Ground Units"]
                    ["Planes"] = 
                    {
                        ["Attack"] = 2,
                        ["total"] = 2,
                    }, -- end of ["Planes"]
                }, -- end of ["kills"]
                ["inAir"] = 36076.493,
                ["actions"] = 
                {
                    ["losses"] = 
                    {
                        ["pilotDeath"] = 2,
                        ["crash"] = 2,
                        ["eject"] = 1,
                    }, -- end of ["losses"]
                }, -- end of ["actions"]
                ["weapons"] = 
                {
                    ["C-802AK"] = 
                    {
                        ["hit"] = 0,
                        ["kills"] = 2,
                        ["shot"] = 6,
                        ["numHits"] = 2,
                    }, -- end of ["C-802AK"]
                    ["C-701IR"] = 
                    {
                        ["numHits"] = 4,
                        ["kills"] = 3,
                        ["shot"] = 7,
                        ["hit"] = 0,
                    }, -- end of ["C-701IR"]
                    ["BRM-1 90MM"] = 
                    {
                        ["numHits"] = 18,
                        ["kills"] = 14,
                        ["shot"] = 55,
                        ["hit"] = 0,
                    }, -- end of ["BRM-1 90MM"]
                    ["SD-10"] = 
                    {
                        ["numHits"] = 0,
                        ["kills"] = 0,
                        ["shot"] = 1,
                        ["hit"] = 0,
                    }, -- end of ["SD-10"]
                    ["CM-802AKG"] = 
                    {
                        ["hit"] = 0,
                        ["kills"] = 4,
                        ["shot"] = 10,
                        ["numHits"] = 4,
                    }, -- end of ["CM-802AKG"]
                    ["kamikaze"] = 
                    {
                        ["numHits"] = 1,
                        ["kills"] = 0,
                        ["shot"] = 0,
                        ["hit"] = 0,
                    }, -- end of ["kamikaze"]
                    ["BRM-1_90MM"] = 
                    {
                        ["hit"] = 0,
                        ["kills"] = 2,
                        ["shot"] = 5,
                        ["numHits"] = 2,
                    }, -- end of ["BRM-1_90MM"]
                    ["GSh-2-23"] = 
                    {
                        ["kills"] = 2,
                        ["shot"] = 214,
                        ["hit"] = 0,
                        ["gun"] = true,
                        ["numHits"] = 97,
                    }, -- end of ["GSh-2-23"]
                    ["GBU-16"] = 
                    {
                        ["numHits"] = 2,
                        ["kills"] = 1,
                        ["shot"] = 3,
                        ["hit"] = 0,
                    }, -- end of ["GBU-16"]
                    ["LD-10"] = 
                    {
                        ["hit"] = 0,
                        ["kills"] = 1,
                        ["shot"] = 9,
                        ["numHits"] = 1,
                    }, -- end of ["LD-10"]
                    ["GB-6-SFW"] = 
                    {
                        ["hit"] = 0,
                        ["kills"] = 10,
                        ["shot"] = 8,
                        ["numHits"] = 13,
                    }, -- end of ["GB-6-SFW"]
                    ["LS-6-500"] = 
                    {
                        ["hit"] = 0,
                        ["kills"] = 9,
                        ["shot"] = 3,
                        ["numHits"] = 9,
                    }, -- end of ["LS-6-500"]
                    ["PL-5EII"] = 
                    {
                        ["hit"] = 0,
                        ["kills"] = 2,
                        ["shot"] = 2,
                        ["numHits"] = 4,
                    }, -- end of ["PL-5EII"]
                }, -- end of ["weapons"]
            }, -- end of ["JF-17"]

So the csv would have to be something like below where "x" is some value stored in the stats and 0 would be anything missing. Including more of the specific stats would just add more and more entries. With hundreds of objects in the game and hundreds of weapons to use it should be evident how large the stats would become. Again, if it was something limited to the in game display then by all means it wouldn't be that bad to created, but all the details it becomes a bit crazy.

ACName, total, inAir, kills Ground Units, Kills Planes, Kills, Ships, Weapons GBU-38, Weapons ... and on and on
A-10C, x, x, x, 0, 0, x, x, x, x, 0, 0
JF-17, x, x, x, x, x, 0, 0, 0, 0, x, x 

@leha-sys
Copy link
Author

leha-sys commented Dec 1, 2020

Yes, I see it becomes a bit more than simple.
Maybe we can start with short stats?
After looking at the code for a while I thought about using
local function createSimpleStats(ucid, mode) for the first step to export to csv or json.
I figured that would be an easy start instead of dealing with full stats.

I haven't had a good knowledge of the lua to not to break anything,
but I could take part in testing.

@mrSkortch
Copy link
Owner

Piggy backing onto the in game display functions was pretty much my line of thinking for getting it to work anyway. I've been focused on mission editor scripting stuff lately, so I've been spending my time on that. If I get some time to add stuff to slmod I might do some tests for this, but no promises though.

@leha-sys
Copy link
Author

leha-sys commented Dec 1, 2020

No problem. We'll wait for any update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants