Auto Make: Automate producing complex items
Languages: English
Version: 1.2.5
Author: Oren Ben-Kiki
Based on: ReagentCalc (and some peeking into BankStatement)

Description:
  AutoMake provides an interface that displays in advance how many reagents and
  which intermediate steps are required to produce a set of items. It also
  allows performing the list of required steps in a single click (per trade
  skill).

Status:
  This is a "release" version. I actually quit World of Warcraft so if anyone
  wants to take over maintaining this...

Usage:

- Open a Trade Skill window (such as Engineering, or Tailoring, or whatever).

- You will notice that the base trade skill window is now accompanied by
  a large (initially empty) frame at the right and a list of additional buttons
  at the bottom. See the attached screenshot for what it should look like.
  
- DON'T PANIC. All the normal trade skill buttons and operations continue to
  work completely unmodified.
  
- You can hit the "A" button next to the "x" close button to toggle the
  AutoMake frames. The "x" buttons close the whole trade skill window.

- The additional buttons provide access to AutoMake functionality. They are:

  Add All: For the currently selected item, set the number of goal items in
    the "todo" list to the number available in the trade skill window (if the
    trade skill won't let you build any, the item is removed from the "todo"
    list). This isn't as useful as you'd expect becase the whole point is to
    build stuff that the trade skill window doesn't know it can do (due to
    dependencies). But it is nice to have.

  Add: Add the specified count of the current selected item to the "todo" list.
    Personally I find that pressing the "Add" button a number of times is
    faster than upadting the number and then pressing "Add", but the
    functionality is there if you want it.

  Remove: Remove the specified count of the current selected item to the "todo"
    list (again, pressing remove a number of times is faster, but you can also
    update the number and then hit remove). If the number in the list drops to
    zero, the item is completely removed from it, and further removes have no
    effect.
  
  Remove All: Completely remove the currently selected item, and only the
    currently selected item, from the "todo" list.

  Clear: Completely remove all items from the "todo" list.

  Basics: Automatically add all available "basic" operations of the current
    trade skill to the "todo" list. Basic operations require only reagents you
    can't make, and which are only used by this specific skill.
    
    Thus, in mining, this will automatically add all the available smelting ore
    into bars, but will not add smelting tin and copper into bronze. In
    Engineering, it will add grinding stones into blasting powder, but will not
    add making bolts out of bars. I have no idea what this will do in other
    skills (alchemy, leatherworking, blacksmithing). I can only assume it is
    something "reasonable". Please let me know how this works for you.

    At any rate, all this does is add things to the list. You therefore have a
    chance to look at the list and edit it manually before hitting "Do" to
    actually perform the steps.

  Do: Perform all actions required to make everything in the "todo" list, using
    the skills from the current trade skill (see below for using more than one
    trade skill for producing an item).

- In the frame at the right, AutoMake will display the current "todo" list,
  the intermediate steps required to create all the items, and the list of
  reagents needed. Each goal item or intermediate step is accompanied by an
  indication of the trade skill required and an indication of the amount
  needed, available, missing, and available in the bank. Only non-zero amounts
  are displayed.

- Closing the trade skill window does not erase the "todo" list. Logging out,
  however, does erase the list.

- All names are color coded to indicate rarity (white, yellow, blue, etc.).
  This is independent of whether the required reagents are present. Luckily,
  red isn't an item color, so stick with "red is bad" for a quick glance
  through the list for missing reagents.

- The trade skill name is painted in green if it is the current one, or orange
  otherwise. In general orange means "we can do it but you need to do some
  simple action first" - in this case, switching to a different trade skill.
  
- If you have enough of a reagent, its amount (and how much you have) will
  appear in green. If you are missing some reagent, its amount will appear in
  red and you will see red "need X more" next to it. If you have enough of the
  reagent in the bank, its amount (and the amount in the bank) will appear in
  orange, but the "need X more" will remain red. So, again - orange indicates
  you can build the item if you take some action (in this case, fetching
  reagents from the bank), while red indicates you are missing some required
  reagents, which you might not be able to do anything about.

- To know what you have in the bank, you need to open the bank deposit box once
  after installing this add-on. AutoMake will keep track of the bank from there
  on across gaming sessions.

- To know what can be made out of what, you need to open all your trade skill
  windows once after installing this add-on. AutoMake will keep track of your
  skills from there on across gaming sessions.

