Question about farming script; Is there any script available like there was for Pande where you would highlight the area you wanted it to harvest?
I love the farming script here, but I mean for farming old crops or removing fields you don't want/need anymore it would be useful. Does anyone have one like that?
Union Client Scripts
Moderator: Phades
-
Shakey
- Posts: 212
- Joined: Wed Jan 25, 2012 10:33 pm
Re: Union Client Scripts
Vigilance to WafflesVigilance wrote:You forgot to make kill a past-tense and precede it with "get"
Vigilance talking about meVigilance wrote:Phaen he's like a little me, except not as sexy right?
-
Pascal666
- Posts: 48
- Joined: Thu Jan 14, 2010 8:12 pm
Re: Union Client Scripts
Small question, I am trying to improve a bot but I can't find the right object name.
I am using findObjectByName(String name, int radius) and figured I could use the res name, but that doesn't work:
For example: plants/hops and plants/peas aren't working, but plants/carrots does work.
Where do I find the right object name?
I am using findObjectByName(String name, int radius) and figured I could use the res name, but that doesn't work:
For example: plants/hops and plants/peas aren't working, but plants/carrots does work.
Where do I find the right object name?
-
Arcanist
- Posts: 2664
- Joined: Mon Mar 19, 2012 2:01 pm
Re: Union Client Scripts
That is the right name to use.Pascal666 wrote:Small question, I am trying to improve a bot but I can't find the right object name.
I am using findObjectByName(String name, int radius) and figured I could use the res name, but that doesn't work:
For example: plants/hops and plants/peas aren't working, but plants/carrots does work.
Where do I find the right object name?
If you are trying to improve apxfarmer, then use the correct stage (ctrl+d blob#)
-
Pascal666
- Posts: 48
- Joined: Thu Jan 14, 2010 8:12 pm
Re: Union Client Scripts
I see, thanks for the tip.Arcanist wrote:That is the right name to use.Pascal666 wrote:Small question, I am trying to improve a bot but I can't find the right object name.
I am using findObjectByName(String name, int radius) and figured I could use the res name, but that doesn't work:
For example: plants/hops and plants/peas aren't working, but plants/carrots does work.
Where do I find the right object name?
If you are trying to improve apxfarmer, then use the correct stage (ctrl+d blob#)
Got it working now, added peas and hops.
Code: Select all
//#! name = Farmer2
//#! uniq = farmer_apxproductions2
//#! icon = gfx/invobjs/seed-hops
// Globals
var inventory = checkInventory();
var harvester;
// Settings
var actionTimeout = 1000 * 60 * 2; // Lag timeout
var cannotPlantTimeout = 1000 * 10; // Non-plowed tile timeout
var cropRadius = 3; // Ðàäèóñ â êîòîðì èäåò ïîèñê (âåðõ, ïðàâî, íèç, ëåâî)
// Flags
var stopFlag = false;
function PeapodHarvester() {
this.cropName = "plants/peas"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/peapod"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 4; // Ñòàäèÿ îáðàáîòêè
}
PeapodHarvester.prototype.processHarvestedGoods = function() {
inventory = checkInventory();
var seeds = inventory.getItems(this.cropSeedName);
var free = inventory.freeSlots();
var i = 0;
if (free < 3) {
inventory.sortItems(seeds, "quality", false);
for (i = 0; i < 3 - free; i++) {
// Åñòü ìîðêîâü åñëè ãîëîäåí
if (jGetHungry() < 95) {
if (seeds[i].isActual()) {
seeds[i].iact();
jWaitPopup(actionTimeout);
jSelectContextMenu("Eat");
waitUnActual(seeds[i]);
}
}
// Âûáðîñèòü ëèøêó
if (seeds[i].isActual()) {
seeds[i].drop();
}
}
}
};
function HopsHarvester() {
this.cropName = "plants/hops"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-hops"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
HopsHarvester.prototype.processHarvestedGoods = function() {
inventory = checkInventory();
var seeds = inventory.getItems(this.cropSeedName);
var free = inventory.freeSlots();
var i = 0;
if (free < 3) {
inventory.sortItems(seeds, "quality", false);
for (i = 0; i < 3 - free; i++) {
// Åñòü ìîðêîâü åñëè ãîëîäåí
if (jGetHungry() < 95) {
if (seeds[i].isActual()) {
seeds[i].iact();
jWaitPopup(actionTimeout);
jSelectContextMenu("Eat");
waitUnActual(seeds[i]);
}
}
// Âûáðîñèòü ëèøêó
if (seeds[i].isActual()) {
seeds[i].drop();
}
}
}
};
/* =========================================================================== */
/* ============================== ÌÎÐÊÎÂÊÀ ============================== */
/* =========================================================================== */
function CarrotHarvester() {
this.cropName = "plants/carrot"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/carrot"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 4; // Ñòàäèÿ îáðàáîòêè
}
CarrotHarvester.prototype.processHarvestedGoods = function() {
inventory = checkInventory();
var seeds = inventory.getItems(this.cropSeedName);
var free = inventory.freeSlots();
var i = 0;
if (free < 3) {
inventory.sortItems(seeds, "quality", false);
for (i = 0; i < 3 - free; i++) {
// Åñòü ìîðêîâü åñëè ãîëîäåí
if (jGetHungry() < 95) {
if (seeds[i].isActual()) {
seeds[i].iact();
jWaitPopup(actionTimeout);
jSelectContextMenu("Eat");
waitUnActual(seeds[i]);
}
}
// Âûáðîñèòü ëèøêó
if (seeds[i].isActual()) {
seeds[i].drop();
}
}
}
};
/* =========================================================================== */
/* ============================== ÑÂÅÊËÀ ============================== */
/* =========================================================================== */
function BeetHarvester() {
this.cropName = "plants/beetroot"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/beetroot"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
BeetHarvester.prototype.processHarvestedGoods = function() {
inventory = checkInventory();
var seeds = inventory.getItems(this.cropSeedName);
var free = inventory.freeSlots();
var i = 0;
//dropsleaves
var leaves = inventory.getItems("beetrootleaves");
if(leaves.length > 0)
if(leaves[0].isActual())
leaves[0].dropSuchAll();
while(leaves.length > 0)
{
leaves = inventory.getItems("beetrootleaves");
jSleep(500);
}
if (free < 6) {
inventory.sortItems(seeds, "quality", false);
for (i = 0; i < 4 - free; i++) {
if (jGetHungry() < 95) {
if (seeds[i].isActual()) {
seeds[i].iact();
jWaitPopup(actionTimeout);
jSelectContextMenu("Eat");
waitUnActual(seeds[i]);
}
}
if (seeds[i].isActual()) {
seeds[i].drop();
}
}
}
};
/* =========================================================================== */
/* ============================== ÂÈÍÎÃÐÀÄ ============================== */
/* =========================================================================== */
function WineHarvester() {
this.cropName = "plants/wine"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-grape"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.packName = "invobjs/grapes";
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
this.barrelID = 0; //id of barrel
this.pressID = 0; //id of winepress
this.containerID = 0;
this.startCoord = jCoord(0, 0);
this.fieldSize = jCoord(0, 0);
this.offsMove = jCoord(2, 0);
}
WineHarvester.prototype.selectObjects = function() {
var bar = jSelectObject("Select barrel...");
if(bar.name().indexOf("barrel") == -1)
{
jToConsole("ERROR: This is not a barrel!");
return false;
}
else this.barrelID = bar;
var pr = jSelectObject("Select winepress...");
if(pr.name().indexOf("winepress") == -1)
{
jToConsole("ERROR: This is not a press!");
return false;
}
else this.pressID = pr;
var cnt = jSelectObject("Select container (chest/lchest)...");
if(cnt.name().indexOf("cclosed") == -1 && cnt.name().indexOf("lchest") == -1)
{
jToConsole("ERROR: This is not a container!");
return false;
}
else this.containerID = cnt;
return true;
}
WineHarvester.prototype.selectRect = function() {
var offs = jCoord(0, 0);
var size = jCoord(1, 1);
var confirm = false;
jDrawGroundRect(offs, size);
var blist = ["West", "East", "North", "South", "Inc width", "Inc height", "Dec width", "Dec height", "Confirm", "Exit"];
var selectWindow = jGUIWindow(jCoord(250, 250), jCoord(105, blist.length * 25 + 15), "Test");
var label = jGUILabel(selectWindow, jCoord(5, 5), "Select grapes area.");
for(var i = 0; i < blist.length; i++)
jGUIButton(selectWindow, jCoord(5, 25 + i*25), 100, blist[i]);
selectWindow.toggleCloseButton();
var btext = "";
while(btext != "Exit"){
btext = selectWindow.waitButtonClick();
if(btext == blist[0]) offs.x--;
if(btext == blist[1]) offs.x++;
if(btext == blist[2]) offs.y--;
if(btext == blist[3]) offs.y++;
if(btext == blist[4]) size.x++;
if(btext == blist[5]) size.y++;
if(btext == blist[6]) if(size.x > 1) size.x--;
if(btext == blist[7]) if(size.y > 1) size.y--;
if(btext == blist[8]) {confirm = true; break;}
jDrawGroundRect(offs, size);
}
selectWindow.destroy();
jDrawGroundRect(offs, jCoord(0, 0));
this.startCoord = jMyCoords().add(offs.mul(11));
this.fieldSize = size;
return confirm;
}
WineHarvester.prototype.processHarvesting = function() {
var result = false;
var grapes = jGetObjectsInRect(this.startCoord, this.fieldSize, this.cropStage, [this.cropName]);
inventory = checkInventory();
var cuts = Math.floor((inventory.freeSlots() - 1)/3); //õóéïèçäà
if(cuts > 8) cuts = 8;
var currentgrape = 0;
while(1)
{
if(currentgrape >= grapes.length) {result = true; break;}
//cursor
if(!jIsCursor("harvest")) {
jSendAction("harvest");
jWaitCursor("harvest", actionTimeout);
}
//harvesting grapes
for(var i = 0; i < cuts; i++)
{
if(jGetStamina() < 50) drinkWater();
if(currentgrape >= grapes.length) break;
jDoClick(grapes[currentgrape], 1, 0);
jWaitProgress(actionTimeout);
currentgrape++;
}
//got pack of grapes
resetCursor();
//goes to press
jAbsClick(this.pressID.position().add(this.offsMove.mul(11)), 1, 0);
jWaitMove(actionTimeout);
jDoClick(this.pressID, 3, 0);
jWaitWindow("Winepress", actionTimeout);
//no window in lag/etc
jSleep(100);
if(!jHaveWindow("Winepress")) {result = false; break;}
//transfers all grapes to winepress
inventory.getItems(this.packName)[0].transferSuchAll();
//waits transfering
while(inventory.getItems(this.packName).length > 0)
jSleep(300);
//making juice
jGetWindow("Winepress").pushButton(1);
while(jGetWindow("Winepress").getInventories()[0].getItems(this.packName).length > 0)
jSleep(500);
//lifts press
var pc = this.pressID.position();// memorizing press coords
jSendAction("carry");
jWaitCursor("chi", actionTimeout);
//lag
if(!jIsCursor("chi")) {result = false; break;}
jDoClick(this.pressID, 1, 0);
jSleep(1500);
/*while(!jAvatarIsCarrying(jGetMyID()))
jSleep(200);*/
//juice to barrel
jDoClick(this.barrelID, 3, 0);
jWaitMove(actionTimeout);
jSleep(2000);
//placing press back
jAbsClick(pc, 3, 0);
jWaitMove(actionTimeout);
/*while(jAvatarIsCarrying(jGetMyID()))
jSleep(200);*/
//getting seeds from press
jDoClick(this.pressID, 3, 0);
jWaitWindow("Winepress", actionTimeout);
//no window in lag/etc
jSleep(100);
if(!jHaveWindow("Winepress")) {result = false; break;}
//transfer to pack seeds
jGetWindow("Winepress").getInventories()[0].getItems("")[0].transferSuchAll();
while(jGetWindow("Winepress").getInventories()[0].getItems("").length > 0)
jSleep(200);
//offset move
jMoveStep(this.offsMove);
jWaitMove(actionTimeout);
//going to lchect
var lc = this.containerID.position().add(this.offsMove.mul(11));
jAbsClick(lc, 1, 0);
jWaitMove(actionTimeout);
jDoClick(this.containerID, 3, 0);
jWaitWindow("Chest", actionTimeout);
//no window in lag/etc
jSleep(100);
if(!jHaveWindow("Chest")) {result = false; break;}
var bags = jGetWindow("Chest").getInventories()[0].getItems("invobjs/bag-seed");
var cbag = 0; //current bag
inventory = checkInventory();
//transferring seeds, btw i hate loftar
while(inventory.getItems(this.cropSeedName).length >= 1)
{
if(cbag >= bags.length) {result = true; break;}
var cnt = inventory.getItems(this.cropSeedName).length; //inventory count
bags[cbag].iact();
//opens seedbag
while(!jHaveWindow("Seedbag"))
jSleep(200);
//check for free slots
if(jGetWindow("Seedbag").getInventories()[0].freeSlots() == 0)
{
jGetWindow("Seedbag").close();
while(jHaveWindow("Seedbag"))
jSleep(200);
cbag++;
continue;
}
jSleep(100);
var free = jGetWindow("Seedbag").getInventories()[0].freeSlots(); //free slots in seedbag
inventory.getItems(this.cropSeedName)[0].transferSuchAll();
while(inventory.getItems(this.cropSeedName).length > Math.abs(cnt - free))
jSleep(200);
jGetWindow("Seedbag").close();
while(jHaveWindow("Seedbag"))
jSleep(200);
cbag++;
}
//èäèòå íà õóé, ìíå ëåíü ÷òîòî äåëàòü ñ ýòèìè ñåìåíàìè
if(result == true) {inventory.getItems(this.cropSeedName)[0].dropSuchAll(); jSleep(1000); break;} //break if all bags r full
//checks barrel
var bc = this.barrelID.position().add(this.offsMove.mul(11));
jAbsClick(bc, 1, 0);
jWaitMove(actionTimeout);
jDoClick(this.barrelID, 3, 0);
while(!jHaveWindow("Barrel"))
jSleep(500);
//barrel label
var blbl = jGetWindow("Barrel").getLabelText(1);
if(blbl.indexOf("100.0") != -1) {result = true; break;} //breaks if barrel is full
}//1
return result;
}
WineHarvester.prototype.plantGrapes = function() {
jMoveStep(this.offsMove);
jWaitMove(actionTimeout);
//going to lchect
var lc = this.containerID.position().add(this.offsMove.mul(11));
jAbsClick(lc, 1, 0);
jWaitMove(actionTimeout);
jDoClick(this.containerID, 3, 0);
jWaitWindow("Chest", actionTimeout);
//no window in lag/etc
jSleep(100);
if(!jHaveWindow("Chest")) return false;
jGetWindow("Chest").getInventories()[0].getItems("invobjs/bag-seed-f")[0].transferSuchAll();
jSleep(1000);
inventory = checkInventory();
var fullbags = inventory.getItems("invobjs/bag-seed-f");
for(var i = 0; i < fullbags.length; i++)
fullbags[i].iact();
while(jGetWindows("Seedbag").length < fullbags.length)
jSleep(200);
var swnds = jGetWindows("Seedbag");
var allseeds = [];
for(var i = 0; i < swnds.length; i++)
{
var sinvs = swnds[i].getInventories()[0].getItems(this.cropSeedName);
for(var j = 0; j < sinvs.length; j++)
allseeds.push(sinvs[j]);
}
//allseeds.sort(sortFunction2); //à Àðõ õóé!
var cseed = 0;
var overflow = false;
jAbsClick(jTilify(this.startCoord), 1, 0);
jWaitMove(actionTimeout);
for(var i = 0; i < this.fieldSize.x; i++) {
if(overflow == true) break;
for(var j = 0; j < this.fieldSize.y; j++) {
if(cseed >= allseeds.length) {overflow = true; break;}
if(jGetStamina() < 50) drinkWater();
jAbsClick(this.startCoord.add(i*11, j*11));
jWaitMove(actionTimeout);
if(jFindObjectByName(this.cropName, 3) != 0) continue;
plantNewCrop(this, false);
/*if(!jGetTileType(jCoord(0, 0)) != 9) plowTile();
allseeds[cseed].take();
jWaitDrag(actionTimeout);
jAbsInteractClick(jCoord(0, 0), 3, 0);
jWaitDrop(actionTimeout);
jSleep(100);*/
cseed++;
}
jSleep(100);
}
jToConsole("test");
}
/* =========================================================================== */
/* ============================== ÊÎÍÎÏËß ============================== */
/* =========================================================================== */
function HempHarvester() {
this.cropName = "plants/hemp"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-hemp"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 4; // Ñòàäèÿ îáðàáîòêè
bagsSeedsSorter(this);
}
HempHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
/* =========================================================================== */
/* ============================== ËÅÍ ============================== */
/* =========================================================================== */
function FlaxHarvester() {
this.cropName = "plants/flax"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/flaxseed"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
FlaxHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
/* =========================================================================== */
/* ============================== ÏÅÐÅÖ ============================== */
/* =========================================================================== */
function PepperHarvester() {
this.cropName = "plants/pepper"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-pepper"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
PepperHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
/* =========================================================================== */
/* ============================== ×ÀÉ ============================== */
/* =========================================================================== */
function TeaHarvester() {
this.cropName = "plants/tea"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-tea"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
this.leaveName = "invobjs/tea-fresh";
this.containerID = 0;
}
TeaHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
TeaHarvester.prototype.selectObjects = function() {
var cnt = jSelectObject("Select container (chest/lchest)...");
if(cnt.name().indexOf("cclosed") == -1 && cnt.name().indexOf("lchest") == -1)
{
jToConsole("ERROR: This is not a container!");
return false;
}
else this.containerID = cnt;
return true;
}
/* =========================================================================== */
/* ============================== ÌÀÊ ============================== */
/* =========================================================================== */
function PoppyHarvester() {
this.cropName = "plants/poppy"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-poppy"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 4; // Ñòàäèÿ îáðàáîòêè
}
PoppyHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
/* =========================================================================== */
/* ============================== ÏØÅÍÈ×ÊÀ ============================== */
/* =========================================================================== */
function WheatHarvester() {
this.cropName = "plants/wheat"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "wheat"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
WheatHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
/*==============================Êðîï÷èêè============================================*/
function bagsSeedsSorter(harv) {
inventory = checkInventory();
var bags = inventory.getItems("invobjs/bag-seed");
var free = inventory.freeSlots();
var fslots = 0;
if (bags.length > 0) {
var windows = jGetWindows("Seedbag");
if (windows.length > 0) {
var seeds = [];
var maxseedscount = bags.length * 9;
//getting seeds from all seedbags into array
for (var i = 0; i < windows.length; i++) {
var inv = waitInventory(windows[i], 0);
fslots += inv.freeSlots();
var bufseeds = inv.getItems(harv.cropSeedName);
for (var j = 0; j < bufseeds.length; j++) {
seeds.push(bufseeds[j]);
}
}
//from inventory to same array
var invseeds = inventory.getItems(harv.cropSeedName);
for (var j = 0; j < invseeds.length; j++) {
seeds.push(invseeds[j]);
}
//calculation quality of all seeds
var allq = 0;
for (var j = 0; j < seeds.length; j++) {
allq += seeds[j].quality();
}
//medium quality
var mediumrange = (allq / seeds.length) - 1;
//correcting medium q
//too many seeds
if(fslots < 9)
mediumrange += 1;
if (seeds.length > maxseedscount * 0.75) {
for (var j = 0; j < seeds.length; j++) {
if (seeds[j].quality() <= mediumrange) seeds[j].drop();
}
organizeBags(inventory, harv.cropSeedName);
}
}//bags windows
}
if (inventory.freeSlots() < 4 && bags.length < 1) {
inventory.sortItems(inventory.getItems(harv.cropSeedName), "quality", false);
for (i = 0; i < 3 - free; i++) {
if (seeds[i].isActual()) {
seeds[i].drop();
}
}
}
}
function organizeBags(inv, name) {
var bagw = jGetWindows("Seedbag");
if(bagw.length < 1) return;
var fullb, nextb;
fullb = 0;
nextb = bagw.length - 1;
while(1)
{
if(fullb == nextb) break; //breaks if filling bag == last bag
if(bagw[fullb].getInventories()[0].freeSlots() == 0) {
fullb++;
continue;
}
if(bagw[nextb].getInventories()[0].freeSlots() == 9) {
nextb--;
continue;
}
var freeSlot = bagw[fullb].getInventories()[0].freeSlotsCoords()[0]; //getting 1st empty slot at current filling bag
var seed = bagw[nextb].getInventories()[0].getItems(name)[0]; //getting 1st seed at current emptying bag
seed.take();
jWaitDrag();
bagw[fullb].getInventories()[0].drop(freeSlot); //drops to filling bag
jWaitDrop();
}
}
function openAllSeedbags() {
inv = checkInventory();
var bags = inv.getItems("invobjs/bag-seed");
if(bags.length < 1)
return;
for(var i = 0; i < bags.length; i++)
if(bags[i].isActual())
bags[i].iact();
while(jGetWindows("Seedbag").length != bags.length)
jSleep(300);
}
function waitUnActual(item) {
while (item.isActual()) {
jSleep(100);
}
}
function resetCursor() {
if (!jIsCursor("arw")) {
jAbsClick(jCoord(0, 0), 3, 0);
jWaitCursor("arw", actionTimeout);
}
}
function checkInventory() {
if(!jHaveWindow("Inventory")) {
jToggleInventory();
while(!jHaveWindow("Inventory"))
jSleep(100);
}
return jGetWindow("Inventory").getInventories()[0];
}
function checkEquipment() {
if(!jHaveWindow("Equipment")) {
jToggleEquipment();
while(!jHaveWindow("Equipment"))
jSleep(100);
}
return jGetJSEquip();
}
function waitInventoryObject(inv, objname) {
while (true) {
var objs = inv.getItems(objname);
if (objs.length > 0) break;
else jSleep(100);
}
}
function waitUnActual(item) {
while (item.isActual()) {
jSleep(100);
}
}
function drinkWater() {
if (jGetStamina() > 80) return;
inventory = checkInventory();
var buckets = inventory.getItems("bucket-water");
if (buckets.length > 0) {
inventory.sortItems(buckets, "amount", false);
var bucket = buckets[0];
var bucket_coord = bucket.coord();
if (bucket.isActual()) {
bucket.take();
jWaitDrag();
var flasks = inventory.getItems("waterflask", "waterskin");
if (flasks.length > 0) {
var flask = flasks[0];
if (flask.isActual()) {
flask.itemact(0);
jSleep(500);
inventory.drop(bucket_coord);
jWaitDrop();
}
}
}
}
var flasks = inventory.getItems("waterflask", "waterskin");
if (flasks.length > 0) {
var flask = flasks[0];
if (flask.isActual()) {
flask.iact();
if (jWaitPopup(actionTimeout)) {
jSelectContextMenu("Drink");
jWaitProgress();
} else {
// No water
stopFlag = true;
}
}
}
}
function TileInfo(crd) {
this.coord = crd;
}
function findCrop(harv) {
var objid = 0;
for (var i = 0; i < cropRadius; i++) {
objid = (jFindObjectWithOffset(harv.cropName, 1, jCoord(0, i))); // down
if (objid && objid.blob(0) == harv.cropStage) return objid;
}
for (var i = 0; i < cropRadius; i++) {
objid = jFindObjectWithOffset(harv.cropName, 1, jCoord(0, -i)); // up
if (objid && objid.blob(0) == harv.cropStage) return objid;
}
for (var i = 0; i < cropRadius; i++) {
objid = jFindObjectWithOffset(harv.cropName, 1, jCoord(i, 0)); // right
if (objid && objid.blob(0) == harv.cropStage) return objid;
}
for (var i = 0; i < cropRadius; i++) {
objid = jFindObjectWithOffset(harv.cropName, 1, jCoord(-i, 0));// left
if (objid && objid.blob(0) == harv.cropStage) return objid;
}
objid = jFindObjectByName(harv.cropName, cropRadius);
jPrint(objid);
if (objid.blob(0) != harv.cropStage) objid = -1;
return objid;
}
function dropItem(coord) {
var items = inventory.getItems("");
for (var i = 0; i < items.length; i++) {
if (items[i].coord().x == coord.x && items[i].coord().y == coord.y) {
items[i].drop();
break;
}
}
}
function waitDragName(name) {
while (true) {
var item = jGetDraggingItem();
if (item != null) {
if (item.resName() != null) {
if (item.resName().indexOf(name) >= 0) {
break;
} else {
jSleep(100);
}
} else jSleep(100);
} else {
break;
}
}
}
function equipScythe() {
var equip = checkEquipment();
var scythe = inventory.getItems("scythe")[0];
if (!scythe) return;
if (equip.resName(6).indexOf("shovel") >= 0) {
equip.takeAt(6);
jWaitDrag(actionTimeout);
inventory.drop(scythe.coord());
jSleep(1000);
waitDragName("scythe");
equip.dropTo(6);
jWaitDrop(actionTimeout);
}
}
function equipShovel() { // From scythe
var equip = checkEquipment();
var shovel = inventory.getItems("shovel")[0];
if (!shovel) return;
if (equip.resName(6).indexOf("scythe") >= 0) {
dropItem(shovel.coord().add(0, 2));
equip.takeAt(6);
jWaitDrag(actionTimeout);
inventory.drop(shovel.coord());
jSleep(1000);
waitDragName("shovel");
equip.dropTo(6);
jWaitDrop(actionTimeout);
}
}
function plowTile() {
drinkWater();
equipShovel();
jSendAction("plow");
jWaitCursor("dig", actionTimeout);
jOffsetClick(jCoord(0, 0), 1, 0);
jWaitProgress();
jOffsetClick(jCoord(0, 0), 3, 0);
jWaitCursor("arw", actionTimeout);
}
function sayArea(text) {
var chats = jGetChats();
for (var i = 0; i < chats.length; i++) {
if (chats[i].chatName().indexOf("Area Chat") >= 0) {
chats[i].sendMessage(text);
break;
}
}
}
function sortFunction2(a, b) {
if (!a.isActual() || !b.isActual()) return 0;
else return a.quality() - b.quality();
}
function sortFunction(a, b) {
if (!a.isActual() || !b.isActual()) return 0;
if (a.quality() < b.quality()) return 1;
if (a.quality() > b.quality()) return -1;
return 0;
}
function waitInventory(wnd, index) {
while (wnd.getInventories().length <= 0) {
jSleep(100);
}
return wnd.getInventories()[index];
}
function plantNewCrop(harv, notrecursive) {
jSleep(300);
inventory = checkInventory();
var plantedSeed = null;
var windows = jGetWindows("Seedbag");
var seedbags = inventory.getItems("invobjs/bag-seed-f");
if (seedbags.length > 0) {
var seeds = [];
for (var i = 0; i < windows.length; i++) {
var inv = waitInventory(windows[i], 0);
if (inv) {
var bufseeds = inv.getItems(harv.cropSeedName);
for (var j = 0; j < bufseeds.length; j++) {
seeds.push(bufseeds[j]);
}
}
}
var invseeds = inventory.getItems(harv.cropSeedName);
for (var j = 0; j < invseeds.length; j++) {
seeds.push(invseeds[j]);
}
var sorted_seeds = seeds.sort(sortFunction);
plantedSeed = sorted_seeds[0];
} else {
var invseeds = inventory.getItems(harv.cropSeedName);
if (invseeds.length > 0) {
inventory.sortItems(invseeds, "quality", true);
plantedSeed = invseeds[0];
}
}
if (plantedSeed) {
// Plow tile if needed
if (jGetTileType(jCoord(0, 0)) != 9) {
plowTile();
}
if (plantedSeed.isActual()) {
plantedSeed.take();
jWaitDrag();
jInteractClick(jCoord(0, 0), 0);
if (!jWaitDrop(cannotPlantTimeout)) {
jWaitDrop();
if (notrecursive) return;
plowTile();
plantNewCrop(harv, true);
}
} else {
if (!notrecursive) plantNewCrop(harv, true);
else jPrint("Double fail on non-actual seed");
}
}
}
function waitPFEndMove() {
while (true) {
jWaitEndMove();
jSleep(500);
if (!jIsMoving()) {
return;
}
}
}
function main() {
jDropLastWindow();
openAllSeedbags();
var blist = ["Carrot", "Poppy", "Wheat", "Hemp", "Beetroot", "Grapes", "Tea", "Flax", "Pepper", "Peapods", "Hops", "Exit"];
var selectWindow = jGUIWindow(jCoord(250, 250), jCoord(110, blist.length * 25 + 15), "Farming");
var label = jGUILabel(selectWindow, jCoord(5, 5), "Select crop type:");
for(var i = 0; i < blist.length; i++)
jGUIButton(selectWindow, jCoord(5, 25 + i*25), 100, blist[i]);
selectWindow.toggleCloseButton();
var btext = selectWindow.waitButtonClick();
jPrint("test " + btext);
if(btext == blist[0]) harvester = new CarrotHarvester();
if(btext == blist[1]) harvester = new PoppyHarvester();
if(btext == blist[2]) harvester = new WheatHarvester();
if(btext == blist[3]) harvester = new HempHarvester();
if(btext == blist[4]) harvester = new BeetHarvester();
if(btext == blist[5]) {
selectWindow.destroy();
harvester = new WineHarvester();
if(!harvester.selectObjects()) return;
if(!harvester.selectRect()) return;
if(!harvester.processHarvesting()) return;
harvester.plantGrapes();
return;
}
if(btext == blist[6]) {
harvester = new TeaHarvester();
if(!harvester.selectObjects()) return;
}
if(btext == blist[7]) harvester = new FlaxHarvester();
if(btext == blist[8]) harvester = new PepperHarvester();
if(btext == blist[9]) harvester = new PeapodHarvester();
if(btext == blist[10]) harvester = new HopsHarvester();
if(btext == blist[blist.length - 1]) {selectWindow.destroy(); return;}
selectWindow.destroy();
while (!stopFlag) {
var crop = findCrop(harvester);
if (crop == -1) break; // No crops found
drinkWater();
equipScythe();
if (!jIsPathFree(crop.position())) {
resetCursor();
jPFMove(crop.position());
jWaitStartMove();
waitPFEndMove();
while (jIsMoving() || jMyCoords().dist(crop.position()) > 1) {
jSleep(100);
}
}
jSendAction("harvest");
jWaitCursor("harvest", actionTimeout);
jDoClick(crop.getID(), 1, 0);
jWaitProgress();
harvester.processHarvestedGoods();
plantNewCrop(harvester, false);
}
}
main();-
Arcanist
- Posts: 2664
- Joined: Mon Mar 19, 2012 2:01 pm
Re: Union Client Scripts
APX Farmer with all crops, grapes still not fixed.
For pumpkins, have seeds in a seedbag.
For pumpkins, have seeds in a seedbag.
Code: Select all
//#! name = Farmer
//#! uniq = farmer_apxproductions
//#! icon = gfx/invobjs/seed-hops
// Globals
var inventory = checkInventory();
var harvester;
// Settings
var actionTimeout = 1000 * 60 * 2; // Lag timeout
var cannotPlantTimeout = 1000 * 10; // Non-plowed tile timeout
var cropRadius = 3; // Ðàäèóñ â êîòîðì èäåò ïîèñê (âåðõ, ïðàâî, íèç, ëåâî)
// Flags
var stopFlag = false;
/* =========================================================================== */
/* ============================== ÌÎÐÊÎÂÊÀ ============================== */
/* =========================================================================== */
function CarrotHarvester() {
this.cropName = "plants/carrot"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/carrot"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 4; // Ñòàäèÿ îáðàáîòêè
}
CarrotHarvester.prototype.processHarvestedGoods = function() {
inventory = checkInventory();
var seeds = inventory.getItems(this.cropSeedName);
var free = inventory.freeSlots();
var i = 0;
if (free < 3) {
inventory.sortItems(seeds, "quality", false);
for (i = 0; i < 3 - free; i++) {
// Åñòü ìîðêîâü åñëè ãîëîäåí
if (jGetHungry() < 50) {
if (seeds[i].isActual()) {
seeds[i].iact();
jWaitPopup(actionTimeout);
jSleep(1000);
jSelectContextMenu("Eat");
waitUnActual(seeds[i]);
}
}
// Âûáðîñèòü ëèøêó
if (seeds[i].isActual()) {
seeds[i].drop();
}
}
}
};
/* =========================================================================== */
/* ============================== ÑÂÅÊËÀ ============================== */
/* =========================================================================== */
function BeetHarvester() {
this.cropName = "plants/beetroot"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/beetroot"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
BeetHarvester.prototype.processHarvestedGoods = function() {
inventory = checkInventory();
var seeds = inventory.getItems(this.cropSeedName);
var free = inventory.freeSlots();
var i = 0;
//dropsleaves
var leaves = inventory.getItems("beetrootleaves");
if(leaves.length > 0)
if(leaves[0].isActual())
leaves[0].dropSuchAll();
while(leaves.length > 0)
{
leaves = inventory.getItems("beetrootleaves");
jSleep(500);
}
if (free < 6) {
inventory.sortItems(seeds, "quality", false);
for (i = 0; i < 4 - free; i++) {
if (jGetHungry() < 1) {
if (seeds[i].isActual()) {
seeds[i].iact();
jWaitPopup(actionTimeout);
jSelectContextMenu("Eat");
waitUnActual(seeds[i]);
}
}
if (seeds[i].isActual()) {
seeds[i].drop();
}
}
}
};
/* =========================================================================== */
/* ============================== ÂÈÍÎÃÐÀÄ ============================== */
/* =========================================================================== */
function WineHarvester() {
this.cropName = "plants/wine"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-grape"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.packName = "invobjs/grapes";
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
this.barrelID = 0; //id of barrel
this.pressID = 0; //id of winepress
this.containerID = 0;
this.startCoord = jCoord(0, 0);
this.fieldSize = jCoord(0, 0);
this.offsMove = jCoord(2, 0);
}
WineHarvester.prototype.selectObjects = function() {
var bar = jSelectObject("Select barrel...");
if(bar.name().indexOf("barrel") == -1)
{
jToConsole("ERROR: This is not a barrel!");
return false;
}
else this.barrelID = bar;
var pr = jSelectObject("Select winepress...");
if(pr.name().indexOf("winepress") == -1)
{
jToConsole("ERROR: This is not a press!");
return false;
}
else this.pressID = pr;
var cnt = jSelectObject("Select container (chest/lchest)...");
if(cnt.name().indexOf("cclosed") == -1 && cnt.name().indexOf("lchest") == -1)
{
jToConsole("ERROR: This is not a container!");
return false;
}
else this.containerID = cnt;
return true;
}
WineHarvester.prototype.selectRect = function() {
var offs = jCoord(0, 0);
var size = jCoord(1, 1);
var confirm = false;
jDrawGroundRect(offs, size);
var blist = ["West", "East", "North", "South", "Inc width", "Inc height", "Dec width", "Dec height", "Confirm", "Exit"];
var selectWindow = jGUIWindow(jCoord(250, 250), jCoord(105, blist.length * 25 + 15), "Test");
var label = jGUILabel(selectWindow, jCoord(5, 5), "Select grapes area.");
for(var i = 0; i < blist.length; i++)
jGUIButton(selectWindow, jCoord(5, 25 + i*25), 100, blist[i]);
selectWindow.toggleCloseButton();
var btext = "";
while(btext != "Exit"){
btext = selectWindow.waitButtonClick();
if(btext == blist[0]) offs.x--;
if(btext == blist[1]) offs.x++;
if(btext == blist[2]) offs.y--;
if(btext == blist[3]) offs.y++;
if(btext == blist[4]) size.x++;
if(btext == blist[5]) size.y++;
if(btext == blist[6]) if(size.x > 1) size.x--;
if(btext == blist[7]) if(size.y > 1) size.y--;
if(btext == blist[8]) {confirm = true; break;}
jDrawGroundRect(offs, size);
}
selectWindow.destroy();
jDrawGroundRect(offs, jCoord(0, 0));
this.startCoord = jMyCoords().add(offs.mul(11));
this.fieldSize = size;
return confirm;
}
WineHarvester.prototype.processHarvesting = function() {
var result = false;
var grapes = jGetObjectsInRect(this.startCoord, this.fieldSize, this.cropStage, [this.cropName]);
inventory = checkInventory();
var cuts = Math.floor((inventory.freeSlots() - 1)/3); //õóéïèçäà
if(cuts > 8) cuts = 8;
var currentgrape = 0;
while(1)
{
if(currentgrape >= grapes.length) {result = true; break;}
//cursor
if(!jIsCursor("harvest")) {
jSendAction("harvest");
jWaitCursor("harvest", actionTimeout);
}
//harvesting grapes
for(var i = 0; i < cuts; i++)
{
if(jGetStamina() < 50) drinkWater();
if(currentgrape >= grapes.length) break;
jDoClick(grapes[currentgrape], 1, 0);
jWaitProgress(actionTimeout);
currentgrape++;
}
//got pack of grapes
resetCursor();
//goes to press
jAbsClick(this.pressID.position().add(this.offsMove.mul(11)), 1, 0);
jWaitMove(actionTimeout);
jDoClick(this.pressID, 3, 0);
jWaitWindow("Winepress", actionTimeout);
//no window in lag/etc
jSleep(100);
if(!jHaveWindow("Winepress")) {result = false; break;}
//transfers all grapes to winepress
inventory.getItems(this.packName)[0].transferSuchAll();
//waits transfering
while(inventory.getItems(this.packName).length > 0)
jSleep(300);
//making juice
jGetWindow("Winepress").pushButton(1);
while(jGetWindow("Winepress").getInventories()[0].getItems(this.packName).length > 0)
jSleep(500);
//lifts press
var pc = this.pressID.position();// memorizing press coords
jSendAction("carry");
jWaitCursor("chi", actionTimeout);
//lag
if(!jIsCursor("chi")) {result = false; break;}
jDoClick(this.pressID, 1, 0);
jSleep(1500);
/*while(!jAvatarIsCarrying(jGetMyID()))
jSleep(200);*/
//juice to barrel
jDoClick(this.barrelID, 3, 0);
jWaitMove(actionTimeout);
jSleep(2000);
//placing press back
jAbsClick(pc, 3, 0);
jWaitMove(actionTimeout);
/*while(jAvatarIsCarrying(jGetMyID()))
jSleep(200);*/
//getting seeds from press
jDoClick(this.pressID, 3, 0);
jWaitWindow("Winepress", actionTimeout);
//no window in lag/etc
jSleep(100);
if(!jHaveWindow("Winepress")) {result = false; break;}
//transfer to pack seeds
jGetWindow("Winepress").getInventories()[0].getItems("")[0].transferSuchAll();
while(jGetWindow("Winepress").getInventories()[0].getItems("").length > 0)
jSleep(200);
//offset move
jMoveStep(this.offsMove);
jWaitMove(actionTimeout);
//going to lchect
var lc = this.containerID.position().add(this.offsMove.mul(11));
jAbsClick(lc, 1, 0);
jWaitMove(actionTimeout);
jDoClick(this.containerID, 3, 0);
jWaitWindow("Chest", actionTimeout);
//no window in lag/etc
jSleep(100);
if(!jHaveWindow("Chest")) {result = false; break;}
var bags = jGetWindow("Chest").getInventories()[0].getItems("invobjs/bag-seed");
var cbag = 0; //current bag
inventory = checkInventory();
//transferring seeds, btw i hate loftar
while(inventory.getItems(this.cropSeedName).length >= 1)
{
if(cbag >= bags.length) {result = true; break;}
var cnt = inventory.getItems(this.cropSeedName).length; //inventory count
bags[cbag].iact();
//opens seedbag
while(!jHaveWindow("Seedbag"))
jSleep(200);
//check for free slots
if(jGetWindow("Seedbag").getInventories()[0].freeSlots() == 0)
{
jGetWindow("Seedbag").close();
while(jHaveWindow("Seedbag"))
jSleep(200);
cbag++;
continue;
}
jSleep(100);
var free = jGetWindow("Seedbag").getInventories()[0].freeSlots(); //free slots in seedbag
inventory.getItems(this.cropSeedName)[0].transferSuchAll();
while(inventory.getItems(this.cropSeedName).length > Math.abs(cnt - free))
jSleep(200);
jGetWindow("Seedbag").close();
while(jHaveWindow("Seedbag"))
jSleep(200);
cbag++;
}
//èäèòå íà õóé, ìíå ëåíü ÷òîòî äåëàòü ñ ýòèìè ñåìåíàìè
if(result == true) {inventory.getItems(this.cropSeedName)[0].dropSuchAll(); jSleep(1000); break;} //break if all bags r full
//checks barrel
var bc = this.barrelID.position().add(this.offsMove.mul(11));
jAbsClick(bc, 1, 0);
jWaitMove(actionTimeout);
jDoClick(this.barrelID, 3, 0);
while(!jHaveWindow("Barrel"))
jSleep(500);
//barrel label
var blbl = jGetWindow("Barrel").getLabelText(1);
if(blbl.indexOf("100.0") != -1) {result = true; break;} //breaks if barrel is full
}//1
return result;
}
WineHarvester.prototype.plantGrapes = function() {
jMoveStep(this.offsMove);
jWaitMove(actionTimeout);
//going to lchect
var lc = this.containerID.position().add(this.offsMove.mul(11));
jAbsClick(lc, 1, 0);
jWaitMove(actionTimeout);
jDoClick(this.containerID, 3, 0);
jWaitWindow("Chest", actionTimeout);
//no window in lag/etc
jSleep(100);
if(!jHaveWindow("Chest")) return false;
jGetWindow("Chest").getInventories()[0].getItems("invobjs/bag-seed-f")[0].transferSuchAll();
jSleep(1000);
inventory = checkInventory();
var fullbags = inventory.getItems("invobjs/bag-seed-f");
for(var i = 0; i < fullbags.length; i++)
fullbags[i].iact();
while(jGetWindows("Seedbag").length < fullbags.length)
jSleep(200);
var swnds = jGetWindows("Seedbag");
var allseeds = [];
for(var i = 0; i < swnds.length; i++)
{
var sinvs = swnds[i].getInventories()[0].getItems(this.cropSeedName);
for(var j = 0; j < sinvs.length; j++)
allseeds.push(sinvs[j]);
}
//allseeds.sort(sortFunction2); //à Àðõ õóé!
var cseed = 0;
var overflow = false;
jAbsClick(jTilify(this.startCoord), 1, 0);
jWaitMove(actionTimeout);
for(var i = 0; i < this.fieldSize.x; i++) {
if(overflow == true) break;
for(var j = 0; j < this.fieldSize.y; j++) {
if(cseed >= allseeds.length) {overflow = true; break;}
if(jGetStamina() < 50) drinkWater();
jAbsClick(this.startCoord.add(i*11, j*11));
jWaitMove(actionTimeout);
if(jFindObjectByName(this.cropName, 3) != 0) continue;
plantNewCrop(this, false);
/*if(!jGetTileType(jCoord(0, 0)) != 9) plowTile();
allseeds[cseed].take();
jWaitDrag(actionTimeout);
jAbsInteractClick(jCoord(0, 0), 3, 0);
jWaitDrop(actionTimeout);
jSleep(100);*/
cseed++;
}
jSleep(100);
}
jToConsole("test");
}
/* =========================================================================== */
/* ============================== ÊÎÍÎÏËß ============================== */
/* =========================================================================== */
function HempHarvester() {
this.cropName = "plants/hemp"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-hemp"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 4; // Ñòàäèÿ îáðàáîòêè
bagsSeedsSorter(this);
}
HempHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
/* =========================================================================== */
/* ============================== ÊÎÍÎÏËß ============================== */
/* =========================================================================== */
function PepperHarvester() {
this.cropName = "plants/pepper"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-pepper"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
bagsSeedsSorter(this);
}
PepperHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
/* =========================================================================== */
/* ============================== ËÅÍ ============================== */
/* =========================================================================== */
function FlaxHarvester() {
this.cropName = "plants/flax"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/flaxseed"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
FlaxHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
/* =========================================================================== */
/* ============================== ÏÅÐÅÖ ============================== */
/* =========================================================================== */
function PepperHarvester() {
this.cropName = "plants/pepper"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-pepper"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
PepperHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
/* =========================================================================== */
/* ============================== ×ÀÉ ============================== */
/* =========================================================================== */
//function TeaHarvester() {
// this.cropName = "plants/tea"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
// this.cropSeedName = "invobjs/seed-tea"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
// this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
// this.leaveName = "invobjs/tea-fresh";
// this.containerID = 0;
//}
//TeaHarvester.prototype.processHarvestedGoods = function() {
// bagsSeedsSorter(this);
//};
//TeaHarvester.prototype.selectObjects = function() {
// var cnt = jSelectObject("Select container (chest/lchest)...");
// if(cnt.name().indexOf("cclosed") == -1 && cnt.name().indexOf("lchest") == -1)
// {
// jToConsole("ERROR: This is not a container!");
// return false;
// }
// else this.containerID = cnt;
// return true;
//}
//
function TeaHarvester() {
this.cropName = "plants/tea"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-tea"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
TeaHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
inventory = checkInventory();
//dropsleaves
var leaves = inventory.getItems("tea-fresh");
if(leaves.length > 0)
if(leaves[0].isActual())
leaves[0].dropSuchAll();
while(leaves.length > 0)
{
leaves = inventory.getItems("tealeaves");
jSleep(500);
}
};
/* =========================================================================== */
/* ============================== ÌÀÊ ============================== */
/* =========================================================================== */
function PoppyHarvester() {
this.cropName = "plants/poppy"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-poppy"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 4; // Ñòàäèÿ îáðàáîòêè
}
PoppyHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
/* =========================================================================== */
/* ============================== ÏØÅÍÈ×ÊÀ ============================== */
/* =========================================================================== */
function WheatHarvester() {
this.cropName = "plants/wheat"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "wheat"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
WheatHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
/* =========================================================================== */
/* ============================== ÌÎÐÊÎÂÊÀ ============================== */
/* =========================================================================== */
function HopsHarvester() {
this.cropName = "plants/hops"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-hops"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
HopsHarvester.prototype.processHarvestedGoods = function() {
inventory = checkInventory();
var seeds = inventory.getItems(this.cropSeedName);
var free = inventory.freeSlots();
var i = 0;
if (free < 3) {
inventory.sortItems(seeds, "quality", false);
for (i = 0; i < 3 - free; i++) {
// Åñòü ìîðêîâü åñëè ãîëîäåí
if (jGetHungry() < 1) {
if (seeds[i].isActual()) {
seeds[i].iact();
jWaitPopup(actionTimeout);
jSelectContextMenu("Eat");
waitUnActual(seeds[i]);
}
}
// Âûáðîñèòü ëèøêó
if (seeds[i].isActual()) {
seeds[i].drop();
}
}
}
};
/* =========================================================================== */
/* ============================== ÌÎÐÊÎÂÊÀ ============================== */
/* =========================================================================== */
function PeasHarvester() {
this.cropName = "plants/peas"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/peapod"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 4; // Ñòàäèÿ îáðàáîòêè
}
PeasHarvester.prototype.processHarvestedGoods = function() {
inventory = checkInventory();
var seeds = inventory.getItems(this.cropSeedName);
var free = inventory.freeSlots();
var i = 0;
if (free < 3) {
inventory.sortItems(seeds, "quality", false);
for (i = 0; i < 3 - free; i++) {
// Åñòü ìîðêîâü åñëè ãîëîäåí
if (jGetHungry() < 1) {
if (seeds[i].isActual()) {
seeds[i].iact();
jWaitPopup(actionTimeout);
jSelectContextMenu("Eat");
waitUnActual(seeds[i]);
}
}
// Âûáðîñèòü ëèøêó
if (seeds[i].isActual()) {
seeds[i].drop();
}
}
}
};
/* =========================================================================== */
/* ============================== ÌÎÐÊÎÂÊÀ ============================== */
/* =========================================================================== */
function OnionsHarvester() {
this.cropName = "plants/onion"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/onion"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
OnionsHarvester.prototype.processHarvestedGoods = function() {
inventory = checkInventory();
var seeds = inventory.getItems(this.cropSeedName);
var free = inventory.freeSlots();
var i = 0;
if (free < 3) {
inventory.sortItems(seeds, "quality", false);
for (i = 0; i < 3 - free; i++) {
// Åñòü ìîðêîâü åñëè ãîëîäåí
if (jGetHungry() < 1) {
if (seeds[i].isActual()) {
seeds[i].iact();
jWaitPopup(actionTimeout);
jSelectContextMenu("Eat");
waitUnActual(seeds[i]);
}
}
// Âûáðîñèòü ëèøêó
if (seeds[i].isActual()) {
seeds[i].drop();
}
}
}
};
/* =========================================================================== */
/* ============================== ÌÎÐÊÎÂÊÀ ============================== */
/* =========================================================================== */
function TobaccoHarvester() {
this.cropName = "plants/tobacco"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-tobacco"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
}
TobaccoHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
inventory = checkInventory();
//dropsleaves
var leaves = inventory.getItems("tobacco-fresh");
if(leaves.length > 0)
if(leaves[0].isActual())
leaves[0].dropSuchAll();
while(leaves.length > 0)
{
leaves = inventory.getItems("tobacco-fresh");
jSleep(500);
}
};
/* =========================================================================== */
/* ============================== ÑÂÅÊËÀ ============================== */
/* =========================================================================== */
function PumpkinHarvester() {
this.cropName = "plants/pumpkin"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-pumpkin"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 6; // Ñòàäèÿ îáðàáîòêè
}
PumpkinHarvester.prototype.processHarvestedGoods = function() {
inventory = checkInventory();
var seeds = inventory.getItems(this.cropSeedName);
var free = inventory.freeSlots();
var i = 0;
//dropsleaves
var leaves = inventory.getItems("pumpkin");
if(leaves.length > 0){
resetCursor();
jGetWindow("Inventory").getInventories()[0].getItems("pumpkin")[0].iact();
jWaitPopup();
jSelectContextMenu("Slice"); }
jSleep(500);
var flesh = inventory.getItems("pumpkinflesh");
var seed = inventory.getItems("seed-pumpkin");
if(flesh[0].isActual()) {
flesh[0].dropSuchAll();}
if(seed[0].isActual()) {
seed[0].dropSuchAll();}
while(leaves.length > 0)
{
leaves = inventory.getItems("pumpkin");
jSleep(500);
}
};
/* =========================================================================== */
/* ============================== ÊÎÍÎÏËß ============================== */
/* =========================================================================== */
function CarrotSeedHarvester() {
this.cropName = "plants/carrot"; // Èìÿ êðîïà êîòîðûé íóæíî õàðâåñòèòü
this.cropSeedName = "invobjs/seed-carrot"; // Èìÿ ñåìå÷êè êîòîðóþ íóæíî ñàæàòü
this.cropStage = 3; // Ñòàäèÿ îáðàáîòêè
bagsSeedsSorter(this);
}
CarrotSeedHarvester.prototype.processHarvestedGoods = function() {
bagsSeedsSorter(this);
};
/*==============================Êðîï÷èêè============================================*/
function bagsSeedsSorter(harv) {
inventory = checkInventory();
var bags = inventory.getItems("invobjs/bag-seed");
var free = inventory.freeSlots();
var fslots = 0;
if (bags.length > 0) {
var windows = jGetWindows("Seedbag");
if (windows.length > 0) {
var seeds = [];
var maxseedscount = bags.length * 9;
//getting seeds from all seedbags into array
for (var i = 0; i < windows.length; i++) {
var inv = waitInventory(windows[i], 0);
fslots += inv.freeSlots();
var bufseeds = inv.getItems(harv.cropSeedName);
for (var j = 0; j < bufseeds.length; j++) {
seeds.push(bufseeds[j]);
}
}
//from inventory to same array
var invseeds = inventory.getItems(harv.cropSeedName);
for (var j = 0; j < invseeds.length; j++) {
seeds.push(invseeds[j]);
}
//calculation quality of all seeds
var allq = 0;
for (var j = 0; j < seeds.length; j++) {
allq += seeds[j].quality();
}
//medium quality
var mediumrange = (allq / seeds.length) - 1;
//correcting medium q
//too many seeds
if(fslots < 9)
mediumrange += 1;
if (seeds.length > maxseedscount * 0.75) {
for (var j = 0; j < seeds.length; j++) {
if (seeds[j].quality() <= mediumrange) seeds[j].drop();
}
organizeBags(inventory, harv.cropSeedName);
}
}//bags windows
}
if (inventory.freeSlots() < 4 && bags.length < 1) {
inventory.sortItems(inventory.getItems(harv.cropSeedName), "quality", false);
for (i = 0; i < 3 - free; i++) {
if (seeds[i].isActual()) {
seeds[i].drop();
}
}
}
}
function organizeBags(inv, name) {
var bagw = jGetWindows("Seedbag");
if(bagw.length < 1) return;
var fullb, nextb;
fullb = 0;
nextb = bagw.length - 1;
while(1)
{
if(fullb == nextb) break; //breaks if filling bag == last bag
if(bagw[fullb].getInventories()[0].freeSlots() == 0) {
fullb++;
continue;
}
if(bagw[nextb].getInventories()[0].freeSlots() == 9) {
nextb--;
continue;
}
var freeSlot = bagw[fullb].getInventories()[0].freeSlotsCoords()[0]; //getting 1st empty slot at current filling bag
var seed = bagw[nextb].getInventories()[0].getItems(name)[0]; //getting 1st seed at current emptying bag
seed.take();
jWaitDrag();
bagw[fullb].getInventories()[0].drop(freeSlot); //drops to filling bag
jWaitDrop();
}
}
function openAllSeedbags() {
inv = checkInventory();
var bags = inv.getItems("invobjs/bag-seed");
if(bags.length < 1)
return;
for(var i = 0; i < bags.length; i++)
if(bags[i].isActual())
bags[i].iact();
while(jGetWindows("Seedbag").length != bags.length)
jSleep(300);
}
function waitUnActual(item) {
while (item.isActual()) {
jSleep(100);
}
}
function resetCursor() {
if (!jIsCursor("arw")) {
jAbsClick(jCoord(0, 0), 3, 0);
jWaitCursor("arw", actionTimeout);
}
}
function checkInventory() {
if(!jHaveWindow("Inventory")) {
jToggleInventory();
while(!jHaveWindow("Inventory"))
jSleep(100);
}
return jGetWindow("Inventory").getInventories()[0];
}
function checkEquipment() {
if(!jHaveWindow("Equipment")) {
jToggleEquipment();
while(!jHaveWindow("Equipment"))
jSleep(100);
}
return jGetJSEquip();
}
function waitInventoryObject(inv, objname) {
while (true) {
var objs = inv.getItems(objname);
if (objs.length > 0) break;
else jSleep(100);
}
}
function waitUnActual(item) {
while (item.isActual()) {
jSleep(100);
}
}
function drinkWater() {
if (jGetStamina() > 50) return;
inventory = checkInventory();
var buckets = inventory.getItems("bucket-water");
if (buckets.length > 0) {
inventory.sortItems(buckets, "amount", false);
var bucket = buckets[0];
var bucket_coord = bucket.coord();
if (bucket.isActual()) {
bucket.take();
jWaitDrag();
var flasks = inventory.getItems("waterflask", "waterskin");
if (flasks.length > 0) {
var flask = flasks[0];
if (flask.isActual()) {
flask.itemact(0);
jSleep(500);
inventory.drop(bucket_coord);
jWaitDrop();
}
}
}
}
var flasks = inventory.getItems("waterflask", "waterskin");
if (flasks.length > 0) {
var flask = flasks[0];
if (flask.isActual()) {
flask.iact();
if (jWaitPopup(actionTimeout)) {
jSelectContextMenu("Drink");
jWaitProgress();
} else {
// No water
stopFlag = true;
}
}
}
}
function TileInfo(crd) {
this.coord = crd;
}
function findCrop(harv) {
var objid = 0;
for (var i = 0; i < cropRadius; i++) {
objid = (jFindObjectWithOffset(harv.cropName, 1, jCoord(0, i))); // down
if (objid && objid.blob(0) == harv.cropStage) return objid;
}
for (var i = 0; i < cropRadius; i++) {
objid = jFindObjectWithOffset(harv.cropName, 1, jCoord(0, -i)); // up
if (objid && objid.blob(0) == harv.cropStage) return objid;
}
for (var i = 0; i < cropRadius; i++) {
objid = jFindObjectWithOffset(harv.cropName, 1, jCoord(i, 0)); // right
if (objid && objid.blob(0) == harv.cropStage) return objid;
}
for (var i = 0; i < cropRadius; i++) {
objid = jFindObjectWithOffset(harv.cropName, 1, jCoord(-i, 0));// left
if (objid && objid.blob(0) == harv.cropStage) return objid;
}
objid = jFindObjectByName(harv.cropName, cropRadius);
if (objid.blob(0) != harv.cropStage) objid = -1;
return objid;
}
function dropItem(coord) {
var items = inventory.getItems("");
for (var i = 0; i < items.length; i++) {
if (items[i].coord().x == coord.x && items[i].coord().y == coord.y) {
items[i].drop();
break;
}
}
}
function waitDragName(name) {
while (true) {
var item = jGetDraggingItem();
if (item != null) {
jSleep(500)
if (item.resName() != null) {
if (item.resName().indexOf(name) >= 0) {
break;
} else {
jSleep(100);
}
} else jSleep(100);
} else {
break;
}
}
}
function equipScythe() {
var equip = checkEquipment();
var scythe = inventory.getItems("scythe")[0];
if (!scythe) return;
if (equip.resName(6).indexOf("shovel") >= 0) {
equip.takeAt(6);
jWaitDrag(actionTimeout);
inventory.drop(scythe.coord());
jSleep(1000);
waitDragName("scythe");
jSleep(1000);
equip.dropTo(6);
jWaitDrop(actionTimeout);
}
}
function equipShovel() { // From scythe
var equip = checkEquipment();
var shovel = inventory.getItems("shovel")[0];
if (!shovel) return;
if (equip.resName(6).indexOf("scythe") >= 0) {
dropItem(shovel.coord().add(0, 2));
equip.takeAt(6);
jWaitDrag(actionTimeout);
inventory.drop(shovel.coord());
jSleep(1000);
waitDragName("shovel");
equip.dropTo(6);
jWaitDrop(actionTimeout);
}
}
function plowTile() {
drinkWater();
equipShovel();
jSendAction("plow");
jWaitCursor("dig", actionTimeout);
jOffsetClick(jCoord(0, 0), 1, 0);
jWaitProgress();
jOffsetClick(jCoord(0, 0), 3, 0);
jWaitCursor("arw", actionTimeout);
}
function sayArea(text) {
var chats = jGetChats();
for (var i = 0; i < chats.length; i++) {
if (chats[i].chatName().indexOf("Area Chat") >= 0) {
chats[i].sendMessage(text);
break;
}
}
}
function sortFunction2(a, b) {
if (!a.isActual() || !b.isActual()) return 0;
else return a.quality() - b.quality();
}
function sortFunction(a, b) {
if (!a.isActual() || !b.isActual()) return 0;
if (a.quality() < b.quality()) return 1;
if (a.quality() > b.quality()) return -1;
return 0;
}
function waitInventory(wnd, index) {
while (wnd.getInventories().length <= 0) {
jSleep(100);
}
return wnd.getInventories()[index];
}
function plantNewCrop(harv, notrecursive) {
jSleep(300);
inventory = checkInventory();
var plantedSeed = null;
var windows = jGetWindows("Seedbag");
var seedbags = inventory.getItems("invobjs/bag-seed-f");
if (seedbags.length > 0) {
var seeds = [];
for (var i = 0; i < windows.length; i++) {
var inv = waitInventory(windows[i], 0);
if (inv) {
var bufseeds = inv.getItems(harv.cropSeedName);
for (var j = 0; j < bufseeds.length; j++) {
seeds.push(bufseeds[j]);
}
}
}
var invseeds = inventory.getItems(harv.cropSeedName);
for (var j = 0; j < invseeds.length; j++) {
seeds.push(invseeds[j]);
}
var sorted_seeds = seeds.sort(sortFunction);
plantedSeed = sorted_seeds[0];
} else {
var invseeds = inventory.getItems(harv.cropSeedName);
if (invseeds.length > 0) {
inventory.sortItems(invseeds, "quality", true);
plantedSeed = invseeds[0];
}
}
if (plantedSeed) {
// Plow tile if needed
if (jGetTileType(jCoord(0, 0)) != 9) {
plowTile();
}
if (plantedSeed.isActual()) {
plantedSeed.take();
jWaitDrag();
jInteractClick(jCoord(0, 0), 0);
if (!jWaitDrop(cannotPlantTimeout)) {
jWaitDrop();
if (notrecursive) return;
plowTile();
plantNewCrop(harv, true);
}
} else {
if (!notrecursive) plantNewCrop(harv, true);
else jPrint("Double fail on non-actual seed");
}
}
}
function waitPFEndMove() {
while (true) {
jWaitEndMove();
jSleep(500);
if (!jIsMoving()) {
return;
}
}
}
function main() {
jDropLastWindow();
openAllSeedbags();
var blist = ["Carrot", "Poppy", "Wheat", "Hemp", "Beetroot", "Grapes", "Tea", "Flax", "Pepper","Hops", "Carrot Seed","Peas","Onions","Tobacco","Pepper","Pumpkin", "Exit"];
var selectWindow = jGUIWindow(jCoord(250, 250), jCoord(110, blist.length * 25 + 15), "Farming");
var label = jGUILabel(selectWindow, jCoord(5, 5), "Select crop type:");
for(var i = 0; i < blist.length; i++)
jGUIButton(selectWindow, jCoord(5, 25 + i*25), 100, blist[i]);
selectWindow.toggleCloseButton();
var btext = selectWindow.waitButtonClick();
if(btext == blist[0]) harvester = new CarrotHarvester();
if(btext == blist[1]) harvester = new PoppyHarvester();
if(btext == blist[2]) harvester = new WheatHarvester();
if(btext == blist[3]) harvester = new HempHarvester();
if(btext == blist[4]) harvester = new BeetHarvester();
if(btext == blist[5]) {
selectWindow.destroy();
harvester = new WineHarvester();
if(!harvester.selectObjects()) return;
if(!harvester.selectRect()) return;
if(!harvester.processHarvesting()) return;
harvester.plantGrapes();
return;
}
if(btext == blist[6]) {
harvester = new TeaHarvester();
//if(!harvester.selectObjects()) return;
}
if(btext == blist[7]) harvester = new FlaxHarvester();
if(btext == blist[8]) harvester = new PepperHarvester();
if(btext == blist[9]) harvester = new HopsHarvester();
if(btext == blist[10]) harvester = new CarrotSeedHarvester();
if(btext == blist[11]) harvester = new PeasHarvester();
if(btext == blist[12]) harvester = new OnionsHarvester();
if(btext == blist[13]) harvester = new TobaccoHarvester();
if(btext == blist[14]) harvester = new PepperHarvester();
if(btext == blist[15]) harvester = new PumpkinHarvester();
if(btext == blist[blist.length - 1]) {selectWindow.destroy(); return;}
selectWindow.destroy();
while (!stopFlag) {
var crop = findCrop(harvester);
if (crop == -1) break; // No crops found
drinkWater();
equipScythe();
if (!jIsPathFree(crop.position())) {
resetCursor();
jPFMove(crop.position());
jWaitStartMove();
waitPFEndMove();
while (jIsMoving() || jMyCoords().dist(crop.position()) > 1) {
jSleep(100);
}
}
jSendAction("harvest");
jWaitCursor("harvest", actionTimeout);
jDoClick(crop.getID(), 1, 0);
jWaitProgress();
harvester.processHarvestedGoods();
plantNewCrop(harvester, false);
}
}
main();-
loic71
- Posts: 57
- Joined: Wed Feb 19, 2014 5:44 am
Re: Union Client Scripts
what was the w6 bot client yet?
Can't find it though I have some scripts for it.
Thanks for help.
Can't find it though I have some scripts for it.
Thanks for help.
-
shampizle
- Posts: 590
- Joined: Sat Oct 20, 2012 1:14 am
Re: Union Client Scripts

Anyone figure out why i cant get it working?
-
Arcanist
- Posts: 2664
- Joined: Mon Mar 19, 2012 2:01 pm
Re: Union Client Scripts
Wrong thread..
But are you sure you're using 32x client?
Try using 64x client and 64x java.
But are you sure you're using 32x client?
Try using 64x client and 64x java.
-
Strandmullen
- Posts: 452
- Joined: Sat Mar 31, 2012 11:37 pm
- Location: Sweden
Re: Union Client Scripts
I just started learning writing scripts and if anyone's interested I made a script which automates the crafting of straw dolls.
It takes straw from one cupboard, plant fibres from another, crafts the straw doll and puts it in a third cupboard.
It's one of the first scripts I've written so I'd really appreciate any suggestions.
It uses "jBotAPI" and "jPFAPI" ("jPFAPI" is a pathfinding tool I found posted earlier in this thread but I'll repost it here)
Straw doll automation
jPFAPI
It takes straw from one cupboard, plant fibres from another, crafts the straw doll and puts it in a third cupboard.
It's one of the first scripts I've written so I'd really appreciate any suggestions.
It uses "jBotAPI" and "jPFAPI" ("jPFAPI" is a pathfinding tool I found posted earlier in this thread but I'll repost it here)
Straw doll automation
Code: Select all
//#! name = Straw Dolls
//#! icon = gfx/invobjs/strawdoll
//#! uniq = strawDollsAutomation
//By Strandmullen
include ("jPFAPI");
include ("jBotAPI");
var inventory = checkInventory();
var strawContainer = jSelectObject("Select straw cupboard");
var plantFibresContainer = jSelectObject("Select plant fibres cupboard");
var strawDollContainer = jSelectObject("Select straw doll cupboard");
var strawNeeded = 4;
var plantFibresNeeded = 2;
var quit;
function getStraw(){
jPFMoveOffset_LX(strawContainer.position(), 1);
waitPFEndMove();
jDoClick(strawContainer.getID(), 3);
jWaitMove();
jWaitWindow("Cupboard");
var strawInventory = jGetWindow("Cupboard").getInventories()[0];
all = strawInventory.getItems("straw");
for (var i = 0; i < strawNeeded; i++){
one = all[i];
one.transfer();
jSleep(100);
}
}
function getPlantFibres(){
jPFMoveOffset_LX(plantFibresContainer.position(), 1);
waitPFEndMove();
jDoClick(plantFibresContainer.getID(), 3);
jWaitMove();
jWaitWindow("Cupboard");
var plantFibresInventory = jGetWindow("Cupboard").getInventories()[0];
all = plantFibresInventory.getItems("flaxfibre");
for (var i = 0; i < plantFibresNeeded; i++) {
one = all[i];
one.transfer();
jSleep(100);
}
}
function craftStrawDolls(){
jSendDoubleAction("craft", "strawdoll");
jSleep(500);
if (jIsCraftReady()) {
jCraftItem(false);
jWaitProgress();
} else {
quit = true;
}
}
function storeStrawDolls(){
inventory = checkInventory();
strawDolls = inventory.getItems("strawdoll");
strawDoll = strawDolls[0];
jPFMoveOffset_LX(strawDollContainer.position(), 1);
waitPFEndMove();
jDoClick(strawDollContainer.getID(), 3);
jWaitMove();
jWaitWindow("Cupboard");
strawDoll.transfer();
}
function main(){
while (true){
getStraw();
getPlantFibres();
craftStrawDolls();
storeStrawDolls();
}
}
main();Code: Select all
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
//LeksarPathfinder
function _pf_click(id) {
if (!jIsPathFree(jGob(id))) {
resetCursor();
if (jPFClick(id) > 0) {
if (jWaitStartMove(1000)) {
waitPFEndMove();
while (jIsMoving() || jMyCoords().dist(jObjectPos(id)) > 33) {
jSleep(100);
}
return true;
}
}
}
return false;
}
function getRandomArbitary(min, max)
{
return Math.random() * (max - min) + min;
}
function jPFMove_LX(point) {
point = jTilify(point);
var MyX = jMyCoords().x;
var MyY = jMyCoords().y;
jPFMove(point);
cycles = 0;
while (MyX != point.x || MyY != point.y)
{
jPrint("jPFMove_LX My =" + MyX + " " + MyY + " - " + point.x + " " + point.y);
jSleep(1000);
MyX = jMyCoords().x;
MyY = jMyCoords().y;
if(cycles == 10)
{
jPrint("jPFMove_LX trying to move again");
jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
jSleep(500);
jPFMove(point);
cycles = 0
}
cycles++;
}
jPrint("jPFMove ended");
}
function jPFMoveOffset_LX(point, offset) {
offsMoveS=jCoord(0,offset);
offsMoveE=jCoord(offset,0);
offsMoveW=jCoord(-offset,0);
offsMoveN=jCoord(0,-offset);
while (1) {
if(jPFMove(point.add(offsMoveS.mul(11))) > 0) {
jPFMove_LX(point.add(offsMoveS.mul(11)));
return offsMoveS;
}
if(jPFMove(point.add(offsMoveE.mul(11))) > 0) {
jPFMove_LX(point.add(offsMoveE.mul(11)));
return offsMoveE;
}
if(jPFMove(point.add(offsMoveW.mul(11))) > 0) {
jPFMove_LX(point.add(offsMoveW.mul(11)));
return offsMoveW;
}
if(jPFMove(point.add(offsMoveN.mul(11))) > 0) {
jPFMove_LX(point.add(offsMoveN.mul(11)));
return offsMoveN;
}
jPrint("jPFMoveOffset_LX can't find path");
// break;
jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
jSleep(500);
}
}
function waitPFEndMove(){
jWaitStartMove(300);
jSleep(100);
while (true) {
jWaitEndMove(10000);
jSleep(200);
if (!jIsMoving()) {
return;
}
}
}-
shampizle
- Posts: 590
- Joined: Sat Oct 20, 2012 1:14 am
Re: Union Client Scripts
anyone have a paver script?