Inventory Logger

Des80

Member
I know how to map my inventory to a file that brings the Name of the item and how any of that item is there. Is there anyway to have it also give me the item type ?
 

Bale

Minion
string item_type( item )

How you need to use that function will depend on what you want to do with it, but I'm sure it can serve your needs.
 

Des80

Member
Well Im trying to keep a list of all of my inventory on a separate Spreadsheet. It is easy enough to map the items to a Folder

void main()
{

batch_open();
int[item] inventory = get_inventory() ;
map_to_file( inventory , "ItemList.txt" ) ;
batch_close();

}

I Know the code is sloppy but it works and I'll try to add a few variables and see if I can't get the item type to work as well then thank you.
 

Theraze

Active member
If you want it to have more variables, you'll need to define your map. something like:
Code:
record {
   int amount;
   string type;
} [item] inventoryFile;

foreach it,count in get_inventory() {
   inventoryFile[it].amount = count;
   inventoryFile[it].type = it.item_type();
}

map_to_file(inventoryFile, "ItemList.txt");
 
Last edited by a moderator:

Theraze

Active member
If you want it to have more variables, you'll need to define your map. something like:
Code:
record {
   int amount;
   string type;
} [item] inventoryFile;

foreach it,count in get_inventory() {
   inventoryFile[it].amount = count;
   inventoryFile[it].type = it.item_type();
}

map_to_file(inventoryFile, "ItemList.txt");

For curiosity's sake, what did I screw up, Bale? It validated the code fine, but since you edited my post, I'm assuming that I messed something up. :)
 

Bale

Minion
For curiosity's sake, what did I screw up, Bale? It validated the code fine, but since you edited my post, I'm assuming that I messed something up. :)

You didn't mess anything up, but for some reason you used absolutely no formatting in your code. I added the indentation and blank lines between sections so that it could be more easily read. I hope that didn't offend, but since Des80 is obviously new to this I wanted it to be easier for him to understand.
 

Theraze

Active member
Not a problem. I wrote it freehand on the forum rather than using a text editor, so... no tabs. I was mostly just wondering if anything was actually WRONG as opposed to just unpretty. :) Thanks for the clarification. Heh.
 

Bale

Minion
Thanks for the clarification. Heh.

Incidentally, if you click the words "Last edited by" on your post you can see the differences in the revisions. In this particular case I only changed whitespace and whitespace isn't displayed so you can puzzle at the fact that I appear to change nothing in the lines that it is telling you have been changed. (You cannot see editing revisions on someone else's post.)
 

lostcalpolydude

Developer
Staff member
In this particular case I only changed whitespace and whitespace isn't displayed so you can puzzle at the fact that I appear to change nothing in the lines that it is telling you have been changed.

That's what I did for a few minutes before giving up and trusting that you would answer at some point.
 

Theraze

Active member
Thanks! I hadn't actually noticed its wiki-comparison-like capabilities before, but then was briefly bemused by the comparison before your comment about whitespace compression. Why do sites do that... *sighs* [rant]If you're going to list it as different, show me the whole stupid thing - don't mangle the comparison first.[/rant]
 
Top