Display case manager script help

Banana Lord

Member
I'm trying to write a script to sort out my display case, but the only solution I've found is incredibly tedious and time consuming. I was hoping that it might be possible to do the same thing, but with much less work and much more functionality. Unfortunately such a script is well beyond my ability so I was hoping a few people could point me in the right direction. Below I have outlined what I want the script to do.


  • Compare a data file to my DC, if it finds any items in my DC that aren't in the data file then add them to it.
  • Move all items in the data file to my DC.
Additional functionality:

  • Ability to specify conditions (ie: my level below 14) for specific items to be moved to display case, but still have said items added to the data file if they are not already there.
A sample from my current script to give you an idea of where I'm at:
Code:
if(item_amount($item[pernicious cudgel])>0) cli_execute("display put * pernicious cudgel");
I pretty much have no idea where to start, on top of that I don't know how to use/create/update data file. Absolutely any assistance would be much appreciated
 

Bale

Minion
PHP:
string [item] list;
file_to_map("displaycase.txt", list);
foreach key in list
   if(item_amount(key)>0)
     put_display( item_amount(item_amount(key), key));
That's not everything you asked for, but it should give you some good ideas about how to handle the rest. Another useful command is display_amount(item)
 
Last edited:

Banana Lord

Member
Thanks! I'll have a play with that and see where I get. If I do get this off the ground would there be a way to have OCD add things from the data file to save?
 

Banana Lord

Member
OK, well I've spent forever trying to work out what to put in place of "item", but no luck. So would you mind pointing out what incredibly obvious thing I've missed so I can feel embarrassed and get back to scratching my head over this script? :eek:
 

Spiny

Member
OK, well I've spent forever trying to work out what to put in place of "item", but no luck. So would you mind pointing out what incredibly obvious thing I've missed so I can feel embarrassed and get back to scratching my head over this script? :eek:

If I understand the code blip Bale posted above, it's a straight forward copy and paste. The concept is that you first create a map file called displaycase.txt which is just a list of names of items that you want in your display case, then run this bit of code which will put any of the items that you have from that list into your display case. It's an all or nothing bit of code though. If the item is in your displaycase.txt data file, it will be considered and if you have more than 0 the item will put however many you have into the DC.
 
Last edited:

Banana Lord

Member
If I understand the code blip Bale posted above, it's a straight forward copy and paste. The concept is that you first create a map file called displaycase.txt which is just a list of names of items that you want in your display case, then run this bit of code which will put any of the items that you have from that list into your display case. It's an all or nothing bit of code though. If the item is in your displaycase.txt data file, it will be considered and if you have more than 0 the item will put however many you have into the DC.

I've tried everything I could think of, but I'm completely stuck. Would you mind explaining that again? I did as you said, but I end up with "Function 'item_amount( int, item )' undefined ()" when I run the script.
 

Bale

Minion
You need to do this in a .ash file. If the file ends with .txt, mafia will try to parse it as if it was CLI.
 

Alhifar

Member
Actually, this line:
Code:
put_display( item_amount(item_amount(key), key));
should be:
Code:
put_display( item_amount(key), key);
 

Bale

Minion
Thank you. It should be noted that I didn't test any of that code since I only intended it to be used to convey some ideas for how to handle the problem.
 

Banana Lord

Member
You need to do this in a .ash file. If the file ends with .txt, mafia will try to parse it as if it was CLI.

Were you referring to the data file or to the script file? I've tried every combination of both and still have no success.

Thanks Alhifar!
 

Banana Lord

Member
script file needs to be .ash while data file should be .txt

That's what I initially assumed, but when I run "tester.ash" with the text file "displaycase.txt" in the scripts folder nothing happens.

Incidentally, is there any difference between running a .ash file and a .txt file with the contents in <inline-ash-script>?
 

Banana Lord

Member
Ah, thanks.

So why is it that I can't get the script to do anything?

Once again I should thank you for your help, I'm looking forward to the KoLMafia wiki being finished so I don't have to keep bothering you!
 

Banana Lord

Member
Display Case.ash
Code:
string [item] list;
file_to_map("displaycase.txt", list);
foreach key in list
    if(item_amount(key)>0) 
        put_display( item_amount(key), key)
displaycase.txt
Code:
anti-anti-antidote
bar whip

Obviously these items are only here to test.
 

Bale

Minion
You don't have a semi-colon at the end of put_display( item_amount(key), key). That might have been a copy-paste error which is only one reason why I said "attach".

Anyway, the problem is that the list isn't being fully loaded. I really don't know how to fix that other than to say you'll need to format displaycase.txt like this:


Code:
anti-anti-antidote	t
bar whip	t
Note those are tabs between the item and the extra element.
 

Banana Lord

Member
Ah, it was a copy paste error, but it occurred when I transferred the script from "tester.ash" to "Display Case.ash".

Even with the semi-colon added and the .txt file formatted as you posted, nothing happens.
 
Top