1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

A geeky tool for measuring eco

Discussion in 'General Economy Discussion' started by San, Apr 26, 2015.

  1. San

    San Active Member

    Messages:
    918
    Likes Received:
    201
    Trophy Points:
    43
    You want to measure your expenses and returns after a hunting, mining or crafting run to learn where there is potential for improvement? Or how loot is trending over time? Or discover if specific things drop typically from a certain mob or activity? Or just know how much you lost on that space trip or PVP battle or what it really cost to train that stubborn pet up a level? You know how to crunch the numbers of course, if only collecting the input for it wasn't so tedious. Now this part can be helped!

    What this tool does is simply showing the difference between two inventory snapshots from the data available on your Entropia Universe account page on the web. Here is how to use it:
    • Before going on a run, load the tool in your web browser
    • Use the link provided to log into your EU account page and see your inventory (ideally, use a new browser window rather than a tab, easier to switch back and forth with Alt-Tab)
    • Now take a 'snapshot' of your inventory by pressing Ctrl-A (select all text) and Ctrl-C (copy to clipboard)
    • Go back to the tool and paste (Ctrl-V) the clipboard content into the field under 'Before' -- no editing required, the program takes care of it all; to prevent data loss in case the computer crashes, you may want to store a backup using a text editor
    • Go play!
    • After the run, take another snapshot in the same way and paste it into the field under 'After'
    • Click 'Calculate difference'
    • The result will show in the third text field below, from where you can pick it up again via clipboard
    • Optionally you may choose one of three output formats, depending on what you want to do with the result:
      • 'Forum table' wraps everything in BBCode for posting in a forum such as this;
      • 'Spreadsheet' formats it with tabs in between and formulas placed instead of pre-calculated results for processing with a spreadsheet program; if you're presented with the data import dialog upon pasting, select tabs as field separator; only cell formatting of percentage and currency fields has to be done manually.
        Note: If you want to add to a sheet which already contains data, create a temporary fresh sheet first, paste into the top left corner there, then mark the range and copy that into clipboard again before pasting it at its final place. This way the cell addresses get transposed correctly. (Thanks Michael for the hint!)
      • 'Plain text' finally produces a raw, but very readable format with spaces filled in so that everything lines up nicely. Store for posterity or watch, weep and wipe.

    The tool requires no installation at all, other than storing the file somewhere where you can load it into your web browser. It consists of nothing but a simple, self-contained HTML page with JavaScript embedded. No outside resources are required to load. Your data is not sent anywhere for processing, all is done locally. Anyone savvy may check the source that nothing fishy is going on.

    A few points to be aware of when working with your Entropia Universe web inventory:
    • Decayed items may not show their actual value immediately; you may need to logout of the game and/or renew your login to the website and/or simply wait a little; I usually double check on the main weapon I just used, when the correct value shows up then everything else like armour etc. should also be updated
    • The following items are not included in your account inventory: Your PED Card balance, vehicles and pets while spawned in-world, oil tanked in vehicles, and mounted enhancers. If you need to include any of these items into your calculation, e.g. to account for repairs underway or travel expenses or usage of enhancers, you need to make sure they are visible just before taking every snapshot, so: Unload your PED card (coins will show up in inventory), pick up your vehicles and extract their oil, detach enhancers and dismiss pets.
    All this reads a lot more complicated than it actually is. With a little bit of practice you can do all of this in under a minute. So much easier than having to rummage through everything just to collect a few numbers!

    So without further ado, here is the code (choose 'download' or 'raw', then save with '.html' as filename ending):

    http://pastebin.com/VGjY6EwW

    Edit: The file is now also hosted at this address: http://sandals-eu.neocities.org/inv.html
    It is the same as above, it does not send any of your data to the server. You can download from there, too (Ctrl-S from your browser), or use online.

    Cheers and good luck!

    PS- Legalese: none. Copyright: none. License: none. Warranty: none! Lawyers are treated the same as space pirates – either ignored or shot.
     
    • Like Like x 7
    • Useful Useful x 4
    • Informative Informative x 1
    Last edited: Aug 18, 2016
  2. San

    San Active Member

    Messages:
    918
    Likes Received:
    201
    Trophy Points:
    43
    Placing a backup here just in case anything ever happens to Pastebin:
    File: diff2.html
    Code:
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>Entropia Universe Inventory Diff Tool</title>
    <script>
    
    function fstr (s, n) {
        return s + Array(n - s.length).join(' ');
    }
    
    function fnumu (x, m, n) {
        var s = x.toFixed(m);
        if (typeof n == 'undefined') return s;
        return Array(n + 2 - s.length).join(' ') + s;
    }
    
    function fnum (x, m, n) {
        var s = ((x > 0) ? '+' : '') + x.toFixed(m);
        if (typeof n == 'undefined') return s;
        return Array(n + 2 - s.length).join(' ') + s;
    }
    
    function fline (t, q, v, f) {
    	if (f == 'f') return "[tr][td]" + t + "[/td][td][right]" + fnum(q, 0) + "[/right][/td][td][right]" + fnum(v, 2) + " PED[/right][/td][/tr]\n";
    	if (f == 's') return t + "\t" + q + "\t" + fnum(v, 2) + "\n";
    	return fstr(t, 50) + fnum(q, 0, 7) + fnum(v, 2, 9) + " PED\n";
    }
    
    function fcsum (t, r, f, n1, n2) {
    	if (f == 'f') return "[tr][td]" + t + "[/td][td].[/td][td][/td][td][right]" + fnum(r, 2) + " PED[/right][/td][/tr]\n";
    	if (f == 't') return fstr(t, 58) + fnum(r, 2, 9) + " PED\n";
    	return t + "\t\t=SUM(C" + n1 + ":C" + n2 + ")\n";
    }
    
    function ftsum (t, p, r, f, n1, n2) {
    	if (f == 'f') return "[tr][td]" + t + "[/td][td][right]" + fnumu(p, 2) + "%[/right][/td][td][right]" + fnum(r, 2) + " PED[/right][/td][/tr]\n";
    	if (f == 't') return fstr(t, 50) + fnumu(p, 2, 6) + "%" + fnum(r, 2, 9) + " PED\n";
    	return t + "\t" + fnumu(p, 2) + "%\t" + fnum(r, 2) + "\n";
    }
    
    function fhead (f) {
    	if (f == 'f') return "[table]\n";
    	return "";
    }
    
    function ffoot (r, p, f, n1, n2) {
    	if (f == 's') return "Result\t=ABS(C" + n2 + "/C" + n1 + ")\t=C" + n1 + "+C" + n2 + "\n";
    	return ftsum("Result", p, r, f) + ((f == 'f') ? "[/table]" : "");
    }
    
    function fempty (f) {
    	if (f == 'f') return "[tr][td].[/td][td].[/td][td].[/td][/tr]\n";
    	return "\n";
    }
    
    function cdiff () {
        var diff = [];
        var re = /^\d+\s+(.*?)\s+(\d+)\s+(\d+\.\d+)\s+PED/gm;
        var e;
        while ((e = re.exec(document.frm.after.value)) !== null) {
            if (diff[e[1]]) {
                diff[e[1]].q += parseInt(e[2]);
                diff[e[1]].v += parseFloat(e[3]);
            }
            else diff[e[1]] = {q: parseInt(e[2]), v: parseFloat(e[3])};
        }
        while ((e = re.exec(document.frm.before.value)) !== null) {
            if (diff[e[1]]) {
                diff[e[1]].q -= parseInt(e[2]);
                diff[e[1]].v -= parseFloat(e[3]);
            }
            else diff[e[1]] = {q: -parseInt(e[2]), v: -parseFloat(e[3])};
        }
        var c = d = '';
        var g = h = n1 = n2 = 0;
        var f = document.frm.format.value;
        for (var p in diff) {
            if (!diff.hasOwnProperty(p)) continue;
            if (Math.abs(diff[p].q) == 0 && Math.abs(diff[p].v) < 0.01) continue;
            if (diff[p].q <= 0) {
    	        h += diff[p].v;
    	        c += fline(p, diff[p].q, diff[p].v, f);
    	        n1++;
            }
            else {
    	        g += diff[p].v;
    	        d += fline(p, diff[p].q, diff[p].v, f);
    	        n2++;
            }
        }
        c += fcsum('Total expenses', h, f, 1, n1) + fempty(f);
    	d += fcsum('Total returns', g, f, n1+3, n1+2+n2) + fempty(f);
    	document.frm.result.value = fhead(f) + c + d + ffoot(g + h, Math.abs(g / h) * 100, f, n1+1, n1+2+n2+1);
        return false;
    }
    </script>
    </head>
    <body>
    <h2>Entropia Universe Inventory Diff Tool</h2>
    <p><a href="https://account.entropiauniverse.com/account/my-account/my-items/" target="_blank">My items</a> &nbsp; / &nbsp;
    <a href="http://arkadiaforum.com/threads/a-geeky-tool-for-measuring-eco.12205/" target="_blank">Instructions</a></p>
    <form name="frm" method="post" onsubmit="return cdiff()">
    <p></p>Before:<br/><textarea name="before" cols="100" rows="10"></textarea></p>
    <p></p>After:<br/><textarea name="after" cols="100" rows="10"></textarea></p>
    <p><input type="submit" value="Calculate difference"></p>
    <p></p>Result (format as
    <input type="radio" name="format" value="f" onchange="return this.form.result.value.length && cdiff()"> forum table &nbsp;/
    <input type="radio" name="format" value="s" onchange="return this.form.result.value.length && cdiff()"> spreadsheet &nbsp;/
    <input type="radio" name="format" value="t" checked="checked" onchange="return this.form.result.value.length && cdiff()"> plain text):<br/>
    <textarea name="result" cols="100" rows="10"></textarea></p>
    </form>
    <p><small>Author: Sandal San Tolk</small></p>
    </body>
    </html>

    ========
    Old version in Perl in case someone is still interested. Very basic output with no bells & whistles:
    Output preview:
    Code:
    Energy Matter Residue                                   +8     +0.08
    Imperium Cube Component 2                               +3     +0.30
    Metal Residue                                          +10     +0.10
    Yellow Crystal                                         -75     -0.75
    Zorn Star Ore                                          -66     -0.66
    Total +/- TT value                                             -0.93
    Download: http://pastebin.com/nDxJskcS
    Code:
    #!/usr/bin/perl
    
    #use Data::Dumper;
    
    $f1 = './1.txt';
    $f2 = './2.txt';
    
    $inv = {};
    
    open(my $fh, $f2) or die "$!: $f2\n";
    while(<$fh>) {
        s/\s+$//s;
        my ($i, $n, $q, $v, $c) = split /\t/, $_;
        next unless $i > 0 && $n ne '';
        $inv->{$n}->{q} += $q;
        $inv->{$n}->{v} += $v;
    }
    close $fh;
    
    open(my $fh, $f1) or die "$!: $f1\n";
    while(<$fh>) {
        s/\s+$//s;
        my ($i, $n, $q, $v, $c) = split /\t/, $_;
        next unless $i > 0 && $n ne '';
        $inv->{$n}->{q} -= $q;
        $inv->{$n}->{v} -= $v;
    }
    close $fh;
    
    $t = 0;
    foreach $k (sort keys %$inv) {
        if (abs($inv->{$k}->{v}) < 0.01) {
            delete $inv->{$k};
        }
        else {
            printf "%-50s %+7d %+9.2f\n", $k, $inv->{$k}->{q}, $inv->{$k}->{v};
            $t += $inv->{$k}->{v};
        }
    }
    printf "%-58s %+9.2f\n", 'Total +/- TT value', $t;
    
    #print Dumper($inv);
     
    • Useful Useful x 1
    Last edited: May 14, 2015
  3. San

    San Active Member

    Messages:
    918
    Likes Received:
    201
    Trophy Points:
    43
    I just noticed that it takes some time until the account page on the EU website reflects the correct values for decayed items, apparently about 1 hour. Confusing is that some items get updated immediately, while others aren't. So you have to wait that long with the second snapshot after you're done, and make sure to double check against your in-game inventory.
     
  4. Nikto

    Nikto Active Member

    Messages:
    312
    Likes Received:
    42
    Trophy Points:
    28
    I wrote similar tool (but more advanced) for myself in 2006 and using it since that time (Perl as well :) ). And it was always that way. When you repair something — it TT value updated immediately, but when you decay — it don't. To force update you need logout from the game and it will be updated immediately after that. A bit annoying, but fine to count results after run.
    So I'm logging in game, repair/buying all I need in TT, save inventory, make my run, logout, save inventory again.
     
    • Informative Informative x 1
  5. San

    San Active Member

    Messages:
    918
    Likes Received:
    201
    Trophy Points:
    43
    New update available! Post(s) edited above.

    Two more hints: Oil in vehicles is not shown in the website inventory and therefore can't be captured here. If you want to account for it in the total cost of doing a mission, remove it each time before taking a shapshot, then the difference can be recorded. I assume (haven't tried yet) it can work the same way with your PEDs: When removed from the card, the coins should show up in the listing. Now you should be able to account for repairs, purchases and deposits in between two snapshots.
     
  6. WhiningSkeptic

    WhiningSkeptic Active Member

    Messages:
    291
    Likes Received:
    55
    Trophy Points:
    28
    Interesting :)

    Any known limitations? I got 6k+ items, could that be a problem?
     
  7. San

    San Active Member

    Messages:
    918
    Likes Received:
    201
    Trophy Points:
    43
    Please do try and let me know if there is a problem, I got only 800+ so I don't know. Of course I didn't set the maxlength attribute in textarea, if there is any limitation it would be browser-internal. Not sure what to do if there is indeed a ceiling, guess this would call for the Perl version then.
     
  8. Nikto

    Nikto Active Member

    Messages:
    312
    Likes Received:
    42
    Trophy Points:
    28
    Same with inserted Enhancers, btw.

    Instead of taking out PED's/PEC's, Oil and Enhancers it could be faster (at least I'm doing it that way with PED's) manually type that (i.e. my script "asking" me to enter those values).

    IMHO all those items should work same way as containers (I asked that on PCF years ago, when they added Tiers and Vehicles, but they didn't fixed that) so it would show Oil and Enhancers as it's content.

    N.B. If you leave spawned Vehicles/Pets when saving inventory, it will not be captured as well.
     
    • Informative Informative x 1
  9. San

    San Active Member

    Messages:
    918
    Likes Received:
    201
    Trophy Points:
    43
    I should probably retire the Perl version as outmoded and just confusing this thread. Or is somebody actually using it and would like it updated?
     
  10. wournos

    wournos Active Member

    Messages:
    647
    Likes Received:
    126
    Trophy Points:
    43
    You could keep both in OP and note that one version is not being worked on but the other is. I personally don't use either scipt because I can't (Mac user) and also don't need this particular task done, but I give you a huge :thumbsup: for your effort and geekyness. :biggrin:
     
  11. San

    San Active Member

    Messages:
    918
    Likes Received:
    201
    Trophy Points:
    43
    Thanks :laugh:
    Of course you can use both on a Mac, even easier than on Windows. Perl needs a bit of knowledge to deploy, no harm if you're not into this usually. The second one runs as a web page inside any standard browser on any system. You just store it wherever, e.g. on the desktop, and then simply load it with your browser; Ctrl-O opens a local file in most browsers, or double click (single on Mac afaik, don't have one) should also work since html files are usually associated correctly. I could have hosted it somewhere, but I also wanted to demonstrate that you can be sure I'm absolutely not interested in your data, which doesn't have to get sent anywhere for processing this way.
     
  12. wournos

    wournos Active Member

    Messages:
    647
    Likes Received:
    126
    Trophy Points:
    43
    Ah cool. To be honest I saw this yesterday and didn't try because it said Linux and Windows, and I don't run either (yet) on my Mac. I'll try it just for kicks. :)
    I have some programming experience but not with Perl or Javascript. I'm more into PHP with some experience in Java (been a long time since I used Java though).
     
  13. San

    San Active Member

    Messages:
    918
    Likes Received:
    201
    Trophy Points:
    43
    Ah sorry about that, we never think of the Mac crowd :whistling: But essentially its OS is a Linux derivate since the complete revamp a couple years ago. If you've ever done more than point and click you probably know that.

    Hopefully by tonight I have an update ready and, most importantly, get this thread tidied up. Admit it's become a little confusing.
     
  14. San

    San Active Member

    Messages:
    918
    Likes Received:
    201
    Trophy Points:
    43
    Update done, OP edited. :bump:
     
  15. Michael

    Michael Member

    Messages:
    43
    Likes Received:
    12
    Trophy Points:
    8
    I just want to say Thanks for this awesome tool :banana: I am a new player and I was spending way too much time trying to figure out a spreadsheet to figure my run P/L (with loot) Now I can just go play and figure the overall stuff later. If I can ever figure out spreadsheets :stats:
     
  16. Hideo

    Hideo Active Member

    Messages:
    535
    Likes Received:
    142
    Trophy Points:
    43
    nice tool you made there. :banana:

    used to do this with the inventory calc at entropiabay, but this is sadly gone...

    for testing i used a inv snapshot from october 2012 and one from early may 2015:
    result is i earned an astonishing amount of 17574 nova fragments. :biggrin2: yay!!
    but actually the cool thing is:
    Total returns +1801.12 PED Result 376.44% :banana::cowboy:
     
    Last edited: May 15, 2015
  17. Michael

    Michael Member

    Messages:
    43
    Likes Received:
    12
    Trophy Points:
    8
    So if the market get's flooded we will know where it came from :p
     
  18. Sub-Zero

    Sub-Zero Member

    Messages:
    109
    Likes Received:
    10
    Trophy Points:
    18
    Have to say this tool is awesome especially for lazy peeps like me. So thanks for that! :)

    Just a question how does one import this to excel 2013 (if it even is possible?).
     
  19. San

    San Active Member

    Messages:
    918
    Likes Received:
    201
    Trophy Points:
    43
    I don't have Excel here to test it, only LibreOffice. But from what I read, Excel should be able to import it. Would be great if someone could try it out and let me know if something doesn't work as expected.

    What you do is simply copy the contents of the box into your clipboard and then paste it into a spreadsheet. It should open a dialog with some settings for data import, the same you get when opening a .csv or plain text file for pulling into a spreadsheet. Choose 'tab' as field separator, if it's not preselected.

    Thanks for the kind words everyone!
     
    • Informative Informative x 1
  20. Michael

    Michael Member

    Messages:
    43
    Likes Received:
    12
    Trophy Points:
    8
    Just paste it where you want it then use "Text to Columns" to tidy it up. There are youtube video's, it is really easy to do. I just use the plain text option since the math is already done. You can always manipulate it later in excel. :)

    I have Excel 2010 and no dialog box is presented when pasting into the program. Pretty sure that is true in all versions, you have to bring up a tool to manipulate if you want to. Also this is from the Microsoft support site .

    "If you copy data from another program and paste it into Microsoft Excel, Excel may condense several columns of data to a single column. You can use the Text To Columns command on the Data menu to put each record in a separate column.

    This only takes a few seconds and tidy's it up nicely. Excel see's it as fixed width but I am pasting plain text not sure if you have that as tab separated, if you do then excel strips them when pasted in.

    Once again thank you San :biggrin2:
     
    • Informative Informative x 1

Share This Page