PullCrap! A script to buy stuff before ascension, and pull it after.

dj_d

Member
PullCrap 1.0.0

Stockpile it, then use it. Never waste a pull again.


This set of files does two things. First, it shops for all the stuff you need for your ascension (BuyCrap.ash). Then, every day, it pulls the bits you need most, so you never waste pulls at the end of the day (PullCrap.ash). The fun part is that both scripts use the same data file (Crap.txt, natch), so you only have to figure out what you want once.

To use it, put everything in your mafia directory, and edit crap.txt, preferably in a spreadsheet like Excel. The first column is the "priority"; this determines the order you'll pull things. The next column is the item name. NO PLURALS! The next column is the # you want pulled (e.g. 3 Mr. Accessories). The last column is trickiest.
  • Use "dayone" for stuff you want pulled ASAP.
  • Use "10" (or another number) to try to pull it if you're less than level 10, but ignore it if you pass level 10 (even if you didn't pull it).
  • Use "0" to never pull the item automatically. BuyCrap will buy it, but PullCrap will ignore it. Useful for stuff like the ores, where you don't know which you'll need.
Now the hard part's done! Simply run PullCrap.ash at logout, and BuyCrap.ash before you ascend. See this thread:
http://kolmafia.us/index.php/topic,2048.0.html
for lots more tips, including a far more comprehensive list of items.

Thanks to degrassi for the versioning script!

Version 0.91
shazbot's elimination of the dependency on ver.ash and replacement with a dependency on zlib.ash.

Version 1.0.0
Cleaned up version checking to work with zLib r27 and newer.
 

Attachments

  • Crap.txt
    1.5 KB · Views: 645
  • PullCrap.ash
    5.6 KB · Views: 280
  • BuyCrap.ash
    2.5 KB · Views: 294
Last edited by a moderator:

dj_d

Member
By the way, Sandiman recently posted a cool script for shopping before your ascension. In a case of great minds thinking alike, I had this similar script ready to go. I was planning on ascending and testing it, but then Crimbo came along, and... you know how it goes. Thought I might as well get it out in the mean time. Expect a greater than usual contingent of bugs.
 

zarqon

Well-known member
I just wanted to mention that this is possibly my favorite script name on the forum. ;)
 

tebee

Member
This is yet another script caught out by Revision: 7185
Code:
Do not allow "=" to be used as a synonym for "==" in expressions, 
since ASH programmers expect "=" to be used only for assignment.

So fix line 54 in buycrap as follows

Code:
if (pullItem == $item[none])

So far this change has also broken 2 of my own scripts :-(

hangs head in shame........

Incidentally I can't get this script to read the map file from anywhere other than the root script directory ( on XP ) Anybody else found this? has the map command been changed to ignore \ ?
 
Last edited:

tebee

Member
OK I've been looking at the BuyCrap part of this, and unless I'm totally misunderstanding what this is supposed to be doing, there seems a logic error in this part

Code:
int num_equipped(item it)
{
	 int amount = 0;
	 if (equipped_item($slot[acc1]) == it)
	    amount = amount + 1;
	 if (equipped_item($slot[acc2]) == it)
	    amount = amount + 1;
	 if (equipped_item($slot[acc3]) == it)
	    amount = amount + 1;
	 if (equipped_item($slot[familiar]) == it)
	    amount = amount + 1;
	 if (equipped_item($slot[hat]) == it)
	    amount = amount + 1;
	 if (equipped_item($slot[off-hand]) == it)
	    amount = amount + 1;
	 if (equipped_item($slot[pants]) == it)
	    amount = amount + 1;
	 if (equipped_item($slot[shirt]) == it)
	    amount = amount + 1;
	 if (equipped_item($slot[weapon]) == it)
	    amount = amount + 1;
	 return amount;
}


void buyit(item it, int number)
{
  if (SIMSHOP)
    print("acquire "+(number-num_equipped(it))+" "+it);
  else
    cli_execute("acquire "+(number-num_equipped(it))+" "+it);
}

Now , as I see it, "number" is the number of an item we want to have before we ascend.
If so, then nowhere in this routine are we taking into account the number of that item we have other than those we have equipped.

The simple solution would be to change the line

Code:
int amount = 0;

to

Code:
int amount = item_amount(it);

though this does result in "num_equipped" meaning something rather different.
 

dj_d

Member
I think you're right, tebee! Weird that I hadn't noticed that in use; I've used this script on every one of about two dozen ascensions. But I think there's been a better way to do this since I wrote the script - if memory serves, available_amount() now considers equipment, closet, inventory, and everything else (except creatable_amount()). Anyone want to confirm that? If so, I'll just switch to available_amount() and replace all that code.
 

jasonharper

Developer
Specifically, available_amount() returns the amount in inventory, closet (even if you've turned off the closet as a source of ingredients), and equipment (including your current familiar's item, but not items still equipped on other familiars - that's arguably a bug). If you're out of hardcore/Ronin, it also counts items in storage.
 

dj_d

Member
Ah, figured out why it's not broken. Acquire takes in to account the number you have already. So acquire 1 lime does nothing if you have 1 or more limes. But acquire used to ignore what you have, hence the gyrations to exclude that. I think that behavior was fixed a long time ago.

I'm updating with the latest version of this code - the bits I've been using lately.
 

tebee

Member
Ah ! yes, It would still work! I'd only run it with a simulate = true and was a bit puzzled about all this stuff it said it was going to acquire, in my brain acquire = buy , even though not in mafia!
 

kain

Member
If I might ... and if there is ongoing revision (otherwise I'll finish with my current hack) ... can we have the option to specify different files of crap for different chars?
 

dj_d

Member
Should be easy - I'd just change "crap.txt" to charname()+".txt" (or whatever the ash call for character name is). Then rename crap.txt to dj_d.txt and you're good to go. I'm on a slow connection now, though, so it'll have to wait for later. Or if you do it, post it and I'll update.
 
I tried to use this, and I got

"> call scripts/BuyCrap.ash

Unknown variable 'Ôªønotify' (BuyCrap.ash, line 1)"

That, which is really weird. Any help?
I am using a Mac, 10.3.9.
 
Last edited:

Ethelred

Member
A good thing to check is that you're working with a plain text file rather than a rich text file, which is the default fot TextEdit, the common Mac text editor. It's nice for styled text but screws up code files. Get TextWrangler (a free download) for code editing and make sure anything you've touched with TextEdit is converted to plain (not rich) text.
 

Veracity

Developer
Staff member
Make your own decision: do you want the script to work, or not? It's guaranteed to not work if it's not plain text - as you observed yourself.
 
Hmmm, I changed the "=" to a ")" in line 54, which is this:
"if (pullItem ) $item[none])"
It was: "if (pullItem ) $item[none])"

Now it says ""if" requires a boolean conditional expression (BuyCrap2.ash, line 54)"
What now? I am using TextWrangler now by the way.
 

dj_d

Member
I'll make this easier... I've updated the scripts to be compatible with the latest release. Just download a fresh copy.
 

StormCrow42

Member
I just noticed that BuyCrap tries to bake your keys into pies after blowing up your chef. You should probably reverse the order of those two operations.
 

dj_d

Member
That's right - I forgot that the new version I posted had that in it.

I found the blowing-up-helper thing to be more trouble than it was worth, so I just leave it disabled. But you're right, you should re-order those two steps if you want to experiment with it.
 
Top