Union Client Scripts

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

Moderator: Phades

Re: Union Client Scripts

Postby Arcanist » Fri Feb 07, 2014 1:52 pm

Bottest wrote:Hey, i hope anyone can help me:
I want the character to move to the curio first, and then picks it. So i thought of adding the "//StuffCoord = Stuff.position(); //jPFmove(Stuff.position()) // jWaitMove();" commands to the getstuff function.
But with those added, the script stops working. Anyone got a clue, how to "pathfind" to the curio before picking it?
Thank you^^
Code: Select all
function GetStuff() {
       var Stuff = jGetObjects(25,jCoord(0,0),"fourleafclover");
       StartCoord = jMyCoords();
       while ((inventory.freeSlots() > 3)&&(Stuff.length>0)) {
          AwayFromGround();
          jPrint(Stuff.length);
            //StuffCoord = Stuff.position();
            //jPFmove(Stuff.position())
              //     jWaitMove();
        Stuff[0].doClick(1,0);
        jWaitMove(6000);
          Stuff[0].doClick(3,0);
          jWaitPopup();
          jSelectContextMenu("Pick");
          jWaitMove(6000);
          jWaitProgress(10000);
          Stuff = NewArrayWithout1stElement(Stuff);
       }   
       AwayFromGround();
       PreviousCoord(StartCoord);
    }



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;
      }
   }
}


use

if(jIsPathFree(stuff.position())) {jToConsole("Direct path was found");}
else {
jToConsole("Direct path wasn't found. Using PF");
jPFMoveOffset_LX(stuff.position(), 1);
waitPFEndMove();}
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Arcanist » Fri Feb 07, 2014 2:31 pm

Updated I think..

Code: Select all
//#! name = Logger
//#! icon = gfx/invobjs/axe
//#! uniq = Arcanist_logger

var actionTimeout = 1000 * 60 * 1;
var hartling = jMyCoords();   
var inventory = checkInventory();
var player = jGetObjects(1,0,"borka");
var drunk = 0;
var logcount = 0;
var winecount = 0;
var count = 0;
var log = 0
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
//Pathfinder
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;
      }
   }
}
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */


//Get Nearest

function getNearestBasket() {
   var trees = jGetObjects(40, jCoord(0, 0), ["terobjs/wbasket"]);
   var min_len = 100500;
   var objid = 0;
   for (var i = 0; i < trees.length; i++) {
      if (trees[i].position().dist(jMyCoords()) < min_len) {
         objid = trees[i];
         min_len = trees[i].position().dist(jMyCoords());
      }
   }
   return objid;
}

function getNearestLog() {
   var trees = jGetObjects(50, jCoord(0, 0), ["trees/log"]);
   var min_len = 100500;
   var objid = 0;
   for (var i = 0; i < trees.length; i++) {
      if (trees[i].position().dist(jMyCoords()) < min_len) {
         objid = trees[i];
         min_len = trees[i].position().dist(jMyCoords());
      }
   }
   return objid;
}

function getNearestIdol() {
   var trees = jGetObjects(40, jCoord(0, 0), ["vclaim"]);
   var min_len = 100500;
   var objid = 0;
   for (var i = 0; i < trees.length; i++) {
      if (trees[i].position().dist(jMyCoords()) < min_len) {
         objid = trees[i];
         min_len = trees[i].position().dist(jMyCoords());
      }
   }
   return objid;
}

function getNearestCliff() {
   var trees = jGetObjects(5, jCoord(0, 0), ["ridges"]);
   var min_len = 100500;
   var objid = 0;
   for (var i = 0; i < trees.length; i++) {
      if (trees[i].position().dist(jMyCoords()) < min_len) {
         objid = trees[i];
         min_len = trees[i].position().dist(jMyCoords());
      }
   }
   return objid;
}

