Union Client Scripts

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

Moderator: Phades

Re: Union Client Scripts

Postby Pjotr84 » Tue Oct 22, 2013 3:05 am

I just ran the script and it threw no errors :?
_Gunnar wrote:Sorry, my bots achieved sentience and started writing other bots...


RIP Gemini
User avatar
Pjotr84
 
Posts: 58
Joined: Tue Jan 17, 2012 6:45 am
Location: Frisia

Re: Union Client Scripts

Postby vipic » Tue Oct 22, 2013 3:15 am

Pjotr84 wrote:
Arcanist wrote:
Pjotr84 wrote:Fixed it already: Replace jSelectPopupMenu with jSelectContextMenu and you're good to go. Now I just have to find a way to let the script


I have a programmed bot village in the Ark.su client but the problem with that is your essentialy left to just to throw around the haven java classes in your own code and I have not figured out how to do alot of things that this union client can do (Mostly Draw My Own GUI windows, I love that). I obtained some source for JSBot from somewhere on the internet after downloading the union client, this source included functions such as jSelectPopupMenu and even more importantly jClosePopupMenu. So after much frustration I made some workarounds. I wanted a more permanent solution though so I decompiled the JSbot file too find that it is an older version than the source I have. I cant compile the source I have because all it contains is the function headers (I guess its not really source, an outline maybe?).

So in essence the link to the union client in the Russian forums is outdated at this point. Some people seem to have the updated JSBot, where can I either download updated JSBot files, compile them, and pop them into my haven.jar, or just get an updated haven.jar. I dont want to start working on fixing the functions in an outdated file, just to have to do it all over again when I find an updated JSBot file.

If anyone can find the answer for me ill post my lumber engine for union, I think there might be one here already but mine has a really nice GUI Interface, displays statistics and keeps track of time running, and can be set to do only pieces of the lumber code (ie Take branches and boughs and remove stumps or you could Chop trees than make boards but leave the stumps). It also stores all the wood and branches and crap into storage buildings which can be arranged any way you want as long as it has at least one cupboard that isn't blocked off.

If anyone knows where to find it I would really like to start plowing through it.
Last edited by vipic on Tue Oct 22, 2013 3:19 am, edited 1 time in total.
User avatar
vipic
 
Posts: 10
Joined: Thu Apr 19, 2012 8:22 am

Re: Union Client Scripts

Postby liamw1986 » Tue Oct 22, 2013 3:17 am

im saving them with .jbot extension, all files, and UTF-8. Prehaps my java needs an update but I only got java a few months ago on this so I doubt that is the problem. And my runstarve works just fine. Although I do get an error when I run the client:

start error.gif


This error has never caused any problems for me before though.
You do not have the required permissions to view the files attached to this post.
..Wilson..
User avatar
liamw1986
 
Posts: 60
Joined: Sun Apr 01, 2012 4:33 pm

Re: Union Client Scripts

Postby Pjotr84 » Tue Oct 22, 2013 3:23 am

Well, since the script runs fine on my system, I think it wouldn't hurt if you did a clean install of Java, if anything to rule that out.

@Vipic

Have you tried asking in the Union thread on the Russian boards? You can just post in English and add a machine translation so you don't offend any language rules present there. I know several people posting in that thread speak English quite well.
Last edited by Pjotr84 on Tue Oct 22, 2013 3:38 am, edited 2 times in total.
_Gunnar wrote:Sorry, my bots achieved sentience and started writing other bots...


RIP Gemini
User avatar
Pjotr84
 
Posts: 58
Joined: Tue Jan 17, 2012 6:45 am
Location: Frisia

Re: Union Client Scripts

Postby vipic » Tue Oct 22, 2013 3:25 am

liamw1986 wrote:im saving them with .jbot extension, all files, and UTF-8. Prehaps my java needs an update but I only got java a few months ago on this so I doubt that is the problem. And my runstarve works just fine. Although I do get an error when I run the client:

