Display case manager script help

Doesn't work for me. :confused:

They're identical except for the

Code:
void main() {

        print("done");
}
bits.

Where is the .txt file supposed to go? Currently it's in my scripts folder. I'm using a Mac, any possible problems there? The .txt file has been saved in TextWrangler, if that makes a difference. I've tried calling the script both from the gCLI and from the Scripts menu, neither work.
 
Doesn't work for me. :confused:

They're identical except for the

Code:
void main() {

        print("done");
}
bits.

Where is the .txt file supposed to go? Currently it's in my scripts folder. I'm using a Mac, any possible problems there? The .txt file has been saved in TextWrangler, if that makes a difference. I've tried calling the script both from the gCLI and from the Scripts menu, neither work.

Try putting the .txt file in the data folder.
 
Where is the .txt file supposed to go? Currently it's in my scripts folder. I'm using a Mac, any possible problems there? The .txt file has been saved in TextWrangler, if that makes a difference.
I don't know anything about TextWrangler, but if it formats text, then that's your problem.
 
I already tried putting it into the data folder.

It's plain text only, and I've used it with every other script I've ever written, edited or saved for mafia and it's always worked.
 
So here's a question... is there a case-sensitivity problem causing the issue?

Or perhaps the files are inheriting some weird extension causing the script to work improperly?

Do you have problems with other scripts that look at data files?
 
I wondered about case sensitivity, but when I tried playing around with it in various combinations, it didn't seem to make a difference.

About extensions, I don't think so. All the files concerned are set to display their extensions, and they all look correct to me.

No, I use eatdrink for example, and that works just fine.
 
Sorry about the double post, but I thought this should be noticed. I found the problem, it was of course my fault.