function getNearestRock() {
   var trees = jGetObjects(5, jCoord(0, 0), ["bumlings"]);
   var min_len = 100500;
   var objid = 0;
   for (var i = 0; i < trees.length; i++) {
      if (trees[i].position().dist(jMyCoords()) < min_len) {
         objid = trees[i];
         min_len = trees[i].position().dist(jMyCoords());
      }
   }
   return objid;
}

function getNearestTree() {
   var trees = jGetObjects(50, jCoord(0, 0), ["trees/fir", "trees/pine", "trees/yew", "trees/birch", "trees/elm", "trees/oak", "trees/willow", "trees/atree", "trees/maple", "trees/mulberry"]);
   var min_len = 100500; var objid = 0;
   for (var i = 0; i < trees.length; i++) {
      if (trees[i].position().dist(jMyCoords()) < min_len) {
         objid = trees[i];
         min_len = trees[i].position().dist(jMyCoords());
      }
   }
   return objid;
}

function closetree() {
   var trees = jGetObjects(2, jCoord(0, 0), ["trees/fir", "trees/pine", "trees/yew", "trees/birch", "trees/elm", "trees/oak", "trees/willow", "trees/atree", "trees/maple", "trees/mulberry"]);
   var min_len = 100500; var objid = 0;
   for (var i = 0; i < trees.length; i++) {
      if (trees[i].position().dist(jMyCoords()) < min_len) {
         objid = trees[i];
         min_len = trees[i].position().dist(jMyCoords());
      }
   }
   return objid;
}

function getNearestStump() {
   var trees = jGetObjects(35, jCoord(0, 0), ["stump"]);
   var min_len = 100500;
   var objid = 0;
   for (var i = 0; i < trees.length; i++) {
      if (trees[i].position().dist(jMyCoords()) < min_len) {
         objid = trees[i];
         min_len = trees[i].position().dist(jMyCoords());
      }
   }
   return objid;
}
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
// Random Functions

function tohearth() {
   jSendDoubleAction("theTrav", "hearth");
   jWaitProgress(actionTimeout);
   jSleep(1000);
}

function tovillage() {
   drinkWine();
   jSleep(500);
   jSendDoubleAction("theTrav", "village");
   jWaitProgress(actionTimeout);
   jSleep(1000);
   }
   
function travelCount() {
   var buffs = jGetBuffs();
   for (var i = 0; i < buffs.length; i++) {
      if (buffs[i].name().indexOf("Travel Weariness") >= 0) {
         return buffs[i].meter();
      }
   }
   return 0;
}
   
   function checkInventory() {
   if(!jHaveWindow("Inventory")) {
      jToggleInventory();
      while(!jHaveWindow("Inventory"))
         jSleep(100);
   }
   return jGetWindow("Inventory").getInventories()[0];
}

function equipShovel() { // From axe
   var equip = checkEquipment();
   var shovel = inventory.getItems("shovel")[0];
   if (!shovel) return;
   if (equip.resName(6).indexOf("axe") >= 0) {
      dropItem(shovel.coord().add(0, 1));
      equip.takeAt(6);
      jWaitDrag(actionTimeout);
      inventory.drop(shovel.coord());
      jSleep(1000);
      waitDragName("shovel");
      equip.dropTo(6);
      jWaitDrop(actionTimeout);
   }
   if (equip.resName(7).indexOf("axe") >= 0) {
      dropItem(shovel.coord().add(0, 1));
      equip.takeAt(7);
      jWaitDrag(actionTimeout);
      inventory.drop(shovel.coord());
      jSleep(1000);
      waitDragName("shovel");
      equip.dropTo(6);
      jWaitDrop(actionTimeout);
   }
}   

