Union Client Scripts

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

Moderator: Phades

Re: Union Client Scripts

Postby Lordtimo » Wed Sep 03, 2014 4:42 pm

It tries to get into the function "CollectMount2" , if you dont have that one in your api then it wont work.
User avatar
Lordtimo
 
Posts: 437
Joined: Wed Jun 01, 2011 12:00 pm

Re: Union Client Scripts

Postby dafels » Sun Sep 14, 2014 11:15 am

How can I get the value of milk level in the curding tub?
http://i.imgur.com/1Qvfvkp.png

Any examples please?
User avatar
dafels
 
Posts: 2994
Joined: Sun Nov 14, 2010 7:49 pm

Re: Union Client Scripts

Postby Arcanist » Sun Sep 14, 2014 1:49 pm

Code: Select all
var meter = jGetWindow("Curding Tub").getMeterValue(1);
jToConsole(meter);


Will return meter value of milk for open curding tub.
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby dafels » Sun Sep 14, 2014 6:02 pm

Thanks. Works great
User avatar
dafels
 
Posts: 2994
Joined: Sun Nov 14, 2010 7:49 pm

Re: Union Client Scripts

Postby Dunner » Sun Sep 21, 2014 9:12 pm

How do I drop a dragged bait on to an equipped fishing pole, equipped in the left slot (char's right)?
Dunner
 
Posts: 20
Joined: Tue Mar 25, 2014 11:51 pm

Re: Union Client Scripts

Postby Arcanist » Sun Sep 21, 2014 11:46 pm

Try
Code: Select all
var equip = checkEquipment();
equip.dropTo(6);


It that doesn't work, then try something like
Code: Select all
 if (equip.resName(6).indexOf("fishing pole") >= 0) { // put correct res name for pole
      equip.takeAt(6);
     waitDragName("pole");
     checkInventory().drop(checkInventory().freeSlotsCoords()[0]);
     jWaitDrop(actionTimeout);
var bait = checkInventory().getItems("bait")[0]
      bait.take();
      jSleep(1000);
      waitDragName("bait");
     while (checkInventory().getItems("pole")[0] == null) jSleep(500);
      checkInventory().getItems("pole")[0].itemact(0);
      jWaitDrop(actionTimeout);
     checkInventory().getItems("pole")[0].take();
     waitDragName("pole");
     equip.dropTo(6);
     jWaitDrop(actionTimeout);
     jSleep(1000);
    
   }

Or try
Code: Select all
     equip.iact(6);


The second soloution was what worked for me, when putting hemp into a pipe.
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Arcanist » Mon Sep 22, 2014 12:01 am

That reminds me..

Here is a script to eat multiple foods from multiple cupboards, and plow starve from nearby barrels.
As always, make sure stuff is centred on the tile, have a free space directly south of the chair, and try to have a complete meal already on the table.

Code: Select all
//#! name = Om nom nom
//#! tooltip = mon mon mO
//#! icon = gfx/invobjs/gast-cutlery-silver
include("jBotAPI");
include("jBotAPIArcanist");
include("pathfinder");
//Global
jMoveStep(jCoord(0, 1));
var inventory = checkInventory();
var count = 0;
var sitecount = 0;
currentlyPlace = jMyCoords();
var stopflag = false;
var cpos = [];
var foodnumber = 0;
startchoice();
var hemp = choiceHemp();
if (hemp) {
   hempcupboard = jSelectObject("Where is your weed stash?");
}

while (1){
   var thisfood = choose_food();
   if (thisfood == -1) break;
   else cpos.push(thisfood);
   foodnumber++;
   jToConsole(foodnumber + " items selected");
   var chosenfood = null;
}
jToConsole(cpos);
//var cpos = choose_food();

var foodcupboards = ScanCup4Ingredients(jGetObjects(35, jCoord(0, 0), ["cupboard"]));
//Settings
var actionTimeout = 1000 * 60 * 2; 
var waterPerc = 80;
var winePerc = 80;

function ScanCup4Ingredients(containerlist){
   ArrayCupboard = [];
   IngredCupboard = [];
   var ObjCupboard = [];
   var cupboards = containerlist;
   for(var i = 0; i < cupboards.length; i++) {
      openCupboard(cupboards, i);
      jWaitWindow("Cupboard",3000);
      for (var k = 0; k < cpos.length; k++){
         if(ObjCupboard.length < k + 1) ObjCupboard.push([]);
         if(jGetWindow("Cupboard").getInventories()[0].getItems(cpos[k]).length > 0){
         ObjCupboard[k].push(cupboards[i]);
         jToConsole("Cupboards of "+ cpos[k] + " found = "+ObjCupboard[k].length);

         }
      }
      
    }
   jAbsClick(jMyCoords(), 1, 0);
   return ObjCupboard;
}

/* =========================================================================== */
/* ==============================   FOOD CHOICE!  ============================ */
/* =========================================================================== */
function choiceHemp(){
   var blist = ["Yes", "No"];
            var selectWindow = jGUIWindow(jCoord(250, 250), jCoord(140, blist.length * 25 + 15), "Fatman");
         var label = jGUILabel(selectWindow, jCoord(5, 5), "Do you want to smoke Hemp?");
            for(var i = 0; i < blist.length; i++)
               jGUIButton(selectWindow, jCoord(5, 25 + i*25),  100, blist[i]);
            selectWindow.toggleCloseButton();
         var btext = selectWindow.waitButtonClick();
      selectWindow.destroy();
         if(btext == blist[0]) return true;
         if(btext == blist[1]) return false;

}
function choose_food() {
      if (chosenfood == null) {
            var blist = ["Cheese", "Sausage", "Baked", "Other", "End", "Exit"];
            var selectWindow = jGUIWindow(jCoord(250, 250), jCoord(110, blist.length * 25 + 15), "Fatman");
         var label = jGUILabel(selectWindow, jCoord(5, 5), "Select Food 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]) {                // Cheese
            selectWindow.destroy();
            
            /* ==============================   Cheese  ============================ */
            var blist2 = ["Brogdar Blue", "Midnight Blue", "Cellar Cheddar", "Musky Milben", "Jorbonzola", "Creamy Camenbert", "Emmentaler","Mothzarella",  "Exit"];
                     selectWindow = jGUIWindow(jCoord(250, 250), jCoord(110, blist2.length * 25 + 15), "Fatman");
                  label = jGUILabel(selectWindow, jCoord(5, 5), "Select Food Type:");
                     for(var i = 0; i < blist2.length; i++)
                        jGUIButton(selectWindow, jCoord(5, 25 + i*25),  100, blist2[i]);
                     selectWindow.toggleCloseButton();
                  var btext2 = selectWindow.waitButtonClick();
               if(btext2 == blist2[0]) { chosenfood = "invobjs/cheese-brodgarblue"; Food = "Brodgar Blue Cheese" }
               if(btext2 == blist2[1]) { chosenfood = "invobjs/cheese-creamycamembert"; Food = "Midnight Blue Cheese" }
               if(btext2 == blist2[2]) { chosenfood = "invobjs/cheese-cellarcheddar"; Food = "Cellar Cheddar" }
               if(btext2 == blist2[3]) { chosenfood = "invobjs/cheese-muskymilben"; Food = "Musky Milben" }
               if(btext2 == blist2[4]) { chosenfood = "invobjs/cheese-jorbonzola"; Food = "Jorbonzola" }
               if(btext2 == blist2[5]) { chosenfood = "invobjs/cheese-creamycamembert"; Food = "Camenbert" }
               if(btext2 == blist2[6]) { chosenfood = "invobjs/cheese-temmentaler"; Food = "Tasty Emmentaler" }
               if(btext2 == blist2[7]) { chosenfood = "invobjs/cheese-mothzarella"; Food = "Mothzarella" }
               if(btext2 == blist2[blist2.length - 1]) {
                  selectWindow.destroy();
                  jExit();
                  }
                  selectWindow.destroy();
                        
               jToConsole("Food selected: " + Food);         
                  return chosenfood;   
            }
         if(btext == blist[1]) {                // Sausage
            selectWindow.destroy();

            /* ==============================   Sausage  ============================ */
            var blist2 = ["Lamb Sausage", "Deer Dog", "Bear Banger","Chorizo", "Boar Baloney", "Boar Bouldin", "Exit"];
                     selectWindow = jGUIWindow(jCoord(250, 250), jCoord(110, blist2.length * 25 + 15), "Fatman");
                  label = jGUILabel(selectWindow, jCoord(5, 5), "Select Food Type:");
                     for(var i = 0; i < blist2.length; i++)
                        jGUIButton(selectWindow, jCoord(5, 25 + i*25),  100, blist2[i]);
                     selectWindow.toggleCloseButton();
                  var btext2 = selectWindow.waitButtonClick();
               if(btext2 == blist2[0]) { chosenfood = "invobjs/wurst-lambsausages"; Food = "Lamb Sausage" }
               if(btext2 == blist2[1]) { chosenfood = "invobjs/wurst-ddd"; Food = "Delicious Deer Dog" }
               if(btext2 == blist2[2]) { chosenfood = "invobjs/wurst-bigbearbanger"; Food = "Big Bear Banger" }
               if(btext2 == blist2[3]) { chosenfood = "invobjs/wurst-cowchorizo"; Food = "Cow Chorizo" }
               if(btext2 == blist2[4]) { chosenfood = "invobjs/wurst-boarbaloney"; Food = "Boar Baloney" }
               if(btext2 == blist2[5]) { chosenfood = "invobjs/wurst-boarboudin"; Food = "Boar Boudin" }
               if(btext2 == blist2[blist2.length - 1]) {
                  selectWindow.destroy();
                  jExit();
                  }
                  selectWindow.destroy();
                        
               jToConsole("Food selected: " + Food);         
                  return chosenfood;   
            }
         if(btext == blist[2]) {                // Baked
            selectWindow.destroy();

            /* ==============================   Baked  ============================ */
            var blist2 = ["Carrot Cake","Pumpkin Pie", "Apple Pie", "Blueberry Pie", "Exit"];
                     selectWindow = jGUIWindow(jCoord(250, 250), jCoord(110, blist2.length * 25 + 15), "Fatman");
                  label = jGUILabel(selectWindow, jCoord(5, 5), "Select Food Type:");
                     for(var i = 0; i < blist2.length; i++)
                        jGUIButton(selectWindow, jCoord(5, 25 + i*25),  100, blist2[i]);
                     selectWindow.toggleCloseButton();
                  var btext2 = selectWindow.waitButtonClick();
               if(btext2 == blist2[0]) { chosenfood = "invobjs/cake-carrot"; Food = "Carrot Cake" }
               if(btext2 == blist2[1]) { chosenfood = "invobjs/pie-pumpkin"; Food = "Pumpkin Pie" }
               if(btext2 == blist2[2]) { chosenfood = "invobjs/pie-apple"; Food = "Apple Pie" }
               if(btext2 == blist2[3]) { chosenfood = "invobjs/cheese-muskymilben"; Food = "Blueberry Pie" }
               if(btext2 == blist2[7]) { chosenfood = "invobjs/cheese-temmentaler"; Food = "Fish Sticks" }
         
               if(btext2 == blist2[blist2.length - 1]) {
                  selectWindow.destroy();
                  jExit();
                  }
                  selectWindow.destroy();
                        
               jToConsole("Food selected: " + Food);         
                  return chosenfood;   
            }
         if(btext == blist[3]) {                // Other
            selectWindow.destroy();

            /* ==============================   Other  ============================ */
            var blist2 = ["Chicken Salad", "Pumpkin Pie", "Apple Pie", "Cow Chorizo", "Exit"];
                     selectWindow = jGUIWindow(jCoord(250, 250), jCoord(110, blist2.length * 25 + 15), "Fatman");
                  label = jGUILabel(selectWindow, jCoord(5, 5), "Select Food Type:");
                     for(var i = 0; i < blist2.length; i++)
                        jGUIButton(selectWindow, jCoord(5, 25 + i*25),  100, blist2[i]);
                     selectWindow.toggleCloseButton();
                  var btext2 = selectWindow.waitButtonClick();
               if(btext2 == blist2[0]) { chosenfood = "invobjs/cheese-brodgarblue"; Food = "Chicken Salad" }
               if(btext2 == blist2[1]) { chosenfood = "invobjs/pie-pumpkin"; Food = "Pumpkin Pie" }
               if(btext2 == blist2[2]) { chosenfood = "invobjs/pie-apple"; Food = "Apple Pie" }
               if(btext2 == blist2[3]) { chosenfood = "invobjs/wurst-cowchorizo"; Food = "Cow Chorizo" }
               if(btext2 == blist2[blist2.length - 1]) {
                  selectWindow.destroy();
                  jToConsole("No Food selected! Shutting down!");
                  jExit();
                  }
                  selectWindow.destroy();
                        
               jToConsole("Food selected: " + Food);         
                  return chosenfood;   
            }

 
         if(btext == blist[4]) {
         selectWindow.destroy();
         jToConsole("End of Selection");
         return -1;
         }
         selectWindow.destroy();
         }        
      jToConsole("Food selected: " + Food);         
      return chosenfood;
   }     

/* =========================================================================== */
/* ==============================  START OF MAIN FUNCTIONS!  ================= */
/* =========================================================================== */

//Get Hungry!!
function isStoned(){
   var buffs = jGetBuffs();
   for (var i = 0; i < buffs.length; i++) {
      if (buffs[i].name().indexOf("In the Fog") >= 0) {
         if (buffs[i].time() > 5) {
            return true;
         }
         
      }
      
   }
   return false;
}

function getStoned(){

if (checkInventory().freeSlotsCoords().length == 0) return;
   while(jHaveWindow("Cupboard")) {
      jAbsClick(jMyCoords(), 1, 0);
      if (jHaveWindow("Cupboard")) jSleep(500);
   }
   while(!jHaveWindow("Cupboard")) {
      jPFMoveOffset_LX(hempcupboard.position(), 1);
      waitPFEndMove();
      jSleep(500);
      jDoClick(hempcupboard.getID(), 3, 0);
      jSleep(1000);
   }
   var equip = checkEquipment();
   var hemp = jGetWindow("Cupboard").getInventories()[0].getItems("hemp-cured")[0];
  // if (!hemp) return;
   if (equip.resName(1).indexOf("pipe") >= 0) {
      equip.takeAt(1);
     waitDragName("pipe");
     checkInventory().drop(checkInventory().freeSlotsCoords()[0]);
     jWaitDrop(actionTimeout);
      hemp.take();
      jSleep(1000);
      waitDragName("hemp-cured");
     while (checkInventory().getItems("pipe")[0] == null) jSleep(500);
      checkInventory().getItems("pipe")[0].itemact(0);
      jWaitDrop(actionTimeout);
     checkInventory().getItems("pipe")[0].take();
     waitDragName("pipe");
     equip.dropTo(1);
     jWaitDrop(actionTimeout);
     jSleep(1000);
     equip.iact(1);
     if (jWaitPopup(actionTimeout)) {
         jSelectContextMenu("Light");
      }
    
   }
}


function getHungry_digger() {
   var chair = jFindObjectByName("chair",10);
   jPFMoveOffset_LX(chair.position(),1);
   while (jIsMoving() || jMyCoords().dist(chair.position()) > 11){
      jPFMoveOffset_LX(chair.position(), 1);
      jSleep(500);
   }
      drinkWater();
      jSendAction("plow");
      jWaitCursor("dig", actionTimeout);
      jOffsetClick(jCoord(0, 0), 1, 0);
      jWaitProgress();
      jWaitCursor("dig", actionTimeout);
      jOffsetClick(jCoord(0, 0), 1, 0);
      jWaitProgress();
      jWaitCursor("dig", actionTimeout);
      jOffsetClick(jCoord(0, 0), 1, 0);
      jWaitProgress();      
      jOffsetClick(jCoord(0, 0), 3, 0);
      jWaitCursor("arw", actionTimeout);
   }

//Get Food
function getFood(number) {

      var inventory = checkInventory();
      var cupboards = foodcupboards;
      var inv_freeSlot = inventory.freeSlots();
   toInt(inv_freeSlot / cpos.length);
   jAbsClick(jMyCoords(), 1, 0);
   jSleep(1000);
      //jToConsole("Freeslots:" + inv_freeSlot); //For debugging purposes
   for (var k = 0; k < cpos.length; k++){
   getItemsFromContainers (cpos[k], foodcupboards[k], "Cupboard", number, 1);
   jAbsClick(jMyCoords(), 1, 0);
   jSleep(1000);
   jSleep(1000);
      }
   //Eat Food
         
 
   }


//Eat Food Standing
function eatFood(food) {
   inventory = checkInventory();
   var foods = inventory.getItems(food);
   jToConsole("Food to Eat:" + foods.length); //For debugging purposes
      //for (var i = 0; i < foods.length; i++) {
         if (jGetHungry() > 95) { return; }
         foods[0].iact();
         jSleep(500);
         jWaitPopup(actionTimeout);
         jSleep(500);
         jSelectContextMenu("Eat");
         jSleep(500);
      //   }

}
function startchoice(){
var blist = ["Eat Stuff", "Starve", "Exit"];
            var selectWindow = jGUIWindow(jCoord(250, 250), jCoord(110, blist.length * 25 + 15), "Fatman");
         var label = jGUILabel(selectWindow, jCoord(5, 5), "Select function:");
            for(var i = 0; i < blist.length; i++)
               jGUIButton(selectWindow, jCoord(5, 25 + i*25),  100, blist[i]);
            selectWindow.toggleCloseButton();
         var btext = selectWindow.waitButtonClick();
      selectWindow.destroy();
         if(btext == blist[0]) { return; }               
         if(btext == blist[1]) {
         while (jGetHungry() > 55) {
            jToConsole("Getting Hungry!");
            getWaterFromBarrel ()         
            getHungry_digger();
         }
      }   
   jExit();         
}

//Find Table sit and feast!
function main() {
   inventory = checkInventory();
      var inv_freeSlot = checkInventory().freeSlots();
   var number = toInt(inv_freeSlot / cpos.length);
   jAbsClick(jMyCoords(), 1, 0);
      if (!isStoned() && hemp){
         jMoveStep(jCoord(0, 2));
         getStoned();
      }
   getFood(number);

   //var foods = [];
   for (var q = 0; q < number; q++){
   for (var i = 0; i < cpos.length; i++) {
      //   var foods[i] = inventory.getItems(cpos[i]);
      
      //   jToConsole("Food to Eat:" + foods.length); //For debugging purposes
      

      if (jGetHungry() > 95) {
         jMoveStep(jCoord(0,2));
         while (jGetHungry() > 55) {
         jToConsole("Getting Hungry!");
         getWaterFromBarrel ()         
         getHungry_digger();
         }
      }
      
      var table = jFindObjectByName("table",10);
      while(!jHaveWindow("Table")) {
         var chair = jFindObjectByName("chair",10);
         jPFMoveOffset_LX(chair.position(),1);
         while (jIsMoving() || jMyCoords().dist(chair.position()) > 15){
            jPFMoveOffset_LX(chair.position(), 1);
            jSleep(500);
            }
         jSleep(500);
         currentlyPlace = jMyCoords();
         jSleep(500);
         chair.doClick(3,0);
         jSleep(500);
         jDoClick(table.getID(), 3, 0);
         jSleep(1000);
      }
      
      var inv_food = inventory.getItems(cpos[i]);
      inv_food[0].transfer();
      
      jSleep(500);
      var open_table = jGetWindow("Table").getInventories()[1];
      var check_food = [];
      var check_food = open_table.getItems(cpos[i]);
      jSleep(500);
      jToConsole("Food in Table: " + check_food.length); //For debugging purposes 
      jGetWindow("Table").pushButton("Feast!");
      try {
      while (!jIsCursor("eat")) {
         jSleep(100);
         jGetWindow("Table").pushButton("Feast!");
      }
      check_food[0].take();
      jWaitProgress(actionTimeout);
      resetCursor();
      }
      catch(e){
          jToConsole(e.message);
      }
      jSleep (500);      
            //jToConsole("Food in Table, Feasting... "); //For debugging purposes   

      //tile = jPFMove_LX(currentlyPlace);
      jSleep(500);
      if (!isStoned() && hemp){
         jMoveStep(jCoord(0, 2));
         getStoned();
      }
   }
   
}
jMoveStep(jCoord(0, 2));
jSleep(1000);
}
   
/* =========================================================================== */
/* ==============================   END OF MAIN FUNCTIONS!  ================== */
/* =========================================================================== */   


starter();
function starter() {
if (jGetHungry() > 95){
   while (jGetHungry() > 55) {
      jToConsole("Getting Hungry!");
      getWaterFromBarrel ();
      getHungry_digger();
      }
      
   }
while(1){
   main();
   }
 }       

while(1) {
   main();
}
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Mernil » Sat Sep 27, 2014 12:03 pm

Hey

I can't think of a way to get chests from a boat.
Boats doesn't seem to have an inventory.

Did I miss something?
User avatar
Mernil
 
Posts: 133
Joined: Tue Jul 29, 2014 9:54 pm

Re: Union Client Scripts

Postby Arcanist » Sat Sep 27, 2014 3:03 pm

Only this

Code: Select all
static void   jImgClick(java.lang.String window, int pos, int BTN, int mod)

Sends click in the boat / ... in the specified slot with the specified identifier
Code: Select all
static int   jImgFreeSlots(java.lang.String window)

Returns the number of empty slots in the boating / ...
Code: Select all
static java.lang.String   jImgName(java.lang.String window, int pos)

Options for the "invetaryami" boats / carts / wagons
Code: Select all
static int   jImgSlotsCount(java.lang.String window)

Returns the number of empty slots in the boating / ...

I cannot get them to work however in union 7.2c
I suspect that they do not work properly.
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Arcanist » Sat Sep 27, 2014 3:05 pm

Does anybody know how to tell the difference between a young animal and a mature animal?

They seem to have the same res file, and the same BLOB
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

PreviousNext

Return to The Wizards' Tower

Who is online

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