KoLmafia Guide: Automatic Mall Selling

From Kolmafia
Jump to navigation Jump to search

Next up is an auto-selling function. In this case, it sells a bunch of stuff that I farmed from the Sea in order to make money with. I am poor, after all. You can easily adapt this script to automatically deal with certain items that you encounter on a regular basis. For example, if Castle-farming, you can mall-sell certain items, auto-sell some of them, or pulverize some.

BIG NOTE: Mafia already has the ability to designate items as 'junk', or 'sellable'. I haven't figured it out yet though... Plus this is easier and quicker for me to control.

a) First up, I figure out how many Slimy Chests I have with item_amount. I then use all of that item. NOTICE the usage of 'cli_execute("command"); I COULD have used what I did in the previous script, which is use(X,$item[Slimy chest]); This would have been simpler. But you learn more this way!

b) You will notice that I used a compound statement to execute the cli_execute command. I took 'use ' then added the number of items I had (lets say 9) , then added ' Slimy Chest'. So the command executed was 'use 9 Slimy chest', when put together. This is handy for opening container-like-items automatically.

c) The cli_execute will run ANY command you could run from the CLI Graphical Interface. You can use the links I've given you at the top of the guide to find a complete list. OR, in the CLI, type /help for a full list. Anything you can do there, you can automate in this way by cli_execute!

d) The next thing is that I want to sell my EXTRAS. What I do is figure out how many of an item I have, then if I have more than X amount, I sell the difference. Once again, I use cli_execute instead of a normal ash script command. This is good for when you want to keep a reserve of a particular item, but don't want them to pile up into the hundreds.

e) The next thing you see is where I sell all of a particular item. Due to extreme laziness, I simply script to mallsell 99 of each item that I want to ditch. It will put UP TO 99 of each into the store with no complaint. Obviously this is less precise, but it does work...and it is very quick and easy.

f) The final command is to 'undercut'. This actually DOES work after all. However Mafia can only see the FIFTH CHEAPEST PRICE. Therefore it sets the price pretty low, but rarely the true lowest price. You can skip this command it desired and just set prices yourself. That's what I wind up doing anyways.

void main()
{
  ## Use any slimy chests first.
  if ( item_amount( $item[Slimy chest] ) > 0 )
  {
     cli_execute("use " +item_amount($item[Slimy chest]) +" Slimy chest");
  }

  ## Sell Spare Seaweed
  if ( item_amount( $item[Seaweed] ) > 10 )
  {
     cli_execute("mallsell " +(item_amount($item[Seaweed]) -10) +" Seaweed");
  }

  ## Sell Spare Sand Dollar
  if ( item_amount( $item[Sand dollar] ) > 20 )
  {
     cli_execute("mallsell " +(item_amount($item[Sand dollar]) -20) +" Sand dollar");
  }

  ## The Sea Fruits
  cli_execute("mallsell 99 sea tangelo");
  cli_execute("mallsell 99 sea honeydew");
  cli_execute("mallsell 99 Sea lychee");
  cli_execute("mallsell 99 sea radish");
  cli_execute("mallsell 99 sea avocado");
  cli_execute("mallsell 99 sea carrot");
  cli_execute("mallsell 99 sea cucumber");

  ## Other Sea-Related Crap.
  cli_execute("mallsell 99 Flytrap pellet");
  cli_execute("mallsell 99 Pufferfish spine");
  cli_execute("mallsell 99 Dragonfish caviar");
  cli_execute("mallsell 99 Slab of sponge");

  ## Octopus Spade, if more than 1.
  if ( item_amount( $item[Octopus spade] ) > 1 )
  {
     cli_execute("mallsell " +(item_amount($item[Octopus spade]) -1) +" Octopus spade");
  }

  ## Straw Hat, if more than 1.
  if ( item_amount( $item[Straw hat] ) > 1 )
  {
     cli_execute("mallsell " +(item_amount($item[Straw hat]) -1) +" Straw hat");
  }

  ## Auto reprice the stuff I just added, that is at 999999999.
  cli_execute("undercut");

}

Continue to Post-Lesson 3: Automatic Buffing II, Buffbots and Status Checking