When I try to use getNearestTree() I get the error jObjectPos is not defined.
What can I do to define jObjectPos?
Union Client Scripts
Moderator: Phades
-
APXEOLOG
- Posts: 1300
- Joined: Fri Apr 23, 2010 7:58 am
- Location: Somewhere on Earth
Re: Union Client Scripts
use jGob(id).position() instead of jObjectPos(id)Arcanist wrote:When I try to use getNearestTree() I get the error jObjectPos is not defined.
What can I do to define jObjectPos?
W10 Meme Plot | W9 Mantis Garden | W8 Core | W7 Ofir | W6 the City of Dis | W5 Vitterstad | W4 A.D. | W3 Mirniy
jorb wrote:All your characters will be deleted, and I will level every village any one of them were ever members of.
-
Arcanist
- Posts: 2664
- Joined: Mon Mar 19, 2012 2:01 pm
Re: Union Client Scripts
Thanks, so I should edit the japi file
Code: Select all
function getNearestTree() {
var trees = jGetObjects(25, jCoord(0, 0), ["trees/fir", "trees/pine"]);
var min_len = 100500; var objid = 0;
for (var i = 0; i < trees.length; i++) {
if (jGob(trees[i]).dist(jMyCoords()).position() < min_len) {
objid = trees[i];
min_len = jGob(trees[i]).dist(jMyCoords()).position();
}
}
return objid;-
APXEOLOG
- Posts: 1300
- Joined: Fri Apr 23, 2010 7:58 am
- Location: Somewhere on Earth
Re: Union Client Scripts
trees is already jGob. you can just use trees.position()
W10 Meme Plot | W9 Mantis Garden | W8 Core | W7 Ofir | W6 the City of Dis | W5 Vitterstad | W4 A.D. | W3 Mirniy
jorb wrote:All your characters will be deleted, and I will level every village any one of them were ever members of.
-
Arcanist
- Posts: 2664
- Joined: Mon Mar 19, 2012 2:01 pm
Re: Union Client Scripts
Is seems the client cannot find the function dist, so I replaced it for position.
Now the client cannot find method position, perhaps I've made a stupid error...
Now the client cannot find method position, perhaps I've made a stupid error...
Code: Select all
function getNearestTree() {
var trees = jGetObjects(25, jCoord(0, 0), ["trees/fir", "trees/pine"]);
var min_len = 100500; var objid = 0;
for (var i = 0; i < trees.length; i++) {
if (trees[i].position(jMyCoords()) < min_len) {
objid = trees[i];
min_len = trees[i].position(jMyCoords());
}
}
return objid;
}-
APXEOLOG
- Posts: 1300
- Joined: Fri Apr 23, 2010 7:58 am
- Location: Somewhere on Earth
Re: Union Client Scripts
You've made it. you don't need to add arguments for position().
Code: Select all
function getNearestTree() {
var trees = jGetObjects(25, jCoord(0, 0), ["trees/fir", "trees/pine"]);
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;
}W10 Meme Plot | W9 Mantis Garden | W8 Core | W7 Ofir | W6 the City of Dis | W5 Vitterstad | W4 A.D. | W3 Mirniy
jorb wrote:All your characters will be deleted, and I will level every village any one of them were ever members of.
-
Arcanist
- Posts: 2664
- Joined: Mon Mar 19, 2012 2:01 pm
Re: Union Client Scripts
most functions are stolen.
Works, but not well.
Start it at the HF, out in the woods with wine and water and an axe in hand.
There must be 4 2x1 slots free
Works, but not well.
Start it at the HF, out in the woods with wine and water and an axe in hand.
There must be 4 2x1 slots free
Code: Select all
//#! name = log harvester
//#! tooltip = harvest log
var actionTimeout = 1000 * 60 * 1;
var hartling = jMyCoords();
var inventory = checkInventory();
var player = jGetObjects(1,0,"borka");
function checkInventory() {
if(!jHaveWindow("Inventory")) {
jToggleInventory();
while(!jHaveWindow("Inventory"))
jSleep(100);
}
return jGetWindow("Inventory").getInventories()[0];
}
function getNearestTree() {
var trees = jGetObjects(25, jCoord(0, 0), ["trees/fir", "trees/pine"]);
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 harvest(){
var log = jFindObjectByName("log", 15).getID();
jSendAction("carry");
jWaitCursor("chi");
jDoClick(log, 1, 0);
jWaitMove();
jSendDoubleAction("theTrav", "village");
jWaitProgress(300000);
jMoveStep(jCoord(0, -2));
jWaitMove();
jAbsClick(jMyCoords(), 3, 0);
jWaitMove();
jPFMove(hartling);
waitPFEndMove();
jAbsClick(jMyCoords(), 1, 0);
jSendDoubleAction("theTrav", "hearth");
}
function tohearth() {
jSendDoubleAction("theTrav", "hearth");
jWaitProgress(300000);
}
function tovillage() {
drinkWine();
jSleep(500);
jSendDoubleAction("theTrav", "village");
jWaitProgress(300000);
}
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, 2));
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 takelog() {
var log = jFindObjectByName("log", 50).getID();
jSendAction("carry");
jWaitCursor("chi");
jDoClick(log, 1, 0);
jWaitMove();
return;
}
function droplog() {
jAbsClick(jMyCoords(), 3, 0);
jWaitMove();
return;
}
function stumper(){
while(true){
jSleep(100);
jSetSpeed(1);
if(jGetStamina() < 40){
checkInventory();
var waterflask = jGetWindow("Inventory").getInventories()[0].getItems("waterflask")[0];
var bucket = jGetWindow("Inventory").getInventories()[0].getItems("bucket-water")[0];
var bucket_coord = bucket.coord();
bucket.take();
jWaitDrag(5000);
jSleep(200);
waterflask.itemact(0);
jSleep(200);
jGetWindow("Inventory").getInventories()[0].drop(bucket_coord);
jWaitDrop(5000);
jSleep(200);
waterflask.iact();
jWaitPopup(1000);
jSelectContextMenu("Drink");
jSleep(200);
jWaitEndProgress(10000);
} else {
var target_stump = jFindObjectByName("stump", 30);
jDoClick(target_stump.getID(), 3, 0);
jWaitPopup(1000);
jSelectContextMenu("Remove");
jWaitMove(20000);
jSleep(200);
jWaitEndProgress(65000);
jSleep(200);
jSleep(200);
return;
}
}
}
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 _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 resetCursor() {
if (!jIsCursor("arw")) {
jAbsClick(jCoord(0, 0), 3, 0);
jWaitCursor("arw", actionTimeout);
}
}
function waitPFEndMove() {
while (true) {
jWaitEndMove();
jSleep(500);
if (!jIsMoving()) {
return;
}
}
}
function treecutter() {
var target_tree = jFindObjectByName("fur06", 30);
jDoClick(target_tree, 3, 0);
jWaitPopup(1000);
jSelectContextMenu("chop");
jWaitMove(20000);
jSleep(200);
jWaitEndProgress(65000);
jSleep(200);
}
function walktotree() {
jPFMove (getNearestTree().getID() );
waitPFEndMove();
return;}
function cuttree() {
jDoClick(getNearestTree().getID(), 3, 0);
jWaitPopup(3000);
jSelectContextMenu("Chop");
jWaitMove(20000);
jSleep(200);
jWaitEndProgress(65000);
jSleep(200);
return;}
function treecutter2() {
var trees = jGetObjects(25, jCoord(0, 0), ["trees/fir", "trees/pine", "trees/yew", "trees/birch", "trees/oak",]);
var min_len = 100500;
var target_tree = 0;
for (var i = 0; i < trees.length; i++) {
if (jObjectPos(trees[i]).dist(jMyCoords()) < min_len) {
objid = trees[i];
min_len = jObjectPos(trees[i]).dist(jMyCoords());
}
}
jDoClick(target_tree, 3, 0);
jWaitPopup(1000);
jSelectContextMenu("chop");
jWaitMove(20000);
jSleep(200);
jWaitEndProgress(65000);
jSleep(200);
}
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);
}
}
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() < 60) 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();
} else {
// No water
stopFlag = true;
}
}
}
}
function main2() {
tohearth();
jSleep(500);
equipAxe();
jSleep(500);
drinkWater();
jSleep(500);
treecutter();
jSleep(500);
equipShovel();
jSleep(500);
stumper();
jSleep(500);
takelog();
jSleep(500);
tovillage();
jSleep(500);
droplog();
}
function main() {
//walktotree();
//jSleep(500);
cuttree();
jSleep(500);
drinkWater()
jSleep(500);
stumper();
jSleep(500);
drinkWine();
jSleep(500)
takelog();
jSleep(500);
tovillage();
jSleep(500);
droplog();
jSleep(500);
tohearth();
jSleep(500);
takelog()
jSleep(500);
drinkWine();
jSleep(500);
tovillage();
jSleep(500);
dropblock();
jSleep(500);
droplog();
jSleep(500)
if (jGetHungry() < 55) {return;}
else {
tohearth();
loop();}
}
function loop() {
main();}
main();
-
overtyped
- Posts: 3906
- Joined: Tue Sep 28, 2010 2:09 am
- Location: Quaran book burning festival
Re: Union Client Scripts
THANK YOU SO MUCH FOR THIS, I FUCKING LOOOOOOOOOOVE IT.Arcanist wrote:most functions are stolen.
Works, but not well.
Start it at the HF, out in the woods with wine and water and an axe in hand.
There must be 4 2x1 slots free
Code: Select all
//#! name = log harvester //#! tooltip = harvest log var actionTimeout = 1000 * 60 * 1; var hartling = jMyCoords(); var inventory = checkInventory(); var player = jGetObjects(1,0,"borka"); function checkInventory() { if(!jHaveWindow("Inventory")) { jToggleInventory(); while(!jHaveWindow("Inventory")) jSleep(100); } return jGetWindow("Inventory").getInventories()[0]; } function getNearestTree() { var trees = jGetObjects(25, jCoord(0, 0), ["trees/fir", "trees/pine"]); 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 harvest(){ var log = jFindObjectByName("log", 15).getID(); jSendAction("carry"); jWaitCursor("chi"); jDoClick(log, 1, 0); jWaitMove(); jSendDoubleAction("theTrav", "village"); jWaitProgress(300000); jMoveStep(jCoord(0, -2)); jWaitMove(); jAbsClick(jMyCoords(), 3, 0); jWaitMove(); jPFMove(hartling); waitPFEndMove(); jAbsClick(jMyCoords(), 1, 0); jSendDoubleAction("theTrav", "hearth"); } function tohearth() { jSendDoubleAction("theTrav", "hearth"); jWaitProgress(300000); } function tovillage() { drinkWine(); jSleep(500); jSendDoubleAction("theTrav", "village"); jWaitProgress(300000); } 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, 2)); 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 takelog() { var log = jFindObjectByName("log", 50).getID(); jSendAction("carry"); jWaitCursor("chi"); jDoClick(log, 1, 0); jWaitMove(); return; } function droplog() { jAbsClick(jMyCoords(), 3, 0); jWaitMove(); return; } function stumper(){ while(true){ jSleep(100); jSetSpeed(1); if(jGetStamina() < 40){ checkInventory(); var waterflask = jGetWindow("Inventory").getInventories()[0].getItems("waterflask")[0]; var bucket = jGetWindow("Inventory").getInventories()[0].getItems("bucket-water")[0]; var bucket_coord = bucket.coord(); bucket.take(); jWaitDrag(5000); jSleep(200); waterflask.itemact(0); jSleep(200); jGetWindow("Inventory").getInventories()[0].drop(bucket_coord); jWaitDrop(5000); jSleep(200); waterflask.iact(); jWaitPopup(1000); jSelectContextMenu("Drink"); jSleep(200); jWaitEndProgress(10000); } else { var target_stump = jFindObjectByName("stump", 30); jDoClick(target_stump.getID(), 3, 0); jWaitPopup(1000); jSelectContextMenu("Remove"); jWaitMove(20000); jSleep(200); jWaitEndProgress(65000); jSleep(200); jSleep(200); return; } } } 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 _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 resetCursor() { if (!jIsCursor("arw")) { jAbsClick(jCoord(0, 0), 3, 0); jWaitCursor("arw", actionTimeout); } } function waitPFEndMove() { while (true) { jWaitEndMove(); jSleep(500); if (!jIsMoving()) { return; } } } function treecutter() { var target_tree = jFindObjectByName("fur06", 30); jDoClick(target_tree, 3, 0); jWaitPopup(1000); jSelectContextMenu("chop"); jWaitMove(20000); jSleep(200); jWaitEndProgress(65000); jSleep(200); } function walktotree() { jPFMove (getNearestTree().getID() ); waitPFEndMove(); return;} function cuttree() { jDoClick(getNearestTree().getID(), 3, 0); jWaitPopup(3000); jSelectContextMenu("Chop"); jWaitMove(20000); jSleep(200); jWaitEndProgress(65000); jSleep(200); return;} function treecutter2() { var trees = jGetObjects(25, jCoord(0, 0), ["trees/fir", "trees/pine", "trees/yew", "trees/birch", "trees/oak",]); var min_len = 100500; var target_tree = 0; for (var i = 0; i < trees.length; i++) { if (jObjectPos(trees[i]).dist(jMyCoords()) < min_len) { objid = trees[i]; min_len = jObjectPos(trees[i]).dist(jMyCoords()); } } jDoClick(target_tree, 3, 0); jWaitPopup(1000); jSelectContextMenu("chop"); jWaitMove(20000); jSleep(200); jWaitEndProgress(65000); jSleep(200); } 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); } } 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() < 60) 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(); } else { // No water stopFlag = true; } } } } function main2() { tohearth(); jSleep(500); equipAxe(); jSleep(500); drinkWater(); jSleep(500); treecutter(); jSleep(500); equipShovel(); jSleep(500); stumper(); jSleep(500); takelog(); jSleep(500); tovillage(); jSleep(500); droplog(); } function main() { //walktotree(); //jSleep(500); cuttree(); jSleep(500); drinkWater() jSleep(500); stumper(); jSleep(500); drinkWine(); jSleep(500) takelog(); jSleep(500); tovillage(); jSleep(500); droplog(); jSleep(500); tohearth(); jSleep(500); takelog() jSleep(500); drinkWine(); jSleep(500); tovillage(); jSleep(500); dropblock(); jSleep(500); droplog(); jSleep(500) if (jGetHungry() < 55) {return;} else { tohearth(); loop();} } function loop() { main();} main();
Early world exploit: Put your hearthfire inside a cave, then hold shift to position a claim right in front of a cave. After 8 hours the claim will be unbreakable. Since your hearthfire is inside the cave, you can still get back inside, and leave, but nobody will be able to enter, effectively making you unraidable for the first 3-7 days. Enjoy
-
Arcanist
- Posts: 2664
- Joined: Mon Mar 19, 2012 2:01 pm
Re: Union Client Scripts
Oh, it will only cut pine and fur, if you want it to cut more types then add them into the getNearestTree function
-
seba95
- Posts: 15
- Joined: Sat Feb 11, 2012 2:06 pm
Re: Union Client Scripts
hello everyone I have a problem with the script under the name ,, taker " pops up this error evertime if i use this script.
http://scr.hu/3ui/cfw8w
PS:What do Silder ?
http://scr.hu/3ui/cfw8w
PS:What do Silder ?