function equipAxe() { // From Shovel
   var equip = checkEquipment();
   var axe = inventory.getItems("axe")[0];
   if (!axe) return;
   if (equip.resName(6).indexOf("shovel") >= 0) {
      dropItem(axe.coord().add(0, 1));
      equip.takeAt(6);
      jWaitDrag(actionTimeout);
      inventory.drop(axe.coord());
      jSleep(1000);
      waitDragName("axe");
      equip.dropTo(6);
      jWaitDrop(actionTimeout);
   }
}   

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 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 checkEquipment() {
   if(!jHaveWindow("Equipment")) {
      jToggleEquipment();
      while(!jHaveWindow("Equipment"))
         jSleep(100);
   }
   return jGetJSEquip();
}

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 drinkWine() {
   if (travelCount() < 85) return;
   inventory = checkInventory();
   var buckets = inventory.getItems("bucket-wine");
   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("glass-winee");
         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("glass-winef");
   if (flasks.length > 0) {
      var flask = flasks[0];
      if (flask.isActual()) {
         flask.iact();
         if (jWaitPopup(actionTimeout)) {
         jSleep(500)
            jSelectContextMenu("Drink");
            jWaitProgress();
         winecount++;
         } else {
            // No water
            stopFlag = true;
         }
      }
   }
  if (travelCount() < 85) return;
  drinkWine();
   }

   
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
// Content Functions

function takelog() {

     var log = jFindObjectByName("log", 50).getID();
     if(log != null) {
      jSendAction("carry");
      jWaitCursor("chi");
      jDoClick(log, 1, 0);
      jWaitMove(2500);
     if (jFindObjectByName ("borka", 1).isCarrying ()) {logcount++;}
     }
    
}

function takethislog(log) {

      jSendAction("carry");
      jWaitCursor("chi");
      jDoClick(log.getID(), 1, 0);
      jWaitMove(2500);
     if (jFindObjectByName ("borka", 1).isCarrying ()) {logcount++;}
     }
    
function movetobasket() {
   jMoveStep(jCoord(1, 0));
   jWaitMove(1000);
   jMoveStep(jCoord(-1, 0));
   jWaitMove(1000);
   jPFMoveOffset_LX(getNearestBasket().position(), 1)
   waitPFEndMove();
   }

function movetoidol() {
   jMoveStep(jCoord(1, 0));
   jWaitMove(1000);
   jMoveStep(jCoord(-1, 0));
   jWaitMove(1000);
   jPFMoveOffset_LX(getNearestIdol().position(), 3)
   waitPFEndMove();
   }
   
function droplog() {
      jAbsClick(jMyCoords(), 3, 0);
      jWaitMove(1000);
     return;
}

function droplognorth() {
      jOffsetClick(jCoord(0, -1), 3, 0);
      jWaitMove(1000);
     return;
}


function stumper(){
      jSleep(100);
      equipShovel();
      jSleep(300);
      var target_stump = getNearestStump();
      jDoClick(target_stump.getID(), 3, 0);
      jWaitPopup(1000);
      jSelectContextMenu("Remove");
      jSleep(200);
      jWaitProgress(actionTimeout);
      jSleep(500);
      while (jIsDragging()) {
            jDropObject(0);
            jSleep(300);     
         }
      drinkWater();
      return;
}
   

   

function resetCursor() {
   if (!jIsCursor("arw")) {
      jAbsClick(jCoord(0, 0), 3, 0);
      jWaitCursor("arw", actionTimeout);
   }
}
   


      
function cuttree() {
         equipAxe();
         jSleep(400);
         jDoClick(getNearestTree().getID(), 3, 0);
         jWaitPopup(3000);
         jSelectContextMenu("Chop");
         jSleep(200);
         jWaitProgress(actionTimeout);
         jSleep(200);
         return;}
      
function cutthistree(target) {
         equipAxe();
         jDoClick(target.getID(), 3, 0);
         jWaitPopup(3000);
         jSelectContextMenu("Chop");
         jSleep(200);
         jWaitProgress(actionTimeout);
         jSleep(200);
         return;}
      

      
function dropblock() {
         checkInventory();
         var inventory_wood = jGetWindow("Inventory").getInventories()[0].getItems("wood");
         while (jIsDragging()) {
            jDropObject(0);
            jSleep(300);     
         }
         for(var i in inventory_wood){
               if(inventory_wood[i] == 0){
                  break;
               }
               inventory_wood[i].drop();
               jSleep(200);
         }
   }
      