- AutoMake maintains a single unified "todo" list which is displayed regardless
  of the current trade skill selected. You can freely add to the list items
  from any of the trade skill windows. AutoMake will also automatically handle
  reagents created by a different trade skill. For example, if an engineering
  item requires a bronze bar, AutoMake will know you can smelt one out of a
  copper and a tin bar (assuming you are a miner/engineer).

- AutoMake will automatically recompute the information whenever it changes
  changes for any reason (including making the reagents manually or
  automatically using "Do"). Note that making something manually does not
  remove it from the "todo" list.

- Clicking "Do" will perform all operations in an arbitrary valid order.
  AutoMake will create required reagents before attempting to create an item,
  and will try to create everything possible within the confines of the current
  trade skill. If some steps use a different trade skill, you need to manually
  switch trade skill windows. AutoMake will give you a "In <some trade skill>,
  need to use <another trade skill>" message to let you know which trade skill
  to switch to next (see known issues below).

- Operations are performed one at a time, until everything is built or all
  remaining steps can't be done (due to missing ingredients and/or missing
  other requirements). AutoMake displays messages explaining what it is doing
  to keep you entertained while it is chugging along.

- To abort the automatic production, simply abort the current processing step.
  Simply moving seems to do the trick for all the skills I know of. Pressing
  ESC to close all windows (in particular, the trade skill window) also works.

Known issues:

- There are a lot of add-ons that attach themselves to the trade skill window.
  This causes problems when more than one is used at the same time. "Out of the
  box", AutoMake positions its stuff so it will look best when no other such
  add-ons are used. Users who are using conflicting add-ons should install the
  MoveAnything add-on and move either AutoMake's stuff or the other add-on's
  stuff (or both) out of each other's way. For such users, the list of relevant
  AutoMake widget names is:

    AutoMakeToggle: The "A" next to the trade skill window "x".
    AutoMakeButtonsFrame: The bottom frame containing the
      AutoMakeAddAll, AutoMakeAdd, AutoMakeRemove, AutoMakeRemoveAll,
      AutoMakeClear, AutoMakeBasics, AutoMakeDo buttons.
    AutoMakeFrame: The right frame containing the AutoMake text.

  Alternatively, if some brave soul wants to create an alternate AutoMake.xml
  file (modifying just the anchors and/or offsets), creating a configuration
  more compatible with a certain (set of?) add-ons, I would be delighted to
  include it in the distribution and let the users decide which one to use.

- Blizzard's API has this notion that Lua scripts can only access whetever is
  visible on the screen. Therefore, it seems the API is sensitive to collapsing
  and expanding skill categories. To prevent all sort of "interesting" issues
  resulting from this behavior, DON'T TOUCH ANYTHING IN THE TRADE SKILL WINDOW
  WHILE AUTO-MAKING ITEMS.

- There is a mysterious problem causing Blizzard's API to sometimes return nil
  when it shouldn't. If this happens, AutoMake will emit an AutoMake: BUGS line
  to the chat frame. Normally this is accompanied by the normal error pop-up.
  For a particularly pesky case (which I can't reproduce on my computer but has
  occured for several 1.2.1 users), there is special error recovery code that
  tries to side-step the issue. If it fails, well, it's back to the good old
  error pop-up...

  I contacted Blizzard's tech support with the problem and they politely told
  me to bugger off, as they don't support their API in any way shape or form.
  To prove the point they changed all sort of stuff in patch 1.8. Sigh.

- The "Basics" button is designed with mining and engineering in mind. Let me
  know if you feel it should be doing something else for other trade skills.

- There are no configurable options. This means there is no longer a slash
  command associated with the add-on. This may be considered a feature :-)

- The background of the new frame is semi-transparent. Again, this might be
  considered a feature, given the amount of screen real estate the frame
  occupies. Still, if anyone knows which background image to specify in the XML
  to make it more compatible with the normal trade skill window, let me know.
  I at least want to see what it would look like :-)

- The trade skill window isn't movable, so the AutoMake frame isn't either (it
  is bound to the base frame). Luckily there is MoveAnything to work around the
  issue. Just make sure you actually open the window before moving it, because
  MoveAnything doesn't display the additional AutoMake frame.

