overtyped wrote:Can anyone make a script that puts curd into cheese trays?
I didn't like Arcanist's implementation, so I had written my own. Just finally got enough curds to make sure it worked in all the use cases I could think of, so it should work fine... but I can't guarantee it handles all situations properly. I also haven't tested it with containers other than cupboards, but they should work the same without problems. Hopefully the commenting and slight changes I just made to make it more readable don't break it.

1. Fill (or half-fill, put one in, doesn't matter) inventory with curds.
2. Open a cupboard with empty cheese trays in it (the name of the container to use can be changed with the containerName variable)
3. Wait for it to finish.

- Code: Select all
//#! name = Cheese2Trays
//#! uniq = cheese2trays
//#! icon = gfx/invobjs/cheese-curd
include("jBotAPI");
/* Instructions: Fill inventory with Cheese Curds, run script with a cupboard open/open a cupboard and run script. Empty cheese trays will be filled until there are no more empty */
var containerName = "Cupboard"; // change this to change which container will house the empty cheese trays. This is the title of the window that opens when you right-click the container e.g. "Chest", "Crate"
var inventory = checkInventory();
// if the window isn't already open, we'll wait a bit for the user to open it, and continue.
if (jGetWindow(containerName) == null)
{
jWaitWindow(containerName, 60000);
}
var win = jGetWindow(containerName);
jSleep(100);
var inv = win.getInventories()[0];
var trays = inv.getItems("gfx/invobjs/cheese-tray");
var trayIndex = 0;
while (inventory.getItems("cheese-curd").length > 0)
{
// these if-else statements will sort out the trays that aren't empty
if (trays[trayIndex].resName() != "gfx/invobjs/cheese-tray-curd")
{
if (trays[trayIndex].resName() != "gfx/invobjs/cheese-tray-cheese")
{
if (inventory.getItems("cheese-curd").length > 0)
{
inventory.getItems("cheese-curd")[0].take();
jWaitDrag(20000);
trays[trayIndex].itemact(0);
jWaitDrop(20000);
// we test to see if the tray has recently become full from having added the cheese curds, and advance the tray index to the next one if it hasn't
if (trays[trayIndex].resName() != "gfx/invobjs/cheese-tray")
{
trayIndex++;
jSleep(100);
}
}
}
else
{
trayIndex++;
jSleep(50);
}
}
else
{
trayIndex++;
jSleep(50);
}
}
Edit: Oh and juchan, I found this: http://pastebin.com/f8npcXT9 on Google, I knew it had been done before, hopefully that should help you out.