I originally had the data file sitting in the scripts folder, but just before I edited the script with the fixes that were posted, I moved it into another folder within the scripts folder (just for tidiness). I was under the impression from the behaviour of other scripts I use that load data files that you could do this. Apparently I was wrong. I'm so sorry for the bother I've caused you all :(.

EDIT: I suspect the misunderstanding about where to put data files came from my eatdrink folder in /kolmafia/scripts which contains the script and data files. However, the kolmafia/data folder also has eatdrink's data files in it. Guess I must have made duplicate copies when I downloaded it.
 
Last edited:
In which way would I have to modify display.ash in order to put other amounts of the specified item into the display case than 'all'. I understand that it would also mean to change the extra elements in the map file. So the question is mainly how do I read out the second 'column'?

Code:
club necklace	t
diamond necklace	t
heart necklace	t
spade necklace	t

So what value would t have to be in the table in order to put ALL items into the DC, and what value would it have to be be to put lets say three or all BUT two into the DC?

Cheers ki77bot
 
You're asking how to get that information into your datafile, not how to make the script do it.

Right now the second column is pretty meaningless, just because the method of reading in a file requires it to have two columns. However, you could change that column to integers. (Make sure you change the definition of list to expect integers.) Then you can use 0 to mean all and anything >0 to be the number to put in and a number <0 to be the amount to not put into the DC. That would be in line with how mafia uses positive and negative numbers for CLI functions.

Code:
club necklace	0
diamond necklace	3
heart necklace	-2
spade necklace	0
Would put all of your club and spades into the DC. Put 3 diamonds into the DC. Put all but 2 hearts into the DC.

You'll just need to change your script to do that.
 
You're asking how to get that information into your datafile, not how to make the script do it.

Hmmm, actually I was asking for both...:eek:

Code:
void main() {
	string [item] list;
	file_to_map("displaycase.txt", list, amount);
	foreach key in list
		if(item_amount(key)>0) 
			put_display( item_amount(amount), key);
			
		print("done");
}

Would it work like this? :confused: It is obvious that i am not used to the concept of maps...

----

edit: just noticed that I have to define 'amount' as an integer as well...
 
Last edited:
I'll explain then.

int [item] list
foreach key in list

The "foreach" will go through each item in the list. key is an item. list[key] will be the integer in the map associated with that item.

You'll want to test list[key] to see if the value is greater than 0, zero, or less than zero. if(list[key] >0) Then take adjust the amount you put into your display case appropriately.
 
Well here's where I'm at. It's a bit of a mess, but with my current knowledge it's the best I could do. Below is a recap of what I want the script to do:

  • Check display case for items not in data file.
  • Add said items to data file.
  • Put all items in data file into DC.
  • Print readout of what was moved.
Note: Data file may include items which are not currently in DC, but which have been added manually.

My description of what it currently does:

  • Saves the contents of your DC to a data file ("DC Data.txt").
  • Prints a readout of what it will move into your DC.
  • Moves items in "DC Data.txt" to your DC.
Problems (that I've noticed):

  • Requires a data file ("all_items.txt") containing every item in the game to compare to your DC before it knows what to save to "DC Data.txt"
  • Unless the script actually moves something when it is run, it will overwrite "DC Data.txt" with a blank version.
  • Currently the script completely overwrites "DC Data.txt" each time it runs, meaning that items have to be in your DC before the script runs, thus defeating the purpose of running the script.
Ideally the script would add items in your DC to "DC Data.txt" (if they are not already there). In other words the file would be, for all intents and purposes, edited rather than overwritten. This would allow for items to be manually, as well as automatically, added to "DC Data.txt"

Any help would be appreciated, but at this point I've reached the limits of my knowledge so it'd be helpful if you could explain (in baby steps) what everything does.
 
Last edited:
I'll look it over more carefully later, but my first comment is that you don't need all_items.txt. Here's a very nice scripting feature for you to use:

PHP:
foreach key in $items[]
   if(display_amount(key)>0) collect [key] = -1;
$items[] is defined as a map of ALL items in the game.

Second comment:
Code:
record display_case_items {
string item_name;
};

display_case_items[item] DC;

Using a record with less than one entry is meaningless. This is more complicated, but essentially the same as:
Code:
string  [item] DC;
Anyway, it should be an int, not a string.
 
Last edited:
Wonderful! Fortunately my copy/pasting for all_items.txt won't be wasted, I intend to use it for a spreadsheet I'm making.

As for your second comment, I understand what you've said (mostly) but as I'm trying to learn here could you tell me when I'd want to use record?

My biggest problem at the moment is how to have items added to "DC Data.txt" rather than having the whole file overwritten. As I said before, that defeats the purpose of running the script. I started trying to do something with two data files, from which the script would know what to put in my DC. One data file could be edited with "new" items to be collected, the other would be a straight copy of my DC after the script had finished running. In this way data from the first "editable" would be transferred to the second "complete" file. But in the end it got too complicated for me and I thought that there must be a better way.

Anyway, here's what I've got so far.
Code:
void main() {
    string [item] list;
    file_to_map("DC Data.txt", list);
        print("Putting...");
    foreach key in list
        if(item_amount(key)>0)
            print(""+key, "blue");
        print("... into display case");    
    file_to_map("DC Data.txt", list);
    foreach key in list
        if(item_amount(key)>0)             
            put_display( item_amount(key), key);

            
        print("DC updated", "green");
}

int [item] collect;

foreach key in $items[]
    if(display_amount(key)>0) collect [key] = -1;  

foreach key in collect {
    if(map_to_file(collect, "DC Data.txt") == false) print("Your DC data failed to save.", "Red");
}

EDIT: Oh and could you explain why it should be a an int rather than a string? Please excuse my ignorance.
 
You could try something like this:

Code:
void main(){
    int [item] dc;
    file_to_map("DC Data.txt", dc);
    
    foreach key in $items[]
        if(display_amount(key) > 0) 
            dc [key] = -1;     
            
    foreach key in get_inventory()
        if(item_amount(key) > 0){
            print("Putting "+item_amount(key)+" "+key+" into display case...", "blue");
            put_display(item_amount(key), key);
        }
        
    if(map_to_file(dc, "DC Data.txt") == false) 
           print("Your DC data failed to save.", "red");
            
    print("DC updated", "green");
}
 
Back
Top