I'm struggling to add sqlite to Union so it is accessible from the scripts to give the bots better long-term memory (proprietary files work, but putting the stuff in a database would be more elegant).
Anyone having some pointers for me how to do that?
Union Client Scripts
Moderator: Phades
-
Granger
- Posts: 9255
- Joined: Mon Mar 22, 2010 2:00 pm
Re: Union Client Scripts
⁎ Mon Mar 22, 2010 ✝ Thu Jan 23, 2020
-
BoOty
- Posts: 233
- Joined: Sat Sep 04, 2010 1:21 pm
Re: Union Client Scripts
Just wondering how to get Script Generator to work. Technically it works after instaling old version of java (have right now 7.0, 7.64 and 8+), but after "saving" it just creates empty file named "New_forager.jbot". It console it was something like "Random" error, moreover, after "Saving' the script is getting finished but I'm unable to close the window then.
Similar with various bots like throughfiller. It allows me to point through, "shits" to collect and after collecting it's unable to put it into fooder, just getting finished. The console error is connected with "jObjectInteractClick" function, but this function is not defined in jBotAPI
Similar with various bots like throughfiller. It allows me to point through, "shits" to collect and after collecting it's unable to put it into fooder, just getting finished. The console error is connected with "jObjectInteractClick" function, but this function is not defined in jBotAPI
-
Arcanist
- Posts: 2664
- Joined: Mon Mar 19, 2012 2:01 pm
Re: Union Client Scripts
What script generator do you refer to? Can you link it/post the code in this thread?
I don't have the English documentation on hand (I'm not at home) but there is the method
jGetItems("lchest", jCoord(0,0), 50).interactClick(mod);
The convention is for jbot methods/functions to have a lower case j, and for user defined functions to not, however I cannot find jobjectInteractClick in the documentation, though as I said, I don't have access to the English version that I have at home
edit:
probably the author means this
I don't have the English documentation on hand (I'm not at home) but there is the method
it's something likepublic void interactClick(int mod)
Взаимодействие данного гоба с предметом в руках (на курсоре) персонажа
Parameters:mod - модификатор клавиатуры (1 - SHIFT; 2 - CTRL; 4 - ALT; 8 - WIN)
jGetItems("lchest", jCoord(0,0), 50).interactClick(mod);
The convention is for jbot methods/functions to have a lower case j, and for user defined functions to not, however I cannot find jobjectInteractClick in the documentation, though as I said, I don't have access to the English version that I have at home
edit:
probably the author means this
jInteractClick(Object, int) - Static method in class union.jsbot.JSHaven
Взаимодествие предмета в руках (на курсоре) с точкой на карте (в тайлах) относительно игрока
-
BoOty
- Posts: 233
- Joined: Sat Sep 04, 2010 1:21 pm
Re: Union Client Scripts
Code: Select all
//#! uniq = Script generator
//#! name = Script generator
//#! tooltip = Learning bots to move right way.
//#! icon = gfx/invobjs/itsyweb
include("jBotAPI");
// rabbit jackalope
// "gfx/invobjs/jackalope"
// "gfx/kritter/hare/body/standing/standing-0"
function main()
{
// select forager type
var modeList = ["Mountain", "Swamp", "Cave", "Forest", "Lake", "OmgWipe!", "Guard"]; //, "ChaoticCreature"];
var modeWnd = jGUIWindow(jCoord(250, 250), jCoord(220, 20 + modeList.length*30+30), "Forager bot maker");
for (var n = 0; n < modeList.length; n++)
{
jGUIButton(modeWnd, jCoord(10, 10 + n*30), 200, modeList[n]);
}
jGUIButton(modeWnd, jCoord(10, 10 + modeList.length*30 + 10), 200, "Exit");
var modeText = modeWnd.waitButtonClick();
modeWnd.destroy();
if (modeText == "Exit") return;
// tune forager
var selectWindow = jGUIWindow(jCoord(250, 250), jCoord(280, 440), "Forager bot maker");
var regionNameEnt = jGUIEntry(selectWindow, jCoord(10, 10), jCoord(260, 20), "Region name [coords]");
var accNameEnt = jGUIEntry(selectWindow, jCoord(10, 40), jCoord(260, 20), "Account name");
var charNameEnt = jGUIEntry(selectWindow, jCoord(10, 70), jCoord(260, 20), "Character name");
var curiosAllNm = []; // name
var curiosAllId = []; // world id
var curiosAllPk = []; // pack id
var curiosAllCollDef = []; // collect default
var curiosAllDropDef = []; // keep default min quality
var modeNum = -1;
if (modeText == modeList[0]) // mountain
{
curiosAllNm = ["Edelweiss", "Frog's crown", "Glimmermoss", "Feldspar"];
curiosAllId = ["edelweiss", "frogscrown", "glimmermoss", "feldspar"];
curiosAllPk = ["edelweiss", "frogscrown", "glimmermoss", "feldspar"];
curiosAllCollDef = [true, true, false, false];
curiosAllDropDef = [20, 20, 20, 50];
modeNum = 0;
}
if (modeText == modeList[1]) // swamp
{
curiosAllNm = ["Bluebell", "Toadstool", "Lady's Mantle", "Bloated bolete"];
curiosAllId = ["bluebell", "toadstool", "ladysmantle", "bloatedbolete"];
curiosAllPk = ["bluebell", "toadstool", "ladysmantle", "bloatedbolete"];
curiosAllCollDef = [true, true, false, true];
curiosAllDropDef = [1, 25, 100, 15];
modeNum = 1;
}
if (modeText == modeList[2]) // cave
{
curiosAllNm = ["Glimmermoss", "Stalagoom", "Cavebulb", "Cave clay"];
curiosAllId = ["glimmermoss", "stalagoom", "cavebulb", "caveclay"];
curiosAllPk = ["glimmermoss", "stalagoom", "cavebulb", "clay-cave"];
curiosAllCollDef = [true, true, false, false];
curiosAllDropDef = [20, 20, 1, 65];
modeNum = 2;
}
if (modeText == modeList[3]) // forest
{
curiosAllNm = ["Bloated bolete", "Blueberries", "Chantrelles", "Rustroot"];
curiosAllId = ["bloatedbolete", "blueberry", "chantrelle", "rustroot"];
curiosAllPk = ["bloatedbolete", "blueberry", "chantrelle", "rustroot"];
curiosAllCollDef = [true, false, false, false];
curiosAllDropDef = [20, 1, 1, 1];
modeNum = 3;
}
if (modeText == modeList[4]) // lake
{
curiosAllNm = ["Flotsam", "Mussel", "Gray clay"];
curiosAllId = ["flotsam", "mussel", "grayclay"];
curiosAllPk = ["flotsam", "mussel", "clay-gray"];
curiosAllCollDef = [true, false, false];
curiosAllDropDef = [1, 1, 1];
modeNum = 4;
}
if (modeText == modeList[5]) // noobs (spindlytaproot - spindlytaproot)
{
curiosAllNm = ["WWW", "Nettle", "Clover", "Candleberry"];
curiosAllId = ["windweed", "stingingnettle", "fourleafclover", "candleberry"];
curiosAllPk = ["windweed", "stingingnettle", "fourleafclover", "candleberry"];
curiosAllCollDef = [true, false, false, false];
curiosAllDropDef = [1, 1, 1, 1];
modeNum = 5;
}
if (modeText == modeList[6]) // shocked
{
curiosAllNm = [];
curiosAllId = [];
curiosAllPk = [];
curiosAllCollDef = [];
curiosAllDropDef = [];
modeNum = 6;
}
if (modeText == modeList[7]) // shocked
{
curiosAllNm = ["Bluebell also"];
curiosAllId = ["bluebell"];
curiosAllPk = ["bluebell"];
curiosAllCollDef = [true];
curiosAllDropDef = [1];
modeNum = 7;
}
var curiosBoxesColl = [];
var curiosBoxesDrop = [];
for (var n = 0; n < curiosAllNm.length; n++)
{
curiosBoxesColl[n] = jGUICbox(selectWindow, jCoord(10, 100 + n*30), "Collect "+curiosAllNm[n]);
curiosBoxesColl[n].setChecked(curiosAllCollDef[n]);
curiosBoxesDrop[n] = jGUIEntry(selectWindow, jCoord(160, 100 + n*30 + 14), jCoord(50, 20), curiosAllDropDef[n].toString());
}
var startBtn = "Start";
var addPointBtn = "AddPoint";
var saveBtn = "Save";
var exitBtn = "Exit";
jGUIButton(selectWindow, jCoord(10, 250), 260, startBtn);
jGUIButton(selectWindow, jCoord(10, 305), 260, addPointBtn);
jGUIButton(selectWindow, jCoord(10, 360), 260, saveBtn);
jGUIButton(selectWindow, jCoord(220, 410), 50, exitBtn);
selectWindow.toggleCloseButton();
var uniqName = ["Mountain_Forager_", "Swamp_Forager_", "Cave_Forager_", "Forest_Forager_", "Lake_Forager_", "OmgWipe_Forager_", "Guard_", "Shocked_Forager_"];
var tooltipText = ["Collects curios at mountain", "Collects curios at swamp", "Collects curios in cave", "Collects curios it the forest", "Collects curios at lake", "Collects noobs items", "Oversees your area for rams and enemy activity", "Collects Shocked frogs"];
var iconName = ["gfx/invobjs/herbs/edelweiss", "gfx/invobjs/herbs/chimingbluebell", "gfx/invobjs/herbs/cavebulb", "gfx/invobjs/herbs/bloatedbolete", "gfx/invobjs/herbs/flotsam", "gfx/invobjs/herbs/fourleafclover", "gfx/hud/skills/ranger", "gfx/invobjs/frog"];
var mainFunctionName = ["CollectMount2", "CollectSwamp2", "CollectMount2", "CollectSwamp2", "CollectLake2", "CollectSwamp2", "CheckRams", "CollectShocked"];
var wpts = [];
var startPos = jMyCoords(0, 0);
var isStarted = false;
while (true)
{
var btext = selectWindow.waitButtonClick();
if (btext == startBtn)
{
jSendDoubleAction("theTrav", "hearth");
jInGamePrint("Teleporting to HF. Wait.");
jWaitProgress(actionTimeout);
startPos = jMyCoords();
isStarted = true;
wpts = [];
jInGamePrint("Started!");
}
if (btext == addPointBtn)
{
var pos = jMyCoords();
wpts.push(jCoord((pos.x-startPos.x)/11, (pos.y-startPos.y)/11));
jInGamePrint("New waypoint, offset = "+(pos.x-startPos.x)/11+", "+(pos.y-startPos.y)/11);
}
if (btext == saveBtn)
{
var regionName = regionNameEnt.getText();
var accName = accNameEnt.getText();
var charName = charNameEnt.getText();
var f = new java.io.FileWriter("New_Forager.jbot");
f.write("//#! uniq = "+uniqName[modeNum]+Random(10000000, 100000000)+"\n");
f.write("//#! name = "+charName+" - "+regionName+"\n");
f.write("//#! tooltip = "+tooltipText[modeNum]+"\n");
f.write("//#! icon = "+iconName[modeNum]+"\n");
f.write("\n");
f.write('include(\"jBotAPI(2)\");'+"\n");
f.write("\n");
f.write('// Before start set camera mode "Fixed" or "Borderizer"'+"\n");
f.write("\n");
f.write('var accName = "'+accName+'"; // account name'+"\n");
f.write('var charName = "'+charName+'"; // character name'+"\n");
f.write("\n");
var collectStr = "";
var nonCollectStr = "";
var dropStr = "";
var nonDropStr = "";
var dropQualityStr = "";
var nonDropQualityStr = "";
for (var n = 0; n < curiosAllId.length; n++)
{
if (curiosBoxesColl[n].isChecked())
{
collectStr = collectStr + '"' + curiosAllId[n] + '", ';
dropStr = dropStr + '"' + curiosAllPk[n] + '", ';
dropQualityStr = dropQualityStr + curiosBoxesDrop[n].getInt() + ', ';
}
else
{
nonCollectStr = nonCollectStr + '"' + curiosAllId[n] + '", ';
nonDropStr = nonDropStr + '"' + curiosAllPk[n] + '", ';
nonDropQualityStr = nonDropQualityStr + curiosBoxesDrop[n].getInt() + ', ';
}
curiosBoxesDrop[n].setText(curiosBoxesDrop[n].getInt().toString());
}
f.write('collectCurios = ['+collectStr+']; // '+nonCollectStr+"\n");
f.write('dropCurios = ['+dropStr+']; // '+nonDropStr+"\n");
f.write('dropQuality = ['+dropQualityStr+']; // '+nonDropQualityStr+"\n");
f.write("\n");
f.write("// Path depends on the marsh mountain or lake etc"+"\n");
f.write("var startPos = jCoord(0, 0);"+"\n");
f.write("var waypoints ="+"\n");
f.write("["+"\n");
for (var i = 0; i < wpts.length; i++)
{
f.write(" ["+wpts[i].x+", "+wpts[i].y+"],"+"\n");
}
f.write("];"+"\n");
f.write("\n");
f.write("function main()"+"\n");
f.write("{"+"\n");
f.write(" "+mainFunctionName[modeNum]+"(accName, charName, collectCurios, dropCurios, dropQuality, startPos, waypoints);"+"\n");
f.write("}"+"\n");
f.write("\n");
f.write("main();"+"\n");
f.close();
jInGamePrint("Script file <New_Forager.jbot> created. Rename and put it to /Scripts directory");
}
if (btext == exitBtn)
{
break;
}
}
selectWindow.destroy();
}
main();
Code: Select all
jInGamePrint("Script file <New_Forager.jbot> created. Rename and put it to /Scripts directory");-
AryaStark
- Posts: 43
- Joined: Fri Sep 19, 2014 8:55 pm
- Location: Secluded Island
Re: Union Client Scripts
I have been fighting with the combined logger script from Russian forums, but cannot figure out what I am doing wrong. When enabling the script, the menu pops up and freezes. Neither function buttons, nor button to close menu works, i have to relog to remove the menu. Am using the API, is there anything else I need to modify to get it working? Holding ax with flask and bucket of water in inventory at start. Thank you for your help.
Code: Select all
//#! name = Combined Logger
//#! tooltip = Harvest, Chop, Move Logs
//#! icon = gfx/invobjs/axe
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(25, 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 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/apple", "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/apple", "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(50, 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);
}
}
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, 2));
equip.takeAt(6);
jWaitDrag(actionTimeout);
inventory.drop(axe.coord());
jSleep(1000);
waitDragName("axe");
equip.dropTo(6);
jWaitDrop(actionTimeout);
}
}
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);
logcount++;
}
}
function takethislog(log) {
jSendAction("carry");
jWaitCursor("chi");
jDoClick(log.getID(), 1, 0);
jWaitMove(2500);
logcount++;
}
function droplog() {
jAbsClick(jMyCoords(), 3, 0);
jWaitMove(1000);
return;
}
function droplognorth() {
jOffsetClick(jCoord(0, -1), 3, 0);
jWaitMove(1000);
return;
}
function stumper(){
jSleep(100);
var target_stump = getNearestStump();
jDoClick(target_stump.getID(), 3, 0);
jWaitPopup(1000);
jSelectContextMenu("Remove");
jSleep(200);
jWaitProgress(actionTimeout);
drinkWater();
return;
}
function resetCursor() {
if (!jIsCursor("arw")) {
jAbsClick(jCoord(0, 0), 3, 0);
jWaitCursor("arw", actionTimeout);
}
}
function cuttree() {
jDoClick(getNearestTree().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");
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()) {
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();
return;}
if (closetree()) {
cuttree();
stumper();
takelog();
if (jFindObjectByName ("borka", 1).isCarrying ()) {tovillage();}
else {jToConsole ("An Error Occured"); jExit(); }
return;}
jToConsole("Nothing Found");
return;
}
function logHarvester() {
jToConsole (winecount/5 + "L of Wine");
jToConsole (logcount + " Logs taken");
jMoveStep(jCoord(2, 0));
jWaitMove(1000);
if (getNearestStump()) {
jToConsole ("Clearing Stumps");
if ( jIsPathFree(getNearestStump().position()) ) {}
else {
jPFMoveOffset_LX(getNearestStump().position(), 1);
waitPFEndMove();
}
stumper();
dropblock();
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();
stumper();
}
else {
jToConsole("No more trees");
jExit();
}
}
jToConsole("I found a log");
if ( jIsPathFree(getNearestLog().position()) ) { takelog(); }
else {
jPFMoveOffset_LX(getNearestLog().position(), 2);
waitPFEndMove();
takelog();
jSleep(300);
}
while (count < 3) {
if (jFindObjectByName ("borka", 1).isCarrying ()) {
tovillage();
droplog();
dropblock();
tohearth();
beginHarvest();
count++;
jSleep(1000);}
else {checkRock(); }
}
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 = all_log[i];
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 = all_log[i];
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++;
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 {jPFMoveOffset_LX(getNearestLog().position(), 0); waitPFEndMove();}
takethislog(getNearestLog())
if (jFindObjectByName ("borka", 1).isCarrying ()) {tohearth();}
else {mainmover();}
droplognorth();
jSleep(200);
tovillage();
mainmover();
}
}
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
// Main Content
function main() {
jDropLastWindow();
var blist = ["Log Harvester", "Log Chopper", "Log Mover", "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[blist.length - 1]) {selectWindow.destroy(); return;};
}
main();-
Arcanist
- Posts: 2664
- Joined: Mon Mar 19, 2012 2:01 pm
Re: Union Client Scripts
AryaStark wrote:I have been fighting with the combined logger script from Russian forums, but cannot figure out what I am doing wrong. When enabling the script, the menu pops up and freezes. Neither function buttons, nor button to close menu works, i have to relog to remove the menu. Am using the API, is there anything else I need to modify to get it working? Holding ax with flask and bucket of water in inventory at start. Thank you for your help.
This is my logger, sometimes that happens (repetitively), it also happens with other scripts, especially if they are large.
Try this updated version.
Code: Select all
//#! name = Logger
//#! icon = gfx/invobjs/axe
//#! uniq = Arcanist_logger
/*include("jBotAPITalon");
include("jBotAPIArcanist");
include("jBotAPI");*/
include("pathfinder");
include("jBotAPI");
include("jBotAPIArcanist");
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
var currentsign = 0
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
//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 obj = jGetObjects(40, jCoord(0, 0), ["trees/fir", "trees/pine", "trees/yew", "trees/birch", "trees/elm",
"trees/oak", "trees/willow", "trees/atree", "trees/maple", "trees/mulberry", "trees/hazel"]);
var min_len = 100500;
var objid = 0;
for (var i = 0; i < obj.length; i++) {
if (obj[i].position().dist(jMyCoords()) < min_len) {
objid = obj[i];
min_len = obj[i].position().dist(jMyCoords());
}
}
return objid;
}
function dropFromCursor(where) { // 1 = inventory
if (jIsDragging()) {
if (where = null) where = 1
if (where = 1) {
if (checkInventory().freeSlots() > 0) checkInventory().drop(checkInventory().freeSlotsCoords()[0]);
jSleep(500);
if (!jIsDragging()) return;
}
while (jIsDragging()) {
jDropObject(0);
jSleep(300);
}
}
}
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() {
if (travelCount() > 50)
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));
jSleep(1000);
jMoveStep(jCoord(-1, 0));
jSleep(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();
goNearPosition( target_stump.position(), 1);
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 putItemsToSigns (itemlist, signlist, signwindow, radius) {
if (radius == null) radius = 1;
var out = 0;
while (checkInventory().getItems(itemlist).length > 0) {
var inventory = checkInventory();
while (!jGetWindow(signwindow)){
jPFMoveOffset_LX(signlist[out].position(), radius);
waitPFEndMove();
var player_pos = jMyCoords();
jDoClick(signlist[out].getID(),3,0);
jSleep(1500);
}
var buildvals = GetBuildValues(signwindow, 1);
jToConsole(buildvals[0]);
if (checkInventory().getItems(itemlist).length > 0){
if (jGetWindow(signwindow) != -1 && buildvals[0] > 0) {
jToConsole("Putting Items into the Container");
if (inventory.getItems(itemlist).length > 0) inventory.getItems(itemlist)[0].transferSuchAll();
jSleep(500);
jAbsClick(player_pos, 1, 0);
if (checkInventory().getItems(itemlist).length == 0) return signlist;
}
else {
signlist.splice(out, 1);
jToConsole("Deleted Full Container");
jMoveStep(jCoord(0, 0));
//out++;
jSleep(500);
}
}
}
jSleep(1000);
return signlist;
}
function stackblock(pile) {
putItemsToSigns ("block", pile, "Palisade Cornerpost", 1)
}
function selectMultiple(object, type) {
var ta = [];
var ids = [];
while (1) {
var sign = jSelectObject("Select "+ type+ " , click on the ground to stop selecting");
if (sign == null) break;
var name = sign.name();
if (name.indexOf(object) != -1) {
if (ids.indexOf(sign.getID()) != -1) {
jToConsole("ERROR: This "+type+" has been already selected.");
continue;
}
ta.push(sign);
ids.push(sign.getID());
jToConsole(type +" count: " + ta.length);
}
else break;
}
return ta;
}
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 startharvest() {
//var piles = selectMultiple("sign", "Pali signs");
tohearth();
beginHarvest();
}
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));
jSleep(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();
if (!jFindObjectByName ("borka", 1).isCarrying ());
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();
//if (piles.length > 1) {putItemsToSigns ("block", piles, "Palisade Cornerpost", 1)}
//if (piles.length == 1) {putItemsToSign ("block", piles, "Palisade Cornerpost", 1)}
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() {
while(1){
if (getNearestLog()) {
jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
if(jIsPathFree(getNearestLog().position())) {}
else {jPFMoveOffset_LX(getNearestLog().position(), 1);; waitPFEndMove();}
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();
}
else {tovillage();}
}
}
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 piles = selectMultiple("sign", "Pali CPs")
var currentTree = 0;
while (1) {
if (currentTree == Trees.length) {jExit();}
jPFMoveOffset_LX(Trees[currentTree].position(), 1);
waitPFEndMove();
cutthistree(Trees[currentTree]);
stumper();
if(piles != null)stackblock(piles);
dropblock();
currentTree++;
}
}
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
// Stacker
function mainstacker(){
var woods = jGetObjects(50, jCoord(0, 0), ["log"]);
var logt = woods.length
var logc = 0
jToConsole(logt+" logs total");
while (logc < logt) {
jPFMoveOffset_LX(woods[logc].position(), 0);
takethislog(woods[logc]);
tohearth();
droplognorth();
logc++
jToConsole(logc + " Logs Taken");
jSleep(500);
} }
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
// Stumper
function mainstumper(){
while(1) {
stumper();
dropFromCursor(1);
}
}
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
// Main Content
function main() {
jDropLastWindow();
var blist = ["Log Harvester", "Log Chopper", "Log Mover", "Log Counter", "Clear Cutter", "Log Stacker","Stumper", "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]) startharvest();
if(btext == blist[1]) mainchopper();
//if(btext == blist[2]) harvester = new mainstacker();
if(btext == blist[2]) movermain2();
if(btext == blist[3]) maincounter();
if(btext == blist[4]) mainClearCutter();
if(btext == blist[5]) mainstacker();
if(btext == blist[6]) mainstumper();
if(btext == blist[blist.length - 1]) {selectWindow.destroy(); return;};
}
main();-
Mernil
- Posts: 133
- Joined: Tue Jul 29, 2014 9:54 pm
Re: Union Client Scripts
How do you send punch action?
-
Arcanist
- Posts: 2664
- Joined: Mon Mar 19, 2012 2:01 pm
Re: Union Client Scripts
Mernil wrote:How do you send punch action?

-
Mernil
- Posts: 133
- Joined: Tue Jul 29, 2014 9:54 pm
Re: Union Client Scripts
Thanks!
Also, any luck playing with FEPs?
There are some functions in JSHaven.java :
jGetFepCurrentList()
jGetFepCurrentAmount()
jGetFepCurrentCap()
jGetFepMaxValue()
...
But :
[JSBot ScriptSyntax Error] ReferenceError: "jGetFepCurrentList" is not defined.
[JSBot ScriptSyntax Error] ReferenceError: "jGetFepMaxValue" is not defined.
[JSBot ScriptSyntax Error] ReferenceError: "jGetFepCurrentAmount" is not defined.
Also, any luck playing with FEPs?
There are some functions in JSHaven.java :
jGetFepCurrentList()
jGetFepCurrentAmount()
jGetFepCurrentCap()
jGetFepMaxValue()
...
But :
[JSBot ScriptSyntax Error] ReferenceError: "jGetFepCurrentList" is not defined.
[JSBot ScriptSyntax Error] ReferenceError: "jGetFepMaxValue" is not defined.
[JSBot ScriptSyntax Error] ReferenceError: "jGetFepCurrentAmount" is not defined.
-
Arcanist
- Posts: 2664
- Joined: Mon Mar 19, 2012 2:01 pm
Re: Union Client Scripts
I can't find those in the documentation, those functions have probably been made by someone by looking at the values of "Character Sheet" and doing some maths