Union Client Scripts

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

Moderator: Phades

Re: Union Client Scripts

Postby Arcanist » Tue Jul 30, 2013 2:58 pm

roboboy33 wrote:When I click "Run Scripts" in union client nothing pops up or happens, it just goes back to the original menu. Is there something else I'm supposed to do?


Do you have a scripts folder in your build?

roboboy33 wrote:When I click "Run Scripts" in union client nothing pops up or happens, it just goes back to the original menu. Is there something else I'm supposed to do?


Code: Select all
         if (jGetHungry() < 95) {
            if (seeds[i].isActual()) {
               seeds[i].iact();
               jWaitPopup(actionTimeout);
            jSleep(1000);
               jSelectContextMenu("Eat");
               waitUnActual(seeds[i]);
            }
         }


In the carrot and beet harvester bits, change it to

if (jGetHungry() < 20)

or remove that bit all together
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby thebender » Tue Jul 30, 2013 7:55 pm

Script for transfering leafes form mulberry tree to mansion cellar. To start script you need stay outside.

Code: Select all
//#! name = leaf factory
//#! uniq = leaf_factory_by_thebender
//#! icon = gfx/invobjs/mulberryleaf

//var mulberry = null
//var house = null
var mul = choise_mulberry();
var inn = choise_house();
var count = 0;
var all_cupboard = 0;

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 == 20)
      {     
         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 checkInventory() {
   if(!jHaveWindow("Inventory")) {
      jToggleInventory();
      while(!jHaveWindow("Inventory"))
         jSleep(100);
   }
   return jGetWindow("Inventory").getInventories()[0];
}

function choise_mulberry() {
   if (mulberry == null) {
      var select_mulberry = jSelectObject("Select mulberry tree");
      var mulberry = jFindObjectByName(select_mulberry.name(), 50);
      if (mulberry == null) {
         jToConsole("Mulberry not found! Script stoped.");
         jExit();
      }
   }
   return mulberry;
}

function choise_house() {
   if (house == null) {
      var select_house = jSelectObject("Select house door");
      var house = jFindObjectByName(select_house.name(), 50);
      if (house == null) {
         jToConsole("House not found! Script stoped.");
         jExit();
      }
   }
   return house;
}

function go_for_leafs(tree) {
   inventory = checkInventory();
   var house_outside = jFindObjectByName("arch/inn", 50);
   while (house_outside = null) {
      jSleep(100);
   }
   if (inventory.freeSlots() > 0) {
      jPFMoveOffset_LX(tree.position(), 1);
      jDoClick(tree.getID(),3,0);
      jWaitPopup(1000);
      jSelectContextMenu("Pick leaf");
      while (inventory.freeSlots() > 0) {
         jSleep(100);
      }
   }
}

function go_to_cellar(door) {
   jPFMoveOffset_LX(door.position(), 1);
   jDoClick(door.getID(),3,0);
   jSleep(1000);
   var cellar_door = jFindObjectByName("arch/door-cellar", 50);
   while (cellar_door == null) {
      jSleep(100);
      var cellar_door = jFindObjectByName("arch/door-cellar", 50);
   }
   jToConsole("I'm in house");
   jDoClick(cellar_door.getID(),3,0);
   jSleep(100);
   var cellar_stairs = jFindObjectByName("arch/stairs-cellar", 50);
   while (cellar_stairs == null) {
      jSleep(100);
      var cellar_stairs = jFindObjectByName("arch/stairs-cellar", 50);
   }
   jToConsole("I'm in cellar");
   jSleep(1000);
}
function transfer_leafs() {
      var inventory = checkInventory();
        var open_cupboard = jGetWindow("Cupboard").getInventories()[0];
      var silkworms = open_cupboard.getItems("invobjs/silkworm");
      var leafes_cupboard = open_cupboard.getItems("invobjs/mulberryleaf");
      if (silkworms.length != 0 && leafes_cupboard.length != 48) {
         var leafes_inventory = inventory.getItems("invobjs/mulberryleaf");
         if (leafes_inventory.length > 48 - leafes_cupboard.length) {
            for (var j = leafes_cupboard.length; j < silkworms.length * 4; j++) {
               var freeSlot = open_cupboard.freeSlotsCoords()[0];
               var leafes_inventory = inventory.getItems("invobjs/mulberryleaf");
               leafes_inventory[0].take();
               jWaitDrag();
               open_cupboard.drop(freeSlot);
               jWaitDrop();
            }
         } else {
            for (var j = leafes_inventory.length; j > 1; j--) {
               var freeSlot = open_cupboard.freeSlotsCoords()[0];
               var leafes_inventory = inventory.getItems("invobjs/mulberryleaf");
               leafes_inventory[0].take();
               jWaitDrag();
               open_cupboard.drop(freeSlot);
               jWaitDrop();
            }
         }
      }
}

function go_to_cupboard() {
   if (cupboards == null) {
      var cupboards = jGetObjects(50, jCoord(0, 0), "terobjs/cupboard");
      all_cupboard = cupboards.length
   }
   
      for (var i = count; i < cupboards.length; i++) {
         var leafes_inventory = inventory.getItems("invobjs/mulberryleaf");
         if (leafes_inventory.length > 1) {
            jPFMoveOffset_LX(cupboards[i].position(), 1);
            jDoClick(cupboards[i].getID(),3,0);
            jSleep(1000);
            var open_cupboard = jGetWindow("Cupboard");
            while (open_cupboard == null) {
               jPFMoveOffset_LX(cupboards[i].position(), 1);
               jDoClick(cupboards[i].getID(),3,0);
               jSleep(1000);
               var open_cupboard = jGetWindow("Cupboard");
            }
            transfer_leafs();
            jSleep(1000);
            var silkworms = jGetWindow("Cupboard").getInventories()[0].getItems("invobjs/silkworm");
            var leafes_cupboard = jGetWindow("Cupboard").getInventories()[0].getItems("invobjs/mulberryleaf");
            if (leafes_cupboard.length >= silkworms.length * 4 || silkworms == null) {
               count++;
               jToConsole(count);
            }
         }
      }
}


function go_out() {
   var cellar_stairs = jFindObjectByName("arch/stairs-cellar", 50);
   jPFMoveOffset_LX(cellar_stairs.position(), 1);
   jDoClick(cellar_stairs.getID(),3,0);
   jSleep(1000);
   jToConsole("I'm in house");
   var out_door = jFindObjectByName("arch/door-inn", 50);
   while (out_door == null) {
      jSleep(100);
      var cellar_door = jFindObjectByName("arch/door-inn", 50);
   }
   jToConsole("I'm out!");
   jPFMoveOffset_LX(out_door.position(), -1);
   jDoClick(out_door.getID(),3,0);
   if (count == all_cupboard) {
      jExit();
   }
   jSleep(5000);
}

function main() {
   go_for_leafs(mul);
   go_to_cellar(inn);
   go_to_cupboard();
   go_out();
}
while(1) {
   main();
}
thebender
 
Posts: 3
Joined: Wed Jun 05, 2013 6:06 am

Re: Union Client Scripts

Postby Lman8786 » Sat Aug 03, 2013 1:57 am

The Script isn't complete for me, it picks the leaves and counts the cupboards in the Cellar then goes back outside says "I'm out", then script finishes.
User avatar
Lman8786
 
Posts: 574
Joined: Thu Sep 17, 2009 5:16 am
Location: America

Re: Union Client Scripts

Postby Glorthan » Thu Aug 08, 2013 3:57 am

I'm having problems with the farmer script, I keep getting this error:
Image

I have a water bucket and flask equipped on the farmer, along with seed bags, and I'm fairly sure the error is caused by this code fragment (somehow), as it's the only use of a blob member function:
Code: Select all
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;
}


