Union Client Scripts

Forum for alternative clients, mods & discussions on the same.

Moderator: Phades

Re: Union Client Scripts

Postby Foetuses » Wed Sep 04, 2013 12:39 pm

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. :roll:
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.
Foetuses
 
Posts: 79
Joined: Tue Mar 27, 2012 11:55 pm

Re: Union Client Scripts

Postby juchan » Wed Sep 04, 2013 2:55 pm

Hi again

This mussel bot dont work.
When im in a boat i get answer (mussel auto pick up finished)
Is it depends on how far away are mussels or what?
Empty inventory is needed? or needed (wine, waterflask etc)
Need help, thanks
juchan
 
Posts: 15
Joined: Sun Aug 25, 2013 4:08 pm

Re: Union Client Scripts

Postby Foetuses » Wed Sep 04, 2013 3:49 pm

Ah, I see what might be your problem. The include statement is to "api/jBotAPI", which probably isn't where you keep your jBotAPI.japi file. This might fix it:

Code: Select all
//#! name = Mussels auto pick up
//#! tooltip = Automatically pick ups mussels around you, just get close to them and press!
//#! icon = gfx/invobjs/mussel

include("jBotAPI");

function Main(){
   while(true){
      var mussels = jFindObjectByName("mussel", 15);
      if(mussels != null && checkInventory().freeSlots() > 0){
      
               jDoClick(mussels.getID(), 3, 0);
               jSleep(100);
                  
               if(jWaitPopup(200)){jSelectContextMenu("Pick"); jWaitProgress(actionTimeout);}

      }else{jToConsole("There isn't more mussels or space in the inventory!"); break;}
   }
}

Main();


You're gonna wanna get within a good distance from the mussels for it to work, then it should automatically harvest them all for you. Clicking those sparse graphics is a pain. ;)

Edit: My own testing confirms that this script will work, so if you have any problems, PM me instead since it's on your side. You shouldn't, though. :)
Foetuses
 
Posts: 79
Joined: Tue Mar 27, 2012 11:55 pm

Re: Union Client Scripts

Postby Arcanist » Wed Sep 04, 2013 8:37 pm

Hopefully BoB dole doesn't mind me posting this :D :D

This is the final edit of the curd script.

Code: Select all
//#! name = curd mover
//#! uniq = Curd_Mover_Arcanist
//#! tooltip = moves curd
//#! icon = gfx/invobjs/cheese-curd

var inventory = checkInventory();
var inv = jGetWindows("Inventory");
var cupboard = checkCupboard();

function checkCupboard() {
   if(!jHaveWindow("Cupboard")) {
      return;
   }
   return jGetWindow("Cupboard").getInventories()[0];
}

function checkInventory() {
   if(!jHaveWindow("Inventory")) {
      jToggleInventory();
      while(!jHaveWindow("Inventory"))
         jSleep(100);
   }
   return jGetWindow("Inventory").getInventories()[0];
}

 function main() {
    inventory = checkInventory();
   var i = 0;
   var cupboard = checkCupboard();
   var buckets = inventory.getItems("cheese-curd");
   if (buckets.length > 0) {
      inventory.sortItems(buckets, "amount", false);
      var bucket = buckets[0];
      if (bucket.isActual()) {
         var flasks = cupboard.getItems("cheese-tray");
         while (1) {
           if (flasks[i].resName() != "gfx/invobjs/cheese-tray-curd") {
         var flask = flasks[i];
            bucket.take();
            jWaitDrag();
               flask.itemact(0);
               jSleep(300);
            var buckets = inventory.getItems("cheese-curd");
            var bucket = buckets[0];
            bucket.take();
            jWaitDrag();
               flask.itemact(0);
               jSleep(300);
            var buckets = inventory.getItems("cheese-curd");
            var bucket = buckets[0];
            bucket.take();
            jWaitDrag();
               flask.itemact(0);
               jSleep(300);
            var buckets = inventory.getItems("cheese-curd");
            var bucket = buckets[0];
            bucket.take();
            jWaitDrag();
               flask.itemact(0);
            var buckets = inventory.getItems("cheese-curd");
            var bucket = buckets[0];
               jSleep(300);}
            i++;
            }
         }
      }
   
   loop();
 }
 
 function transfertray() {
   inventory = checkInventory();
   var cupboard = checkCupboard();
   var buckets = cupboard.getItems("cheese-tray-curd");
   var freeSlot = inventory.freeSlotsCoords()[0];
   if (buckets.length > 0) {
      inventory.sortItems(buckets, "amount", false);
      var bucket = buckets[0];
      while (bucket.isActual()) {
         bucket.take();
         jWaitDrag();
       inventory.drop(freeSlot)
       jSleep(500)
       }
       }
       return;
       }
   


 

 