/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
// Log Harvester Content

function beginHarvest() {
var log = 0;
var tree = 0;
var rock = 0;
var cliff = 0;
var count = 0;
drinkWater();
logHarvester();}

function checkRock() {

      if (getNearestCliff()) {jToConsole ("Too close to a cliff"); jExit();}

      if (getNearestRock()) {
      if (!jIsMoving()) {
         jToConsole("I've found a rock, I don't like rocks.");
         jSendDoubleAction("swrk", "runestone");
         jWaitCursor("chi");
         jSleep(2500);
         jDoClick(jFindObjectByName("03", 5).getID(), 1, 0);
         jSleep(200);
         jWaitProgress(actionTimeout);
         jSleep(500);
         jSendAction("carry");
         jWaitCursor("chi", actionTimeout);
         jDoClick(jFindObjectByName("runestone", 5).getID(), 1, 0);
         jWaitMove(1000);
         droplognorth();
         takelog();
         var count = 0;
         return;} }
      if (closetree()) {
         cuttree();
         dropblock();
         stumper();
         takelog();
         var count = 0;
         return;}
   jToConsole("Nothing Found");
   return;   
   
   }

function logHarvester() {
   jToConsole (winecount/5 + "L of Wine");
   if (logcount > 1) {   jToConsole (logcount + " Logs taken");}
   else { if (logcount < 1) {jToConsole("No Logs taken");}
   else { jToConsole("1 Log taken");}}
         
      
    jMoveStep(jCoord(2, 0));
    jWaitMove(1000);
if (getNearestStump()) {
   jToConsole ("Clearing Stumps");
   if ( jIsPathFree(getNearestStump().position()) ) {}
   else {
      jPFMoveOffset_LX(getNearestStump().position(), 1);
      waitPFEndMove();
      }
   dropblock();
   stumper();
   tohearth();
   beginHarvest();
   }
   
if (getNearestLog()) {}
else {
   jToConsole("No logs found");
   jToConsole("Searching for trees");
   if (getNearestTree()) {
      if ( jIsPathFree(getNearestTree().position()) ) {}
      else {
      jPFMoveOffset_LX(getNearestTree().position(), 2);
      waitPFEndMove();
      }
      cuttree();
      dropblock();
      stumper();
   }
   else {
      jToConsole("No more trees");
      jExit();
   }
}

   jToConsole("I found a log");
   if ( jIsPathFree(getNearestLog().position()) ) {jDoClick(getNearestLog().getID(), 1, 0); jWaitEndMove(10000); takelog(); }
   else {
   jPFMoveOffset_LX(getNearestLog().position(), 2);
   waitPFEndMove();
   takelog();
   jSleep(300);
   }
   while (count < 3) {
   if (jFindObjectByName ("borka", 1).isCarrying ()) {
      tovillage();
      if (getNearestBasket()) {movetobasket();}
      else {movetoidol();}
      droplog();
      dropblock();
      tohearth();
      beginHarvest();
      count++;
      jSleep(1000);}
   else {checkRock(); }
   jSleep(1000);
   }

   
jToConsole("A strange error occurred"); jExit();
}

/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
// Log Chopper Content

function mainboards() {
   var i = 0
   var count = 1
   var all_log = [];
   all_log = jGetObjects(30, 0, "log");
   jToConsole(all_log.length+" Logs total");
   while(true){
         jToConsole("Chopping log number "+ count)
         var current_log = getNearestLog();
         if (jIsPathFree(current_log.position())) {}
         else {
            jPFMoveOffset_LX(current_log.position(), 0);
            waitPFEndMove();
            }
             jDoClick(current_log.getID(), 3, 0);
          jWaitPopup(1000);
          jSelectContextMenu("Make Boards");
          jWaitProgress(actionTimeout);
          i++;
          count++;
          }

      }
    
