Scrifen -- Hafen scripting API

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

Re: Scrifen -- Hafen scripting API

Postby hery76 » Sat Jun 11, 2016 2:04 am

oh right, for some reason (stupid one i bet) i totally forgot to put script.js in the directory.

My bad, mistery solved :P

Thanks b0r3d0m o/
hery76
 
Posts: 176
Joined: Mon Feb 06, 2012 1:15 pm

Re: Scrifen -- Hafen scripting API

Postby clefa221 » Sun Jun 12, 2016 12:36 am

How would I go about making a script the foraged some forgables but not others? What commands would I use?

EDIT: For example, lets say that I want to make a script that forages all blueberries, curios, nettles, and chantrelles, how would I go about doing that?
clefa221
 
Posts: 63
Joined: Sat Feb 01, 2014 4:47 pm

Re: Scrifen -- Hafen scripting API

Postby Granger » Sun Jun 12, 2016 9:16 am

You would loop over the stuff you see and test each if it is in the list of stuff you want to foreage, if so get it, if not ignore it.

You most likely need array().contains() - or indexOf(), should you need to cook one yourself - for and if.
⁎ Mon Mar 22, 2010 ✝ Thu Jan 23, 2020
User avatar
Granger
 
Posts: 9254
Joined: Mon Mar 22, 2010 2:00 pm

Re: Scrifen -- Hafen scripting API

Postby UzU123 » Mon Jun 13, 2016 4:17 pm

Hello, I'd like to write by myself bot which would harvest for me peppercorn from trellis but it doesn't work. I think I did something wrong. Could you help me, please?

Code: Select all
var g = null;
var autoWalkingTimerId = null;

function onClientStarted() {
  var options = {
    renderingEnabled: true
  };
  return options;
}

function onLogin() {
  print('Logging in...');

  var credentials = {
    login: 'x',
    password: 'x'
  };
  return credentials;
}

function onCharSelect() {
  print('Selecting character...');

  return 'x';
}

function onGameLoaded(game) {
  print('Game loaded');

  g = game;
  for (i = 0; i < 48; i++){
   lc()
   sleep(500);
   pieprz(i);
   sleep(500);
  }
}

function pieprz(rid){
   var kolba = g.getMapObjects('trellis');
   g.mapObjectRightClick(kolba[rid].id);
   g.chooseFlowerMenuOption(Harvest);
   g.waitForPf();
   g.waitForTaskToFinish();
}

function lc(){
   var skrzynia = g.getMapObjects('largechest');
   g.mapObjectRightClick(skrzynia[0].id);
   g.waitForPf();
   g.transferItems('peppercorn');
   g.waitForTaskToFinish();
   sleep(500);
}

function picie(){
   if (g.getStamina() < 50){
      print('Brak staminy');
      g.drink();
   }
}


Translation:
skrzynia-chest-LC
pieprz-pepper
picie-drinking
UzU123
 
Posts: 15
Joined: Mon Dec 31, 2012 7:00 pm

Re: Scrifen -- Hafen scripting API

Postby Granger » Tue Jun 14, 2016 2:42 am

UzU123 wrote:
g.chooseFlowerMenuOption(Harvest);

This line seems to be defective.
⁎ Mon Mar 22, 2010 ✝ Thu Jan 23, 2020
User avatar
Granger
 
Posts: 9254
Joined: Mon Mar 22, 2010 2:00 pm

Re: Scrifen -- Hafen scripting API

Postby UzU123 » Tue Jun 14, 2016 8:24 am

Granger wrote:
UzU123 wrote:
g.chooseFlowerMenuOption(Harvest);

This line seems to be defective.


I think you mean that I forgot to write like this ('Harvest') with "" but I added it and still it doesn't work. Bot opens LC, puts harvested (by me manually) pepper, tries to go to trellis but after it reaches one of many trellises stops and comes back to LC, opens it and etc.

Also tried to change 'peppercorn' to other names but still nothing.
UzU123
 
Posts: 15
Joined: Mon Dec 31, 2012 7:00 pm

Re: Scrifen -- Hafen scripting API

Postby Granger » Tue Jun 14, 2016 8:59 am

Maybe you should target the plant, not the trellis.
⁎ Mon Mar 22, 2010 ✝ Thu Jan 23, 2020
User avatar
Granger
 
Posts: 9254
Joined: Mon Mar 22, 2010 2:00 pm

Re: Scrifen -- Hafen scripting API

Postby UzU123 » Tue Jun 14, 2016 9:11 am

Granger wrote:Maybe you should target the plant, not the trellis.


Tried it also. I changed "trellis" to "pepper" and still nothing.

Should I use something like this? Or it won't work?
Code: Select all
var stojak = g.getMapObjectsByFullName('gfx/terobjs/plants/pepper');
UzU123
 
Posts: 15
Joined: Mon Dec 31, 2012 7:00 pm

Re: Scrifen -- Hafen scripting API

Postby Glorthan » Tue Jun 14, 2016 11:37 am

UzU123 wrote:
Granger wrote:Maybe you should target the plant, not the trellis.


Tried it also. I changed "trellis" to "pepper" and still nothing.

Should I use something like this? Or it won't work?
Code: Select all
var stojak = g.getMapObjectsByFullName('gfx/terobjs/plants/pepper');

You should use that so it doesn't get confused with pepper on the floor. You should also check if the pepper is harvestable (correct stage). I can't help you test this ingame at the moment, sorry.
Glorthan
 
Posts: 1099
Joined: Tue Jun 11, 2013 4:33 pm

Re: Scrifen -- Hafen scripting API

Postby UzU123 » Tue Jun 14, 2016 2:41 pm

Ok, so now it looks like this:
Code: Select all
var g = null;
var autoWalkingTimerId = null;

function onClientStarted() {
  var options = {
    renderingEnabled: true
  };
  return options;
}

function onLogin() {
  print('Logging in...');

  var credentials = {
    login: 'x',
    password: 'x'
  };
  return credentials;
}

function onCharSelect() {
  print('Selecting character...');

  return 'x';
}

function onGameLoaded(game) {
  print('Game loaded');

  g = game;
  for (i = 0; i < 48; i++){
   lc()
   sleep(500);
   pieprz(i);
   sleep(500);
  }
}

function pieprz(rid){
   var kolba = g.getMapObjectsByFullName('gfx/terobjs/plants/pepper');
   g.mapObjectRightClick(kolba[rid].id);
   g.chooseFlowerMenuOption('Harvest');
   g.waitForPf();
   g.waitForTaskToFinish();
}

function lc(){
   var skrzynia = g.getMapObjects('largechest');
   g.mapObjectRightClick(skrzynia[0].id);
   g.waitForPf();
   g.transferItems('peppercorn');
   g.waitForTaskToFinish();
   sleep(500);
}

function picie(){
   if (g.getStamina() < 50){
      print('Brak staminy');
      g.drink();
   }
}


After logging in it opens LC and closes it and it does it again again and again. Script skips harvesting from trellis. Any ideas?
UzU123
 
Posts: 15
Joined: Mon Dec 31, 2012 7:00 pm

PreviousNext

Return to The Wizards' Tower

Who is online

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