start error.gif


This error has never caused any problems for me before though.


Dont worry I get that error too, its a permissions thing, if you want it to go away run as administrator.

Edit I might have a Solution To Your First Problem: The text editor you are using is most likely putting some type of header at the top that you dont want. Make sure your opening them in NotePad or even better NotePad++ (Dont use Word) and that its not putting anything funny at the top. This wont be something you can see in the document part of the file but it will be a header that tells about the file. Javascript doesnt know how to interperate this so it is crashing. Anyway seems logical to me.

Edit #2 @ Pjotr84 : No I haven't tried that, if I find anything ill post it here. (Update: Russians Queried, Waiting For Reply) (Found Update See Below)
Last edited by vipic on Tue Oct 22, 2013 7:02 am, edited 1 time in total.
User avatar
vipic
 
Posts: 10
Joined: Thu Apr 19, 2012 8:22 am

Re: Union Client Scripts

Postby liamw1986 » Tue Oct 22, 2013 4:13 am

Thanks guys! I was using wordpad before but I recreated the script in wordpad++ and no more errors!

+1 to both!
..Wilson..
User avatar
liamw1986
 
Posts: 60
Joined: Sun Apr 01, 2012 4:33 pm

Re: Union Client Scripts

Postby vipic » Tue Oct 22, 2013 4:46 am

Whoop Whoop - I found the updated one ,jSelectPopup and jClosePopupWorks are defined in this version and there is some type of area selector function i'm going to start playing with and other cool stuff, ive just started combing through the updates. It was modified by another person called CarryGun so ill decompile and use grep to compare the changes and look for things trying to connect to bad places on the internet.

So if your getting the jSelectPopup is not defined error, this should give you the functions you need. (You could also just change the script to use the older version of the function if your worried about this one sending your account information to the world)

Link Here - https://github.com/APXEOLOG/hnh_union

Edit: Eventualy found it on the second page of the English Union Released Post, the link was originally posted by Borka here.
http://www.havenandhearth.com/forum/viewtopic.php?f=27&t=30491&start=10

!!Wrong!! Edit #2: After further testing the new version appears to be 100% backwards compatible with scripts created for the older version of JSBot

Edit #3: Jumped the Gun there, It is not backwards compatible with some of the GUI functions although the function names have not changed the parameters for a few of them have.

Edit #4: Ok so the only thing which appears to have changed which is not backwards compatible is the:
public String waitButtonClick()
Has been removed for some reason (I think because 0 no longer seems to give you an infinite time in the waitButtonClick() function). So all your waitButtonClicks need to be changed to use the function:
public String waitButtonClick(int timeout)
Not a big differnce, if I find any more ill update this post. (Note: This has not been updated in the source code so it still looks like waitButtonClick() is a valid function but the function is missing from the actual haven.jar and wouldnt work even if it was there as 0 no longer gives you infinity. If you want to update it to use this function here is what you would need to add to the JSGUI_Window file found in your haven.jar)
Code: Select all
   public String waitButtonClick() {
      return waitButtonClick(2,147,483,647); //This is the biggest integer in the world, it will take 25 days for this menu to go away
   }

And here is the command you need to enter on the command line to compile your new version
javac JSGUI_Window.java -cp haven.jar
Than just use winrar to open your haven.jar and replace the JSGUI_Window.class file with your new file.
User avatar
vipic
 
Posts: 10
Joined: Thu Apr 19, 2012 8:22 am

Re: Union Client Scripts

Postby vipic » Wed Oct 23, 2013 1:39 am