function mainblocks() {
   var i = 0
   var count = 1
   var all_log = [];
   all_log = jGetObjects(30, 0, "log");
   jToConsole(all_log.length+" Logs total");
   while(true){
         jToConsole("Chopping log number "+ count)
         var current_log = getNearestLog();
         if (jIsPathFree(current_log.position())) {}
         else {
            jPFMoveOffset_LX(current_log.position(), 0);
            waitPFEndMove();
            }
             jDoClick(current_log.getID(), 3, 0);
          jWaitPopup(1000);
          jSelectContextMenu("Chop into Blocks");
          jWaitProgress(actionTimeout);
          i++;
          count++;
          }

      }
function mainchopper() {
   jDropLastWindow();
   var blist = ["Planks", "Blocks", "Exit"];
   var selectWindow = jGUIWindow(jCoord(250, 250), jCoord(110, blist.length * 25 + 15), "LogChopper");
   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]) harvester = new mainboards();
   if(btext == blist[1]) harvester = new mainblocks();
   if(btext == blist[blist.length - 1]) {selectWindow.destroy(); return;};
   
   }
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
// Main Content


function mainstacker() {
var radius = 50;
start = jMyCoords();
var p_log = [];
var count = 1;
var i = 0
p_log = jGetObjects(radius, 0, "log");
jToConsole(p_log.length+ " Logs total");
while(1) {
         jToConsole("Working on log number "+count)
            var current_log = p_log[i];
            if(jIsPathFree(current_log.position())) {jToConsole("Direct path was found");}
            else {
               jToConsole("Direct path wasn't found. Using PF");
               jPFMoveOffset_LX(current_log.position(), 1);
               waitPFEndMove();}
            takethislog(current_log);
            jWaitMove(3000);
            if(jFindObjectByName("borka", 1).isCarrying()){}
            else {jSleep(1000);}
            if(jFindObjectByName("borka", 1).isCarrying()){
            jToConsole("Log taken");
            tohearth();
            i++;
            if (getNearestBasket()) {movetobasket(); droplog();}
            else {droplognorth();}
            jMoveStep(jCoord(2, 0));
            jWaitMove(1000);
            returnToSite(start);
            count++
            }
            else{ jToConsole("Log missed"); tohearth(); jMoveStep(jCoord(2, 0)); i++;}
}
}   


/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
// Log Mover Content

 function mainmover() {
   jToConsole(winecount/5+"L of wine");
   jToConsole(logcount + " logs taken");
   movermain(); }
   
function movermain() {
   if (getNearestLog()) {
      if(jIsPathFree(getNearestLog().position())) {}
      else {jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0); jWaitMove();}
      takethislog(getNearestLog())
      if (jFindObjectByName ("borka", 1).isCarrying ()) {tohearth();}
      else {jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0); jWaitMove(); movermain2();}
      droplognorth();
      jSleep(200);
      tovillage();
      mainmover();
   }
}
      
function movermain2(){movermain();}
   
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
// Counter Content
   