- AutoMake was only tested on English clients. On the other hand, version 1.1
  doesn't parse any chat texts, so if you use it in a German/French/Korean
  client, it should still work. All displayed texts would be in English though.

- The system flat out refuses to behave itself when it comes to switching trade
  skill windows from Lua. I spent a day pushing, shoving and poking at it, to
  no avail. It almost seems as though I am triggering some "anti-bot" detection
  code that kicks in to actively prevent this from working. At any rate, life
  is too short; I am giving up on this as a lost cause. If anyone wants to try,
  I'll be happy to provide a list of failed approaches.

- It would be nice to indicate the total buy/sell cost of the reagents you will
  be using and the expected profit from the current "todo" list. This is
  reasonably straighforward to do using vendor prices (integrating with, say,
  SellValue). It is trickier when considering auctions (integrating with, say,
  Auctioneer), because values there are less definitive and not always
  available. This requires some thought before plunging into coding :-)

Upgrade Instructions:

- Simply unzip AutoMake.zip on top of any older version. Then fire up Warcraft
  as usual. You will need to open the bank frame and all your trade skill
  frames so AutoMake will get a chance to learn them if you had version 1.1 or
  1.2 installed, as the format has changed in version 1.2.1.

Version history:

1.2.5:

  At: 2005-11-26
  By: Oren Ben-Kiki
  Description:

  - Fixed a minor variable name bug in line 1147.

1.2.4:

  At: 2005-10-12
  By: Oren Ben-Kiki
  Description:

  - Hacked to work for patch 1.8.

1.2.3:

  At: 2005-09-27
  By: Oren Ben-Kiki
  Description:

  - Fixed an embarrasing problem on 1.2.2 where AutoMake would abort making
    things after each item made. Sorry!

  - AutoMake should now track new skills even if learned while the trade
    skill window is opened.

1.2.2:

  At: 2005-09-27
  By: Oren Ben-Kiki
  Description:

  - Fixed spurious "BUGS" messages when hitting the "Basics" button.

  - Added attempt at recovery from getting a nil reagent name when scanning
    a trade skill window.

  - Abort processing and re-scan skills when the trade skill window is updated.
    (THIS TURNED OUT TO BE A HUGE MISTAKE, fixed in 1.2.3. Sorry...).

1.2.1:

  At: 2005-09-25
  By: Oren Ben-Kiki
  Description:

  - Added guards at each function invocation and each relevant API call. These
    are intended to catch any misbehaving as soon as possible, and pin-point
    the source of the problem to either a piece of the add-on's code or
    Blizzard's API. This will hopefully help resolve the strange error messages
    witnessed by some users.

  - Switched to the new (toc) saved variables mechanism. This may or may not
    have anything to do with the strange problems people experienced, but
    given RegisterForSave is officially deprecated it sounds like a good idea.

1.2:

  At: 2005-09-24
  By: Oren Ben-Kiki
  Description:

  - Made the code even more defensive in hope of fixing a mysterious
    (harmless) problem reported by a user building a huge list of items.

  - Skills that create multiple amount of items are now handled properly.

  - The amount of reagents you can make but already have some of is now
    displayed in green.

  - Moving items from the bank to the inventory now properly updates the
    "have in bank" amounts.

  - Added buttons to close and toggle the AutoMake frame.

  - Added the "Basics" button which hopefully does something reasonable.

  - Added sorting to various loops so display and production order are now
    deterministic and hopefully make more sense to the user.

1.1:

  At: 2005-09-17
  By: Oren Ben-Kiki
  Description:

  - Updated interface version to 1700 to work cleanly on patch 1.7.

  - Integrated AutoMake with the trade skill window. It now appears as a frame
    and a row of buttons attached to the normal trade skill frame, and looks
    like a more-or-less integral part of it (except for the bloody background).

  - Added color to the display. Names and amounts are color coded by current
    trade skill, item rarity, and availability. It looks much prettier than
    the boring yellow version 1.0. Hopefully it is also more useful. The basic
    rule is that red is bad, and orange you can fix.

  - A lot of wasted effort trying to automate production across trade skills.
    The code knows what needs to be done, but implementing "switch to trade
    skill X, then continue" seems impossible. As it is, the user needs to
    manually change the trade skill and hit "Do" again.

1.0:

  At: 2005-09-13
  By: Oren Ben-Kiki
  Description:

  - Initial revision.
