Union Client Scripts

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

Moderator: Phades

Re: Union Client Scripts

Postby Rhakar » Tue Jun 10, 2014 10:59 pm

Using v7.2e from github and the last logger bot Arcanist posted I get this:
Image

I didn't compile it, I just took the binaries that were there, was that my mistake?

Also, I tried coding a farmer together from bits and pieces, and this:
Code: Select all
var inventory = checkInventory();
var seeds = inventory.getItems("invobjs/carrot");
for (var i = 0; i < seeds.length; i++) {
      jPrint(seeds[i].name);
     jPrint(seeds[i].quality);
   }

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


results in
Image

I don't think I actually need that, but I wanted to understand the language better.
Rhakar
 
Posts: 88
Joined: Wed Feb 29, 2012 5:06 pm

Re: Union Client Scripts

Postby Arcanist » Wed Jun 11, 2014 7:31 am

My script works on 7.2c
7.2f seems to have had that method removed.

The_Sun wrote:
talon00302 wrote:Out of curiosity, try something like this

"C:\Program Files\Java\jre7\bin\java.exe" -Xms256m -Xmx512m -jar haven.jar moltke.seatribe.se
pause

Replace the location of java with yours

Was my location.

Image
Still no dice :(


It looks like you left out the quote marks.
You need to have the quote marks
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Rhakar » Wed Jun 11, 2014 11:12 am

Where can I get version 7.2c?
Rhakar
 
Posts: 88
Joined: Wed Feb 29, 2012 5:06 pm

Re: Union Client Scripts

Postby The_Sun » Thu Jun 12, 2014 5:10 am

Arcanist wrote:My script works on 7.2c
7.2f seems to have had that method removed.

The_Sun wrote:
talon00302 wrote:Out of curiosity, try something like this

"C:\Program Files\Java\jre7\bin\java.exe" -Xms256m -Xmx512m -jar haven.jar moltke.seatribe.se
pause

Replace the location of java with yours

Was my location.

Image
Still no dice :(


It looks like you left out the quote marks.
You need to have the quote marks

Still no dice. Contacted talon. Stumped.
User avatar
The_Sun
 
Posts: 52
Joined: Mon May 26, 2014 6:07 pm

Re: Union Client Scripts

Postby Arcanist » Thu Jun 12, 2014 11:09 am

See if this works for you
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Yasuo » Sat Jun 14, 2014 3:20 pm

Hello, why i can't run union for windows 64bit if i have 64bit java?

Code: Select all
"C:\Program Files\Java\jre7\bin\java.exe" -Xms256m -Xmx512m -jar haven.jar moltke.seatribe.se -r ./res
pause
Yasuo
 
Posts: 32
Joined: Sat Feb 15, 2014 9:53 pm

Re: Union Client Scripts

Postby mernil2 » Sat Aug 02, 2014 6:34 am

Little edit to runStarve script so it uses a chair to rest instead of water.

Code: Select all
//#! tooltip = Starving by 4x speed Rest on chair
//#! name = Starving Bot chair
//#! uniq = dfccd2e6-1cd5-495d-8947-9f0d6d4059ab

include("jBotAPI");

function main() {

   //var chair = jSelectObject("Select chair");
   var chair = jFindObjectByName("terobjs/furniture/chair", 15);
   
   jSetSpeed(3);
   while (jGetHungry() > 50) { // Run and sit until famished
      
      while (jGetStamina() > 50){ // Run around until tired
         jMoveStep(jCoord(80, 0));
         jWaitStartMove(30000);
         jWaitEndMove(30000);
         jMoveStep(jCoord(-80, 0));
         jWaitStartMove(30000);
         jWaitEndMove(30000);
      }
      
      
      chair.doClick(3,0); // Sit on chair...
      jWaitEndMove(30000);
      while (jGetStamina() < 95){ // ...until rested
         jSleep(100);
      }
      jMoveStep(jCoord(0, -1)); // go 1 step North
      jWaitEndMove(30000);   
   }
}

main();
mernil2
 
Posts: 11
Joined: Fri Aug 01, 2014 2:14 pm

Re: Union Client Scripts

Postby mernil2 » Sat Aug 02, 2014 5:18 pm

Is there a way to know the label of all crafts ?

For instance I'm trying this to craft nuggets :

Code: Select all
function craft_nuggets(){
   log("[+] crafting nuggets");
   alloying_crucible.doClick(3, 0);
   jWaitWindow("Crucible", 3000);
   jSleep(500);
   if(!jHaveWindow("Crucible")) error_log("No crucible ?!");
   jSendDoubleAction("craft", "nugget-metal");
   jWaitProgress();
}


I can't manage to have this working. I believe it's because the "nugget-metal" isn't the good label.
I've tried with others like "nuggets" or "metalnuggets" ...

Is there a way to get the list of all crafts ?
mernil2
 
Posts: 11
Joined: Fri Aug 01, 2014 2:14 pm

Re: Union Client Scripts

Postby mernil2 » Sat Aug 02, 2014 7:04 pm

Here is a bot that crafts tiny abacus.

I'm still interested in the list of crafts if someone has it.

Code: Select all
//#! tooltip = Craft tiny abacus
//#! name = craft tiny abacus
//#! uniq = dfccd2e6-1cd5-495d-8947-9f0d6d45454

/********** Usage recommendation : **********
 - empty your inventory (need at least backpack).
 - axe and saw equipped
 - have logs nearby.
 - have a chest nearby with your metal in it (tin + iron atm).
 - have a lit alloying crucible nearby.
 */


include("jBotAPI");

var metal_chest = jSelectObject("Select the chest with the metal");
var alloying_crucible = jSelectObject("Select the alloying crucible");


function main() {   
   
   var crafted_abacus = 0;
   
   var tin_nugget = "invobjs/nugget-tin";
   var tin_bar = "invobjs/bar-tin";
   
   var iron_nugget = "invobjs/nugget-castiron";
   var iron_bar = "invobjs/bar-castiron";
   
   
   while (crafted_abacus < 10){ //Here we'll craft 10 abacus (=> 3 tin bar and 2 iron bars)

      if(get_number_of_items_in_chest(metal_chest, tin_nugget) < 3){
         get_items_from_chest(metal_chest, tin_bar, 1);
         craft_nuggets_from(tin_bar);
         put_items_in_chest(metal_chest, tin_bar, 10);
      }
      
      if(get_number_of_items_in_chest(metal_chest, iron_nugget) < 2){
         get_items_from_chest(metal_chest, iron_bar, 1);
         craft_nuggets_from(iron_bar);
         put_items_in_chest(metal_chest, iron_bar, 10);
      }
      
      if(!get_item_on_ground('terobjs/items/board')){
         action_on_ground_item('terobjs/trees/log', 'Make Boards');
         get_item_on_ground('terobjs/items/board');
      }
      
      var inventory = checkInventory();
      if(inventory.getItems("invobjs/branch").length < 4){
         if(!get_item_on_ground('terobjs/items/wood')){
            action_on_ground_item('terobjs/trees/log', 'Chop into Blocks');
            get_item_on_ground('terobjs/items/wood');
         }
         jSleep(1000);
         var inventory = checkInventory();
         wood_block = inventory.getItems("invobjs/wood")[0];
         wood_block.iact();
         jWaitPopup();
            jSelectContextMenu("Split");
         waitUnActual(wood_block);
      }
      
      get_items_from_chest(metal_chest, tin_nugget, 3);
      get_items_from_chest(metal_chest, iron_nugget, 2);
      
      jMoveStep(jCoord(0, -1));
      jWaitEndMove(1000);
      jSleep(3000);
      
      checkInventory();
      
      jSendDoubleAction("craft", "abacus");
      jWaitCraft();
      jCraftItem(true);
      jWaitProgress(25000);
      jSleep(1000);
      
      
      put_items_in_chest(metal_chest, "invobjs/tinyabacus", 1);
           crafted_abacus++;
   }
}

function get_number_of_items_in_chest(chest, item_name){
   log('[+] Getting number of ' + item_name + ' in chest.');
   
   chest.doClick(3, 0);
   jWaitWindow("Chest", 3000);
   jSleep(500);
   if(!jHaveWindow("Chest")) return false;
   
   item_number = jGetWindow("Chest").getInventories()[0].getItems(item_name).length;
   
   log('[+] ' + item_number + ' ' + item_name + ' in chest.');

   
   return item_number;
}

function go_to_ground_object(item_name){
   var item = jFindObjectByName(item_name, 30);
   if (item == null){
      return false;
   }
   item.doClick(1,0);
   jWaitEndMove(30000);
   jSleep(500);
   return item;
}

function get_item_on_ground(item_name){
   item_id = go_to_ground_object(item_name);
   if(!item_id){
      error_log(item_name + ' not found!');
      return false;
   }
   if (item_id.isActual()){
      item_id.doClick(3, 0);
      jWaitEndMove(30000);
      return true;
   }
   return false;
}

function action_on_ground_item(item_name, action){
   log('[+] ' + action + ' on ' + item_name);
   item = go_to_ground_object(item_name);
   if(!item)
      return false;
   item.doClick(3,0);
   jSleep(100);
   jWaitPopup();
   jSelectContextMenu(action);
   jWaitProgress(25000);
}


function get_items_from_chest(chest, item_name, quantity){
   log('[+] Getting '+ quantity +' of ' + item_name + ' from chest.');

   chest.doClick(3, 0);
   jWaitWindow("Chest", 3000);
   jSleep(500);
   if(!jHaveWindow("Chest")) return false;
   
   var i = 0;
   while (i < quantity){
      jGetWindow("Chest").getInventories()[0].getItems(item_name)[i].transfer();
      i++;
   }
}

function put_items_in_chest(chest, item_name, quantity){
   log('[+] Putting '+ quantity +' of ' + item_name + ' in chest.');

   chest.doClick(3, 0);
   jWaitWindow("Chest", 3000);
   jSleep(500);
   if(!jHaveWindow("Chest")) return false;
   
   var i = 0;
   var inventory = checkInventory();
   while (i < quantity){
      try{
         inventory.getItems(item_name)[0].transfer();
      }catch(e){}
      try{
         inventory.getItems(item_name)[i].transfer();
      }catch(e){}
      i++;
   }
}

function craft_nuggets_from(bar_type){
   alloying_crucible.doClick(3, 0);
   jWaitWindow("Crucible", 3000);
   jSleep(500);
   if(!jHaveWindow("Crucible")) error_log("No crucible ?!");
   jSendDoubleAction("craft", "nuggify");
   log("[+] crafting nuggets from " + bar_type);
   jWaitCraft();
   jCraftItem(true);
    jWaitProgress(25000);
}

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


function log(text){
   jInGamePrint(text);
   jSleep(500);
}

function error_log(text){
   jPlayBeep(500);
   jInGamePrint('[!] ' + text);
   jSleep(5000);
   
}

main();
mernil2
 
Posts: 11
Joined: Fri Aug 01, 2014 2:14 pm

Re: Union Client Scripts

Postby mernil2 » Sat Aug 02, 2014 10:23 pm

Still scripting, Union is quite fun!

I've made another tool, which is a mapper (it's in wizard tower, somewhere).
It basically compiles all map folders so we keep our map data from a session to another.

With Union I believe I can get our character coordinates and write them to a text file, so I can then read them in the mapper, and place a marker on the map where our character actually is.
And possibly later also add other chars, as well as curios / herbs, etc...
And maybe too the ability to click somewhere in the mapper and have our character pathfind his way over there...

But well, I have some trouble to convert coordinates :
On the mapper side, all I have is relative coordinates with the tiles (tile_0_0.png, tile_0_1.png, ...).
And on Union side I have big numbers using
Code: Select all
jMyCoords()


And whenever I get in and out of a house (or cave or whatever...), these coordinates are changing.

How do I convert these coordinates to something relative to map big tile names?
I'd like to get something like : (0.5,0.5) if I am at the center of the tile : tile_0_0.png
mernil2
 
Posts: 11
Joined: Fri Aug 01, 2014 2:14 pm

PreviousNext

Return to The Wizards' Tower

Who is online

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