// ??????? ????????? ??????? ?? ????????? ?? ??????. ? ?????? ????? ?????????.
function sortObjects(objects) {
   objects.sort(function(a,b) {
      if(a.position().dist(jMyCoords())>b.position().dist(jMyCoords())) return 1;
      if(a.position().dist(jMyCoords())<b.position().dist(jMyCoords())) return -1;
      if(a.position().dist(jMyCoords())==b.position().dist(jMyCoords())) return 0;
   });
   return objects;
}
// ????????? ??????? ??? ????? ? ??? ?? jbotapi
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;
      }
   }*/
}
// ??????? ????????? ????? ?? 1 ?? 9999 ? ????????? ?????.
function russianCounter(number){
   var numbers = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "zero"];
   var teens = ["eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"];
   var tens = ["ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"];
   var hundreds = ["one hundred and ", "two hundred and ", "three hundred and ", "four hundred and ", "five hundred and ", "six hundred and ", "seven hundred and ", "eight hundred and ", "nine hundred and "];
   var thousands = ["one thousand and ", "two thousand and ", "three thousand and ", "four thousand and ", "five thousand and ", "six thousand and ", "seven thousand and ", "eight thousand and ", "nine thousand and "];
   var result = ""
   if ((number / 1000) > 0){
      if (Math.floor(number/1000)>0){
         result = result + thousands[Math.floor(number/1000)-1]
      }
      if (Math.floor(number/1000) == 1){
         result = result + " ??????"
      }
      if ((Math.floor(number/1000)>1)&&(Math.floor(number/1000)<5)){
         result = result + " ??????"
      }
      if (Math.floor(number/1000) > 5){
         result = result + " ?????"
      }
      number = number - (Math.floor(number/1000)*1000);
   }
   if ((Math.floor(number/100)>0)){
      result = result +" "+hundreds[Math.floor(number/100)-1];
      number = number - (Math.floor(number/100)*100);
   }
   if (result !==""){
      result= result+" ";
   }
   if ((number>0)&&(number <10)){
      result = result + numbers[number-1];
   }
   if ((number>10)&&(number <20)){
      result = result + teens[number-11];
   }
   if (((number == 10)||(number>19))&&(number<100)){
      if ((number>0)&&((number % 10) == 0)){
         result = result + tens[Math.floor(number/10)-1];
      }
      if ((number % 10) !== 0){
         result = result + tens[Math.floor(number/10)-1]+" "+numbers[(number % 10)-1];
      }
   }
   return result;
}

function maincounter() {
   // ??????? ??? ??????? ? ??????? 100 ??????.
   var objects = jGetObjects(100, jCoord(0,0),"log")
   jToConsole(objects.length +" logs here");
   objects = sortObjects(objects);

/*
// ?????????? ???????, ?????? ???????????, ?????? ? ????? ? ???? ???????. ????????? ???? ? ???? ?????? ?? ???????? ???????.
for (var i = 0; i < objects.length; i++){
   objects[i].setOverlay(true);
   sayArea(russianCounter(i+1));
   jSleep(1000);
   }
*/
}

/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* Clear Cutter */
   
   
   function selectTrees() {
   var target_trees = [];
   var tree_ids = []
   while (1) {
      var Tree = jSelectObject("Select Tree, click on the ground to stop selecting");
      if (Tree == null) {jToConsole ("You clicked the ground, Working on selected trees"); break;}
      var name = Tree.name();
      if (name.indexOf("trees") != -1) {
         if (tree_ids.indexOf(Tree.getID()) != -1) {
            jToConsole("ERROR: This Tree has been already selected.");
            continue;
         }
         target_trees.push(Tree);
         tree_ids.push(Tree.getID());
         jToConsole("Trees count: " + target_trees.length);
      }
      else break;
   }//Trees
   return target_trees;
}

function mainClearCutter() {
   jDropLastWindow();
   checkInventory();
   var startPoint = jMyCoords();
   var lastPoint = jMyCoords();
   
   var Trees = selectTrees();
   if (Trees.length == 0)
      return;
   
   var currentTree = 0;
   while (1) {
      if (currentTree == Trees.length) {jExit();}
   
      jPFMoveOffset_LX(Trees[currentTree].position(), 1);
      waitPFEndMove();
      cutthistree(Trees[currentTree]);
      stumper();
      dropblock();
      currentTree++;
      }
      
      
   }
   
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
// Main Content
   
   
   function main() {
   jDropLastWindow();
   var blist = ["Log Harvester", "Log Chopper", "Log Mover", "Log Counter", "Clear Cutter", "Exit"];
   var selectWindow = jGUIWindow(jCoord(250, 250), jCoord(110, blist.length * 25 + 15), "Lumberjack");
   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]) harvester = new beginHarvest();
   if(btext == blist[1]) harvester = new mainchopper();
   //if(btext == blist[2]) harvester = new mainstacker();
   if(btext == blist[2]) harvester = new mainmover();
   if(btext == blist[3]) harvester = new maincounter();
   if(btext == blist[4]) harvester = new mainClearCutter();
   if(btext == blist[blist.length - 1]) {selectWindow.destroy(); return;};
   
   }