In my last post I said that the new version had an area selector function. Unfortunately I realized a couple hours ago the selector function is one of those things in the source but not in the compiled code. I felt obliged to type up a gui area selector function for you guys so here it is. The demonstration prints to the command line so check there to see the sample.
Code: Select all
//#! name = Demonstration for getAreaByUserInputWindow(String Text) Function
//#! tooltip = You will probable want to remove the demonstration section and copy this into your .japi's or make this a .japi if you like the way it works
//////////////////////////////////////////////////////////////////////////
///////////////////////Just For Demonstration/////////////////////////////
function SelectAreaDemonstration(){
   this.displayFrontEnd = new DisplayFrontEnd();
   this.aArea = this.displayFrontEnd.getAreaByUserInputWindow("Demonstration Area");
}
SelectAreaDemonstration.prototype.run = function(){
   jPrint(String(this.aArea));
   var GobArray = this.aArea.getTilesInArea();
   for(var j = 0; j < GobArray.length; j++)
   {
      jPrint(String(GobArray[j]))
   }
   jPrint("Tiles in Array: " + String(GobArray.length));
}
///////////////////////Just For Demonstration/////////////////////////////
/////////////////////////////////////////////////////////////////////////

// Area Class, Parameters: northWestCoord - jCoord   The Northwest Corner of the Area
//                      areaSize - jCoord         The Size of the Area

function Area(northWestCoord, areaSize){
   this.northWestCoord = northWestCoord;
   this.southEastCoord = northWestCoord.add(areaSize.sub(jCoord(11,11)));
   if(areaSize.x < 0 || areaSize.y < 0)
   {
      jPrint("Tried to Create an Area that is Smaller than 0 - In Area Constructor - Area Set to Zero")
      this.areaSize = jCoord(0,0);
   }
   else
   {
      this.areaSize = areaSize;
   }
   
}
Area.prototype.toString = function(){
   return "Area Size: " + String(this.areaSize) + "North West Coord: " + String(this.southEastCoord) + "Bottom Left Coord: " + String(this.northWestCoord);
}
// Area.getTilesInArea - Returns the Tile Types in the Area
Area.prototype.getTilesInArea = function(){
   var tileArray = [];
   var positionInArea = jCoord(0,0);
   var arrayIndex = 0;
   var gettingTiles = true;
   //I'm sorry I didnt want to give out my movement function as I spent alot of time on it, you will probably want to replace the crappy jAbsClick with your movement function
   //lmMoveToCoord(this.northWestCoord)
   jAbsClick(this.northWestCoord , 1, 0)
   jWaitMove(10000)
   while(gettingTiles)
   {
      if(positionInArea.x < (this.areaSize.x) / 11)
      {
         tileArray[arrayIndex] = new Tile(jGetTileType(jCoord(positionInArea.x, positionInArea.y)), this.northWestCoord.add(positionInArea.mul(11)))
         arrayIndex++;
         positionInArea.x++;
      }
      else
      {
         if(positionInArea.y < (this.areaSize.y - 11)/11)
         {
            positionInArea.x = 0;
            positionInArea.y++;
         }
         else
         {
            return tileArray;
         }
      }
   }   
}
// Area.getTilesInArea - Returns the Gobs in the Area
Area.prototype.getGobsInArea = function(){
   return jGetObjectsInRect(this.northWestCoord, this.areaSize.div(11), 0, "");
}
// The DisplayFrontEnd - You may want to delete this and make straight up functions, this class serves a point in some of my other bots but not here
function DisplayFrontEnd(){
   this.menuUIPlacementCoord = jCoord(200,100);
}
DisplayFrontEnd.prototype.getAreaByUserInputWindow = function(textAreaName){
   var areaSize = this.getCoordByByUserInputWindow("Enter the Size of the " + textAreaName);
   jDrawGroundRect(jCoord(0,0), areaSize);
   areaSize = areaSize.mul(11);
   var topCornerCoord = jTilify(this.getCharCoordinantesByUserInput("Move to the " + textAreaName));
   jDrawGroundRect(jCoord(0,0), jCoord(0,0));
   area = new Area(topCornerCoord, areaSize);
   return area;
}
DisplayFrontEnd.prototype.getCoordByByUserInputWindow = function(text){
   var window = jGUIWindow(this.menuUIPlacementCoord, jCoord(200, 85), "Enter XY Coordinate");
   jGUILabel(window, jCoord(15, 0), text);
   var invalidResponceLabel = jGUILabel(window, jCoord(0, 80), "");
   var entryBoxX = jGUIEntry(window, jCoord(35, 25), jCoord(50, 20), "0");
   jGUILabel(window, jCoord(20, 27), "X:");
   var entryBoxY = jGUIEntry(window, jCoord(115, 25), jCoord(50, 20), "0");
   jGUILabel(window, jCoord(100, 27), "Y:");
   jGUIButton(window, jCoord(75, 55), 50, "Ok");
   var gettingInput = true;
   while(gettingInput)
   {
      window.waitButtonClick(240000);
      if(isNaN(parseInt(entryBoxX.getText()), 10) && isNaN(parseInt(entryBoxY.getText()), 10))
      {
         invalidResponceLabel.setText("Invalid Entry for both X and Y - Enter a Number")
      }
      else if(isNaN(parseInt(entryBoxX.getText()), 10))
      {
         invalidResponceLabel.setText("Invalid Entry for X - Enter a Number")
      }   
      else if(isNaN(parseInt(entryBoxY.getText()), 10))
      {
         invalidResponceLabel.setText("Invalid Entry for Y - Enter a Number")
      }
      else
      {
         window.destroy();
         return jCoord(parseInt(entryBoxX.getText()), parseInt(entryBoxY.getText()));
      }
   }

}
DisplayFrontEnd.prototype.getCharCoordinantesByUserInput = function(text) {
    var gettingUserCoords = true;
    while(gettingUserCoords)
    {
        var messageWindow = jGUIWindow(this.menuUIPlacementCoord, jCoord(170, 50), "Move To Location");
        jGUILabel(messageWindow, jCoord(0 , 0), text)
        jGUIButton(messageWindow, jCoord(40 , 25), 100, "Ok")
        messageWindow.waitButtonClick(240000);
        messageWindow.destroy();
        return jMyCoords();
    }
}

