Bramson wrote:Working on a script where I want to pull things out of a build site..
jGetBuildValues("signname",1).charAt(0)
I can determine how much left needed to put in, but what about pulling out?
What code would make it so you can pull stuff out instantly with transferSuchAll();
Thanks!
1.
// Village Banner sign example
var values = jGetBuildValues("Village Banner", 1); // Get full string
var parts = values.split("/"); // Split it
var left = parseInt(parts[0]); // Convert string to int with native js parseInt function
var placed = parseInt(parts[1]);
var builded = parseInt(parts[2]);
2. There's no transferSuchAll for signs (i didn't implement it at least, maybe Kerrigan), you can just transfer items in the loop.
W10Meme Plot | W9Mantis Garden | W8Core | W7Ofir | W6the City of Dis | W5Vitterstad | W4A.D. | W3Mirniy
jorb wrote:All your characters will be deleted, and I will level every village any one of them were ever members of.
I have a question. What value represents the "jSleep ()". Is it a tics in the game or a millisecond? If this is tics in the game, how many ticks equivalent to one second?
Investor wrote:I have a question. What value represents the "jSleep ()". Is it a tics in the game or a millisecond? If this is tics in the game, how many ticks equivalent to one second?
Pretty sure it's ms.
Jalpha wrote:I believe in my interpretation of things.
I will be releases some various scripts for Union Client. My hope is if you find it useful, and improve upon it please share it with me to improve code. You can PM me any code changes that helps improve it and make it run smoother/faster/better. Thank you in advance for sending me improvements.
1. Rock Destroyer v1.0! - Have pesky rocks from celler you want destroyed? here you go!
note: to edit rockdestroy range, at the top under SETTINGS change rockRadius.
CODE:
//#! name = BR Rock Destroyer v1.0
//#! tooltip = BR Works v0.1
//#! icon = gfx/invobjs/paxe
//Global
jToConsole("Start of Rock Destroyer v1.0.");
var inventory = checkInventory();
//Settings
var actionTimeout = 1000 * 60 * 2; // Lag timeout
var rockRadius = 10;
// Flags
var stopFlag = 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 checks inventory
//and opens it, if it closed
function checkInventory() {
if(!jHaveWindow("Inventory")) {
jToggleInventory();
while(!jHaveWindow("Inventory"))
jSleep(100);
}
return jGetWindow("Inventory").getInventories()[0];
}
//Reset Cursor
function resetCursor() {
if (!jIsCursor("arw")) {
jAbsClick(jCoord(0, 0), 3, 0);
jWaitCursor("arw", actionTimeout);
}
}
//Drink Water
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;
}
}
}
}
//Main Function
function main() { //1S
drinkWater();
var bumling = jGetObjects(rockRadius,0,"bumlings/02");
while (bumling != 0) { //2S
jToConsole("Rocks to Turn to Runestones:" + bumling.length);
for (var i = 0; i < bumling.length; i++) { //3S
drinkWater();
jSendDoubleAction("swrk","runestone");
jWaitCursor("chi");
bumling[i].doClick(1,0);
while (bumling[i].isActual() == true) jSleep(200);
} //3E
resetCursor();
var runeStones = jGetObjects(rockRadius,0,"runestone"); //????????? ?????????
jToConsole("Runestone to Destroy:" + runeStones.length);
for (var i = 0; i < runeStones.length; i++) { //3S
while (runeStones[i].isActual()) {
jSendAction("destroy");
jWaitCursor("mine")
runeStones[i].doClick(1,0);
jWaitProgress(300000);
drinkWater();
}
} //3E
resetCursor();
if (bumling = 0)
{
if (runeStones = 0)
{
jToConsole("Nothing else to break!");
jSleep(500);
jExit();
}
}
} //2E
} //1E
main();
1. Cellar Digger v1.0! - Wanna dig that cellar? No problem. Just build it and turn on bot and come back in abit.
note: its a good idea to have a couple buckets of water, and I am not responsible if you starve yourself
CODE:
//#! name = BR Cellar Digger v1.0
//#! tooltip = BR Works v0.1
//#! icon = gfx/invobjs/paxe
//Global
jToConsole("Start of BR Cellar Digger v1.0");
var inventory = checkInventory();
var cellar_door = jFindObjectByName("arch/door-cellar", 10);
var count = 0;
//Settings
var actionTimeout = 1000 * 60 * 2; // Lag timeout
var rockRadius = 10; // Distance to check for rocks & runestones
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 checks inventory
//and opens it, if it closed
function checkInventory() {
if(!jHaveWindow("Inventory")) {
jToggleInventory();
while(!jHaveWindow("Inventory"))
jSleep(100);
}
return jGetWindow("Inventory").getInventories()[0];
}
//Reset Cursor
function resetCursor() {
if (!jIsCursor("arw")) {
jAbsClick(jCoord(0, 0), 3, 0);
jWaitCursor("arw", actionTimeout);
}
}
//Drink Water
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(300000);
} else {
// No water
stopFlag = true;
}
}
}
}
//Main Function
//Get Rock
function getrock() {
drinkWater();
jToConsole("Getting Rock");
jPrint("Getting Rock");
cellar_door.doClick(3,0); //jDoClick(cellar_door, 3, 0);
jWaitProgress(1000 * 60 * 10);
jOffsetClick(jCoord(0, -1), 3, 0);
jWaitMove(1000 * 60);
}
//Make Runestone
function makerunestone() {
drinkWater();
var bumling = jGetObjects(rockRadius,0,"bumlings/02");
jToConsole("Making Runestone");
jPrint("Making Runestone");
for (var i = 0; i < bumling.length; i++) {
drinkWater();
jSendDoubleAction("swrk","runestone");
jWaitCursor("chi");
bumling[i].doClick(1,0);
while (bumling[i].isActual() == true) jSleep(200);
}
}
//Destroy Runestone
function destroyrunestone() {
drinkWater();
var runeStones = jGetObjects(rockRadius,0,"runestone");
jToConsole("Destroying Runestone");
jPrint("Destroying Runestone");
for (var i = 0; i < runeStones.length; i++) {
while (runeStones[i].isActual() == true) {
jSendAction("destroy");
jWaitCursor("mine")
runeStones[i].doClick(1,0);
jWaitProgress(300000);
drinkWater();
}
}
}
function main() {
jSleep(500);
getrock();
jSleep(500);
makerunestone();
jSleep(500);
destroyrunestone();
count++;
jToConsole(count);
jPrint(count);
}
while(1) {
main();
}
3. Well2Tube v1.0! - Need to fill your tubs? Well here we go! Ideal to use 6 buckets, it will fill em and load the tubs up to 60% water. I know someone out there can help me get this faster! Send me an update!
CODE:
//#! name = BR Well to Tub v1.0
//#! tooltip = BR Works v0.1
//#! icon = gfx/terobjs/ttubw
var count = 0;
var count2 = 0;
var count3 = 0;
var buckets = jGetWindow("Inventory").getInventories()[0].getItems("buckete");
var bucket_start = buckets.length;
var all_tub = 0;
var RAD = 14;
var tubs = jGetObjects(RAD, jCoord(0, 0), "ttub");
var all_tubs = tubs.length;
jToConsole("Total Tubs to fill = " + tubs.length);
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 checks inventory
//and opens it, if it closed
function checkInventory()
{
if(!jHaveWindow("Inventory"))
{
jToggleInventory();
while(!jHaveWindow("Inventory"))
jSleep(100);
}
}
//Start of Well 2 Tub
//Go to well
function go_to_well()
{
inventory = checkInventory();
var well = jFindObjectByName("well", 20); //well
//if no wells around
if(!well)
{
jToConsole("Cannot find a well. Script failed.");
return;
}
jSleep(100);
tile = jPFMoveOffset_LX(well.position(),-1);
jToConsole("I'm at well");
}//main fuction end
function get_water()
{
if (jGetWindow("Inventory").getInventories()[0].getItems("buckete")[0] == undefined){
if (jGetWindow("Inventory").getInventories()[0].getItems("bucket-water")[0] == undefined){
jToConsole("No empty buckets in inventory. Script stopped");
jExit();
}
}
var buckets = jGetWindow("Inventory").getInventories()[0].getItems("buckete");
jToConsole("Buckets to Fill =" + buckets.length);
count2 = null;
for (var k = count2; k < buckets.length; k++) {
var bucket2 = jGetWindow("Inventory").getInventories()[0].getItems("buckete")[0];
var bc = bucket2.coord();
jPrint("bc = " + bc);
bucket2.take();
jWaitDrag(5000);
jSleep(100);
var well = jFindObjectByName("well", 20); //well
well.interactClick(0);
var drag = jGetDraggingItem();
//waits for the filled bucket
while(drag.resName().indexOf("water") == -1) {
jSleep(100);
}//end while
jGetWindow("Inventory").getInventories()[0].drop(bc);
jWaitDrop(5000);
jSleep(100);
count2++;
}
}//main fuction end
function fill_tub() {
jToConsole("Bucket's Filled, filling tub");
var inventory = checkInventory();
if (tubs == null) {
var tubs = jGetObjects(RAD, jCoord(0, 0), "ttub");
all_tubs = tubs.length;
}
//filling tubs
for (var i = count; i < tubs.length; i++) {
var bucket_inventory1 = jGetWindow("Inventory").getInventories()[0].getItems("bucket-water");
if (bucket_inventory1.length >= bucket_start) {
tile = jPFMoveOffset_LX(tubs[i].position(),1);
jDoClick(tubs[i].getID(), 3, 0);
//waits for tub window
jWaitWindow("Tanning Tub");
jSleep(500);
count3 = null;
var WaterInTub = jGetWindow("Tanning Tub").getMeterValue(1);
//jToConsole(WaterInTub); //For debugging purposes
if (WaterInTub < 60) {
//transfer water
var bucket_inventory2 = jGetWindow("Inventory").getInventories()[0].getItems("bucket-water");
for (var j = count3++; j < bucket_inventory2.length; j++) {
var bucket2 = jGetWindow("Inventory").getInventories()[0].getItems("bucket-water")[0];
var bc2 = bucket2.coord();
bucket2.take();
jWaitDrag(5000);
tubs[i].interactClick(0);
var drag2 = jGetDraggingItem();
jSleep(1000);
jGetWindow("Inventory").getInventories()[0].drop(bc2);
jWaitDrop(5000);
jSleep(100);
count3++;
}
}
jSleep(1000);
count++;
jToConsole(count);
if (count == all_tubs) {
jToConsole("I'm done.");
jExit();
}
}
}
}//main fuction end
function main() {
go_to_well();
get_water();
fill_tub();
}
while(1) {
main();
}
4. Get Dreams v1.0! - who likes to do this anyhow? It works best if you setup a location for a farm, and position each dream catcher on the edge of the grid. (no PF issues)
CODE:
Hi, i was trying to run the farming script posted on the first page but i get this error.
When i start the script seedbags open and the popup with the different croops pops up but then it finishes.
fehler.jpg
would be very nice if someone could help me or give me a hint.
You do not have the required permissions to view the files attached to this post.