main();


Harvest will go to hearth, chop trees, take logs back to the idol. Make sure you have space for the stumps in your inventory, and wine/water. - buy stoneworking
Chopper will chop all logs into blocks/boards
Stacker will take logs from his hearth fire, put them by a basket.
Mover will take logs from idol, and drop them at his hearth fire
Counter... counts
Clear Cutter will chop all selected trees, remove their stumps and drop the blocks (you need spaces clear for the blocks in inventory)
Last edited by Arcanist on Sat Mar 29, 2014 7:06 pm, edited 1 time in total.
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Matheusmk » Wed Feb 12, 2014 11:32 pm

Minimap highlight PLEASE.
User avatar
Matheusmk
 
Posts: 114
Joined: Sun Feb 24, 2013 1:17 am

Re: Union Client Scripts

Postby borka » Wed Feb 12, 2014 11:41 pm

You're aware that this is Union script thread?

Minimap highlightning would have to be coded in Union client Source code and APX is sure not doing that for public Union anymore ...
Avatar by SacreDoom
Java 8 - manually downloads - good to check for actual versions url here:
viewtopic.php?f=42&t=40331
Remember what the dormouse said: Feed your head Feed your head
User avatar
borka
 
Posts: 9965
Joined: Thu Feb 03, 2011 7:47 pm
Location: World of Sprucecap

Re: Union Client Scripts

Postby Arcanist » Wed Feb 12, 2014 11:46 pm

what?

edit your haven.ini file
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Matheusmk » Wed Feb 12, 2014 11:55 pm

borka wrote:You're aware that this is Union script thread?


Yeah but i dont know russian.

Arcanist wrote:what?

edit your haven.ini file


Dont know do this sorry.

Is there any way to transfer Highlight of Ender to the Union?
Last edited by Matheusmk on Wed Feb 12, 2014 11:59 pm, edited 1 time in total.
User avatar
Matheusmk
 
Posts: 114
Joined: Sun Feb 24, 2013 1:17 am

Re: Union Client Scripts

Postby borka » Thu Feb 13, 2014 12:12 am

oh sure ty again Arcanist for pointing me in the right direction! :) the problem is to see the whole wood when examining single trees ;)

marten you can edit the haven.ini with a txt editor - look at colors in running client to see what code is what color

example
Code: Select all
/herbs/cavebulb=0xFFFF00


would show a yellow mark for cavebulbs
Avatar by SacreDoom
Java 8 - manually downloads - good to check for actual versions url here:
viewtopic.php?f=42&t=40331
Remember what the dormouse said: Feed your head Feed your head
User avatar
borka
 
Posts: 9965
Joined: Thu Feb 03, 2011 7:47 pm
Location: World of Sprucecap

Re: Union Client Scripts

Postby Matheusmk » Thu Feb 13, 2014 2:11 am

i want it shows a icon on minimap for each forageable what is near me, like ender's map.
User avatar
Matheusmk
 
Posts: 114
Joined: Sun Feb 24, 2013 1:17 am

Re: Union Client Scripts

Postby Arcanist » Thu Feb 13, 2014 5:07 am

To show icons you'll need to edit the client itself. All you can do is have colors for res items shown in the mini map.
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Bogey » Thu Feb 13, 2014 11:19 am

There was an update to Union Client some time ago made by CarryGun, he made those minimap icons so all you have to do is just download sources from Github and compile them.
User avatar
Bogey
 
Posts: 16
Joined: Sun Jun 02, 2013 4:05 pm

PreviousNext

Return to The Wizards' Tower

Who is online

Users browsing this forum: Claude [Bot] and 1 guest