function loop() {main();}
loop()


And one I just wrote to pick up mussles.

Code: Select all
//#! name = Mussel Collector
//#! uniq = musselzzz
//#! icon = gfx/invobjs/mussel

var target_mussel = jFindObjectByName("mussel", 30)
var musselsno = target_mussel.length
var g = 0

function getNearestMussel() {
   var mussel = jGetObjects(25, jCoord(0, 0), ["herbs/mussel"]);
   var min_len = 100500;
   var objid = 0;
   for (var i = 0; i < mussel.length; i++) {
      if (trees[i].position().dist(jMyCoords()) < min_len) {
         objid = trees[i];
         min_len = mussel[i].position().dist(jMyCoords());
      }
   }
   return objid;
}
jFindObjectByName("mussel", 30)

function collector() {
         var target_mussel = target_mussel[i];
         jDoClick(target_mussel.getID(), 3, 0);
         jWaitPopup(1000);
         jSelectContextMenu("Pick");
         jWaitMove(20000);
         jSleep(200);
         jWaitEndProgress(5000);
         jSleep(200);
         
      }

      
      
function main() {      
while (musselsno > g) { collector(); jSleep(300); g++; }
   
   }
   
main()


The one posted above is much better.
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby xxlasciel » Thu Sep 05, 2013 2:14 am

Hey, quick issue, I'm new to this and I'm trying to run the 'runstarv' bot and what ends up happening is that i run 80 tiles south then immediately stop. There's also text that pops up saying "Starving Bot finished" the instant I start it.

I looked over the coding for it, and (bear with me, I have no idea how this works) it looks like there's water involved and I should be running back and forth, not just towards one location. I also tried changing the coding to move 20 units instead of 80 in a notepad document, saving it as a .jbot file and using UTF-8, however, when trying to run the bot, nothing happens.

All I want is to be able to run 10 tiles and back (and repeat) and drink water out of a waterskin (or multiple in my inventory if possible) at a certain level of stamina.

Any help is appreciated :)
xxlasciel
 
Posts: 4
Joined: Tue Sep 03, 2013 7:38 pm

Re: Union Client Scripts

Postby Arcanist » Thu Sep 05, 2013 2:18 am

download a fresh runstarve, you might have messed it up by changing it to utf-8
You need a bucked of water, and a waterflask/skin in inventory. Do you have both of those things?

If you do and this still happens, have a look in your cmd window and see what the error is.
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby julian12it » Thu Sep 05, 2013 3:38 am

Arcanist wrote:Hopefully BoB dole doesn't mind me posting this :D :D

This is the final edit of the curd script.

Code: Select all
//#! name = curd mover
//#! uniq = Curd_Mover_Arcanist
//#! tooltip = moves curd
//#! icon = gfx/invobjs/cheese-curd

var inventory = checkInventory();
var inv = jGetWindows("Inventory");
var cupboard = checkCupboard();

function checkCupboard() {
   if(!jHaveWindow("Cupboard")) {
      return;
   }
   return jGetWindow("Cupboard").getInventories()[0];
}