// The Tile Class - Im tired of typing this ones self explanatory
function Tile(type, coord){
   this.type = type;
   this.coord = coord;
}
Tile.prototype.toString = function(){
   return "Tile Type: " + this.type + " Tile Coord: " + this.coord;
}


var selectAreaDemonstration = new SelectAreaDemonstration().run();


There are 3 classes here Tile, Area, and DisplayFrontEnd. Tile is just an easy way for me to store the coord and type of tiles. The area class has two functions that allow you to get the Gobs or tiles in the area and it will return them in an array. The displayfrontend class can be removed, in some other display functions is serves a point but I don't think it does in these.

Edit: Fixed a bug where the tiles would not have the correct coordinates, I need to test these before I post them
User avatar
vipic
 
Posts: 10
Joined: Thu Apr 19, 2012 8:22 am

Re: Union Client Scripts

Postby killerdude54 » Sat Oct 26, 2013 10:01 pm

killerdude54 wrote:How come when I run the grape bot on the farmer it doesn't work? I select the LC, Winepress, and Barrel, but when I input the area and run it, it does nothing. It just stands there, although it did go to the harvest tool.

Image

^ It's inventory.


Is no one able to fix this?
killerdude54
 
Posts: 18
Joined: Wed Jul 06, 2011 4:32 am

Re: Union Client Scripts

Postby mvgulik » Thu Oct 31, 2013 4:27 am

...
Last edited by mvgulik on Wed Dec 25, 2013 5:36 pm, edited 2 times in total.
mvgulik
 
Posts: 3774
Joined: Fri May 21, 2010 2:29 am

PreviousNext

Return to The Wizards' Tower

Who is online

Users browsing this forum: Claude [Bot] and 0 guests