Union Client Scripts

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

Moderator: Phades

Re: Union Client Scripts

Postby Mernil » Tue Aug 19, 2014 9:16 am

Please Union developer build some retro-compatibility in.
That's so bad to have to rewrite every script at each new version.

For instance, in previous versions, there was a function called jObjectBLOB which would return the blob.
Now, this function doesn't exist anymore so any call to it will crash the scripts.
Instead you've added a method : "blob()" in jGob class.

What'd be nice would be to keep that kind of function, and edit it to something like that :

Code: Select all
function jObjectBLOB(object, index){
   log_warning("jObjectBLOB is deprecated, use object.blob(index) instead.");
     return object.blob(index);
}
function log_warning(txt){
   sayArea("[!] Warning, "+txt); //log that the function is deprecated when it's called.
}


This way, all scripts will continue working whatever the current version of union is, and conscientious devs will be able to update their script easily.
User avatar
Mernil
 
Posts: 133
Joined: Tue Jul 29, 2014 9:54 pm

Re: Union Client Scripts

Postby Arcanist » Tue Aug 19, 2014 9:22 am

I agree.
My scripts work for 7.2c
7.2d has some funky bot engine, I recommend not to use it.
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Mernil » Tue Aug 19, 2014 10:36 am

So, I'm trying to craft a bot that would basically play HnH as a wanderer (basically : no big building) without human interaction :D

First thing first I need to get out of the creation room.

So I change beliefs 1 time to 'peaceful'.
I change the character gender randomly.

Now I'm speaking with Germania to get a name, though I have trouble clicking the "gen" button. And I don't know how I'll press "enter" to validate the name neither...

Any help on how to interact with these particular windows would be welcome, and a sample of code would be awesome.

My code yet :

Code: Select all
//#! tooltip = Survivor
//#! name = Survivor
//#! uniq = 0000000-000000-000000-000000-SURVIV

include("jBotAPI");

function Survivor(){
   
   //Initialisation
   //Character just created, have to get its stuff, his name, and get out of creation room.
   this.init = function(){
   
      jBuyBelief("martial", 1); //Slide one time to peaceful
   
      gender_npc = jFindObjectByName('npcs/surg',5000);
      name_npc = jFindObjectByName('npcs/germania',5000);
      port_npc = jFindObjectByName('npcs/sherlock',5000);
      
      //************** Get a gender ***************//
      if(!gender_npc){
         return; //Character not in the creation room anymore
      }
      merl_tools.PFto(gender_npc);
      random_gender = Math.floor((Math.random() * 2)+1); //number of clicks on NPC.
      for(var i = 0; i < random_gender; i++){
         gender_npc.doClick(3,0);
         jSleep(500);
      }      
      //************** Get a name ***************//
      merl_tools.PFto(name_npc);
      name_npc.doClick(3,0);
      while(!jHaveWindow("Change Name")) jSleep(100);
      
      
   
   }
}


var merl_tools = new function(){
   this.dump = function(object){ //dump text to screen
      name = '';
      try{
         name = object.name();
      }catch(e){}
      id = '';
      try{
         id = object.getID();
      }catch(e){}
      
      sayArea(object + ' - ' + name + ' - ' + id);
      jSleep(2000);
   },
   
   this.PFto = function(item){ //move to item position using path-finding
      jAbsClick(item.position(), 1, 0);
      jSleep(500);
      jWaitEndMove(50000);

      jPFClick(item.getID());
      
      old_distance = 9999999999;
      distance = 0;
      while(distance + 1 < old_distance){      
         old_distance = jMyCoords().dist(item.position());
         item.doClick(1,0);
         jPFClick(item.getID());
         jSleep(2500);
         distance = jMyCoords().dist(item.position());
      }
      
      jClosePopup();
      
      if(distance > 20){
         sayArea("I can't reach this place :(");
         return false;
      }else{
         return true;
      }
   },
   
   this.getClosestObjectByName = function(object_name){
      var objects = jGetObjects(5000, jCoord(0,0), object_name);
      min_distance = 9999999999;
      current_object = false;
      for(var i = 0; i < objects.length; i++){
         distance = objects[i].position().dist(jMyCoords());
         if(distance < min_distance){
            min_distance = distance;
            current_object = objects[i];
         }
      }
      return current_object;
   }
}



survivor = new Survivor();
survivor.init();
User avatar
Mernil
 
Posts: 133
Joined: Tue Jul 29, 2014 9:54 pm

Re: Union Client Scripts

Postby Arcanist » Wed Aug 20, 2014 3:48 am

Try

jGetWindow("Change Name").pushButton("Gen");

This script was also written by usernm

Will press enter (the script can not do it)


Looks like he didn't get it to press enter either.

http://www.havenandhearth.ru/viewtopic.php?f=17&t=1524
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Zarxes » Sun Aug 24, 2014 9:47 pm

Hi, first thanks for releasing your bots, but i got a problem with the Crafter bot (using union 7.2c ) . After selecting the Cupboards (crafting boar baloney) and then clicking onto the ground the script stops and i get the following error.

Image

Do you maybe have any idea how i might be able to fix this?

skype: zarxes007
Zarxes
 
Posts: 143
Joined: Mon Feb 21, 2011 6:06 pm

Re: Union Client Scripts

Postby Arcanist » Sun Aug 24, 2014 10:56 pm

It looks like you didn't save the API that I posted correctly.
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Zarxes » Sun Aug 24, 2014 11:51 pm

Well i did but ill double check again. Shouldnt opencupboard be defined or mentioned in some kind of way in that api? Because in the one you posted, it isnt.
Zarxes
 
Posts: 143
Joined: Mon Feb 21, 2011 6:06 pm

Re: Union Client Scripts

Postby Arcanist » Sun Aug 24, 2014 11:54 pm

Oh, I must have not selected it when I uploaded the script. sorry about that, I'll fix it when I get home tonight
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Zarxes » Sun Aug 24, 2014 11:59 pm

Also the jbotapitalon does not exist in my script folder - im really no expert on this,but from what i deduced this is like a library of commands right? So if the bot includes that api i need it right?

Edit: Also, thanks for answering/helping
Zarxes
 
Posts: 143
Joined: Mon Feb 21, 2011 6:06 pm

Re: Union Client Scripts

Postby Arcanist » Mon Aug 25, 2014 1:15 am

I was going to use some functions from Talon's API, but I didn't get around to it, so don't worry about that file.
As I said, I'll find that function and add it to the api when I get home (I'm at polytech at the moment).
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

PreviousNext

Return to The Wizards' Tower

Who is online

Users browsing this forum: Claude [Bot] and 1 guest