function checkInventory() {
   if(!jHaveWindow("Inventory")) {
      jToggleInventory();
      while(!jHaveWindow("Inventory"))
         jSleep(100);
   }
   return jGetWindow("Inventory").getInventories()[0];
}

 function main() {
    inventory = checkInventory();
   var i = 0;
   var cupboard = checkCupboard();
   var buckets = inventory.getItems("cheese-curd");
   if (buckets.length > 0) {
      inventory.sortItems(buckets, "amount", false);
      var bucket = buckets[0];
      if (bucket.isActual()) {
         var flasks = cupboard.getItems("cheese-tray");
         while (1) {
           if (flasks[i].resName() != "gfx/invobjs/cheese-tray-curd") {
         var flask = flasks[i];
            bucket.take();
            jWaitDrag();
               flask.itemact(0);
               jSleep(300);
            var buckets = inventory.getItems("cheese-curd");
            var bucket = buckets[0];
            bucket.take();
            jWaitDrag();
               flask.itemact(0);
               jSleep(300);
            var buckets = inventory.getItems("cheese-curd");
            var bucket = buckets[0];
            bucket.take();
            jWaitDrag();
               flask.itemact(0);
               jSleep(300);
            var buckets = inventory.getItems("cheese-curd");
            var bucket = buckets[0];
            bucket.take();
            jWaitDrag();
               flask.itemact(0);
            var buckets = inventory.getItems("cheese-curd");
            var bucket = buckets[0];
               jSleep(300);}
            i++;
            }
         }
      }
   
   loop();
 }
 
 function transfertray() {
   inventory = checkInventory();
   var cupboard = checkCupboard();
   var buckets = cupboard.getItems("cheese-tray-curd");
   var freeSlot = inventory.freeSlotsCoords()[0];
   if (buckets.length > 0) {
      inventory.sortItems(buckets, "amount", false);
      var bucket = buckets[0];
      while (bucket.isActual()) {
         bucket.take();
         jWaitDrag();
       inventory.drop(freeSlot)
       jSleep(500)
       }
       }
       return;
       }
   


 

 
function loop() {main();}
loop()


And one I just wrote to pick up mussles.

Code: Select all
//#! name = Mussel Collector
//#! uniq = musselzzz
//#! icon = gfx/invobjs/mussel

var target_mussel = jFindObjectByName("mussel", 30)
var musselsno = target_mussel.length
var g = 0

function getNearestMussel() {
   var mussel = jGetObjects(25, jCoord(0, 0), ["herbs/mussel"]);
   var min_len = 100500;
   var objid = 0;
   for (var i = 0; i < mussel.length; i++) {
      if (trees[i].position().dist(jMyCoords()) < min_len) {
         objid = trees[i];
         min_len = mussel[i].position().dist(jMyCoords());
      }
   }
   return objid;
}
jFindObjectByName("mussel", 30)

function collector() {
         var target_mussel = target_mussel[i];
         jDoClick(target_mussel.getID(), 3, 0);
         jWaitPopup(1000);
         jSelectContextMenu("Pick");
         jWaitMove(20000);
         jSleep(200);
         jWaitEndProgress(5000);
         jSleep(200);
         
      }

      
      
function main() {      
while (musselsno > g) { collector(); jSleep(300); g++; }
   
   }
   
main()


The one posted above is much better.


Your mussel bot shows this error http://puu.sh/4jmZg.png
User avatar
julian12it
 
Posts: 787
Joined: Sat Sep 11, 2010 8:01 pm
Location: Topaz

Re: Union Client Scripts

Postby Foetuses » Thu Sep 05, 2013 3:54 am

julian12it wrote:
Arcanist wrote: ...

The one posted above is much better.


Your mussel bot shows this error http://puu.sh/4jmZg.png


:roll:

jFindObjectByName returns a JSGob which has no length property, which is why you get that error.

Also on line 21 is a method call that has no good reason to be there, isn't followed by a semi-colon, and no preceding variable assignment declaration and will most certainly throw an error.

I don't see why not just use the one I found (and fixed slightly, this paste is the new version) earlier: http://pastebin.com/dBF7i8ak
Last edited by Foetuses on Thu Sep 05, 2013 3:58 am, edited 2 times in total.
Foetuses
 
Posts: 79
Joined: Tue Mar 27, 2012 11:55 pm

Re: Union Client Scripts

Postby Arcanist » Thu Sep 05, 2013 4:10 am

wow okay, it seems to work for me.

And btw, line 21 is crutial (But I took it out)

EDIT: oops, change the "musselsno > g" to "1" and it works.. :oops:
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby xxlasciel » Thu Sep 05, 2013 4:47 am

Arcanist wrote:download a fresh runstarve, you might have messed it up by changing it to utf-8
You need a bucked of water, and a waterflask/skin in inventory. Do you have both of those things?

If you do and this still happens, have a look in your cmd window and see what the error is.


Alright, I did what you said, new copy downloaded, full bucket of water and a full waterskin in my inventory. Same message appears "Starving Script finished", when I shift+f11 or f12 nothing happens. Not sure where to go on from here, any help appreciated :)
xxlasciel
 
Posts: 4
Joined: Tue Sep 03, 2013 7:38 pm

PreviousNext

Return to The Wizards' Tower

Who is online

Users browsing this forum: Claude [Bot], Meta [Bot] and 0 guests