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.