If anyone has any idea what causes this, or any [english] documentation on the matter that would be most appreciated :)
Glorthan
 
Posts: 1099
Joined: Tue Jun 11, 2013 4:33 pm

Re: Union Client Scripts

Postby Arcanist » Thu Aug 08, 2013 7:05 am

There is the working script posted on the first page
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Glorthan » Thu Aug 08, 2013 10:36 am

Yeah it was that script. I repasted it to double check and it gave the same error a couple of times, then started working, and it's all good now. Not really sure what was going on ^^
Glorthan
 
Posts: 1099
Joined: Tue Jun 11, 2013 4:33 pm

Re: Union Client Scripts

Postby robinx » Tue Aug 27, 2013 12:59 pm

hello
how do function x when see bear or boar on the screen?
Image
robinx
 
Posts: 106
Joined: Sat Jul 16, 2011 2:40 pm

How do I find the coordinates of the cursor in the Union a c

Postby Firarno » Fri Aug 30, 2013 8:02 pm

How do I find the coordinates of the cursor in the Union a client?
In this form (30, 10)
Firarno
 
Posts: 5
Joined: Fri Aug 30, 2013 8:01 pm

Re: How do I find the coordinates of the cursor in the Union

Postby Aokigahara » Fri Aug 30, 2013 8:12 pm

Huh?
"The light shineth in the darkness; but the darkness comprehended it not."
User avatar
Aokigahara
 
Posts: 277
Joined: Fri Mar 04, 2011 5:01 am

Re: How do I find the coordinates of the cursor in the Union

Postby Firarno » Fri Aug 30, 2013 8:22 pm

Aokigahara wrote:Huh?

I have this
I have coordz = jCoord (??,??);, Here with such coordinates -30, -50, I need to replace them on your own. How do I find the coordinates?
Firarno
 
Posts: 5
Joined: Fri Aug 30, 2013 8:01 pm

PreviousNext

Return to The Wizards' Tower

Who is online

Users browsing this forum: Claude [Bot] and 3 guests