Page 8 of 13

Re: Plug-in system for Latikai's client

PostPosted: Mon Apr 24, 2017 11:12 pm
by Kandarim
yep - my bad. F collided with one of my own debug options :)
FYI you can also find the corresponding hotkey by looking (closely, though) at the tooltip. The hotkey will be yellow while the rest of the text is white.

Re: Plug-in system for Latikai's client

PostPosted: Mon Apr 24, 2017 11:15 pm
by Taipion
Kandarim wrote:yep - my bad. F collided with one of my own debug options :)
FYI you can also find the corresponding hotkey by looking (closely, though) at the tooltip. The hotkey will be yellow while the rest of the text is white.

That's how I found out, then I looked through the code (as I did not know where it's defined) until I stumbled over that 73. :D

And it seems to bug out after excessive use, just saying.

[edit]: observed bugged behaviour is, it first starts to do less than 10 per run, and less, until it does not do anything anymore.
Threads... :lol:

Re: Plug-in system for Latikai's client

PostPosted: Mon Apr 24, 2017 11:38 pm
by Heffernan
Taipion wrote:
Kandarim wrote:yep - my bad. F collided with one of my own debug options :)
FYI you can also find the corresponding hotkey by looking (closely, though) at the tooltip. The hotkey will be yellow while the rest of the text is white.

That's how I found out, then I looked through the code (as I did not know where it's defined) until I stumbled over that 73. :D

And it seems to bug out after excessive use, just saying.

[edit]: observed bugged behaviour is, it first starts to do less than 10 per run, and less, until it does not do anything anymore.
Threads... :lol:


hopefully it can be made stable and accept more then 10 :P

Re: Plug-in system for Latikai's client

PostPosted: Tue Apr 25, 2017 12:02 am
by Taipion
One simple thing is, I would make it one way or the other so that it simply adds additional calls instead of ignoring them until it is finished.
As one way, you could have a static variable to that is added for every call, and that determines the the "remaining times to repeat", instead of simply running one thread per call.
Also, thread safety! :D

Re: Plug-in system for Latikai's client

PostPosted: Fri May 05, 2017 5:53 pm
by Taipion
For the very convenient Store Seller Plugin, I have made some changes and optimizations.
I know there are various, fast ways of selling to a stall without even using a plugin, but I prefer this sophisticated way,
if you also do, then you might enjoy this one. :-)

Problem was:
- Stall Seller would not work if your inventory contained anything not-sell-able
- Selling items that one would usually not want to sell to the npc, including but not limited to: indian cotton, egyptian cotton, sea island cotton, leather, indian feathers
- hotkey "w" kind of collided with WASD

Solution:
- Check items before selling
- Check only for sell-worthy items
- changed hotkey to "g"

Additional features:
- You can switch the plugin between "sell only selected items" and the previously default behaviour of "trying to sell all", by holding an item in hand and then pushing the hotkey ("g")
- If you activate the plugin while holding an item in hand, it will, in addition to toggling sell modes, output the name and resource name of the item, like: gfx/invobjs/hide-beaver-prep or gfx/invobjs/cottoncloth0, which in turn can be used to, for instance, use icons on this forum with the "Item" tag [item] and [/item] like hide-beaver-prep cottoncloth0 goldbar savagecharm
- changed interval of "clicks" from 150ms to 100ms


If you have any addition or idea for this or other plugins, feel free to use this thread or pm me. :-)


For the bold and reckless, I have uploaded a compiled jar here, the download will be valid until around 19th may 2017.

Ofc I hope Kandarim will either take over these changes in some way, or preferably: add it as a separate plugin/version.



Source of changed files is:
(rest is identical with the source of the stall seller from kandarims github repo)

StallSellerPlugin.java
Code: Select all
package haven.plugins;

import haven.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class StallSellerPlugin extends Plugin {

   public static boolean sellAll = false;

   public void load(UI ui) {
      Glob glob = ui.sess.glob;
      Collection<Glob.Pagina> p = glob.paginae;
      p.add(glob.paginafor(Resource.load("paginae/add/stallseller")));
      XTendedPaginae.registerPlugin("stallseller", this);
   }

   public void execute(final UI ui) {

      new Thread(new Runnable() {
         @Override
         public void run() {

            String text = "\n[StallSeller] To switch between sell-modes, activate the plugin (hotkey = \"g\") while holding any item in the hand";
            
            if (!ui.gui.hand.isEmpty()) {

               Iterator<GItem> handContent = ui.gui.hand.iterator();
               while (handContent.hasNext()) {
                  GItem item = handContent.next();
                  ui.message("The item in your hand is: " + item.name() + "\nResource name: " + item.resname(),
                        GameUI.MsgType.INFO);
               }
               
               
               if (sellAll) {
                  ui.message("[StallSeller] Sell mode is now: Sell selected only \n(yellow cotton, mixed cotton, savage charms, arrowheads, gold bars, bear skins, beaver skins and cricket teams)" + text, GameUI.MsgType.INFO);
                  sellAll = false;
               } else {
                  ui.message("[StallSeller] Sell mode is now: Sell everything" + text, GameUI.MsgType.INFO);
                  sellAll = true;
               }

            } else {
               
               if (sellAll) {
                  ui.message("[StallSeller] Selling items to stall. Sell mode is: \"Sell everything\". Please wait until further notice." + text, GameUI.MsgType.INFO);
               }else{
                  ui.message("[StallSeller] Selling items to stall. Sell mode is: \"Sell selected only\". Please wait until further notice." + text, GameUI.MsgType.INFO);
               }
               

               List<WItem> items = ui.gui.maininv.getSameName("", true);

               for (int i = items.size() - 1; i < items.size() && i >= 0; i--) {

                  Resource curs = ui.root.cursor;
                  if (!curs.name.contains("kreuz")) {
                     ui.message("[StallSeller] You are not selling to a stall! Aborting.", GameUI.MsgType.BAD);
                     return;
                  }

                  WItem subject = items.get(i);
                  if (!sellAll) {
                     if ((subject.item.resname().contains("cottoncloth")
                           || subject.item.resname().contains("savagecharm")
                           || subject.item.resname().contains("arrowhead")
                           || subject.item.resname().contains("goldbar")
                           || subject.item.resname().contains("hide-bear-prep")
//                           || subject.item.resname().contains("cricketteam")
                           || subject.item.resname().contains("hide-beaver-prep"))
                           && !subject.item.resname().contains("cottoncloth1")
                           && !subject.item.resname().contains("cottoncloth2")
                           && !subject.item.resname().contains("cottoncloth3")) {
                        
                        subject.mousedown(Coord.z, 1);
                        try {
                           Thread.sleep(100);
                        } catch (InterruptedException ex) {
                        }
                     }

                  } else {
                     subject.mousedown(Coord.z, 1);
                     try {
                        Thread.sleep(150);
                     } catch (InterruptedException ex) {
                     }
                  }

                  items = ui.gui.maininv.getSameName("", true);
               }
               ui.message("[StallSeller] Stopped selling items.", GameUI.MsgType.INFO);
            }
         }
      }, "Stall seller").start();

   }
}


action_0.data
Code: Select all
#ABUTTON LAYER FOR RES src//\paginae\add\stallseller.res
#String pr
paginae/act/add
#uint16 pver
2
#String name
g-Hotkey: Sell all of the items in your inventory to the white stall you have open currently. Will lag!
#String preq

#uint16 hk
103
#uint16 ad length
2
#String ad[0]
@
#String ad[1]
stallseller


Please note, that when compiling this yourself, you need to run the "compile_resources.bat" or the changes to action_0.data will be ignored.
Further info on this in spoiler:
Run this batch file only in a command prompt and don't just doubleclick it, so you will see if it actually did something or failed, if it failed, you may need to set (for instance) the java variables correctly.
To do this non-permanently just for the currently active command prompt from which you execute it, use these commands and adjust them to your file system / location of your JRE, 1.7 is required iirc.
set JAVA_HOME=C:\Java\jre1.7.0_80
set PATH=%JAVA_HOME%\bin;

Re: Plug-in system for Latikai's client

PostPosted: Fri May 05, 2017 6:24 pm
by Kandarim
I hope to get around to it tonight.
Also, sneak peek: I hope to soon post a plugin to automatically swap roses/berries in distillers. Work in progress and still buggy (as in: sometimes it skips over distillers without swapping the items in them), but functional.

Re: Plug-in system for Latikai's client

PostPosted: Fri May 05, 2017 7:38 pm
by Taipion
Kandarim wrote:I hope to get around to it tonight.
Also, sneak peek: I hope to soon post a plugin to automatically swap roses/berries in distillers. Work in progress and still buggy (as in: sometimes it skips over distillers without swapping the items in them), but functional.


Thank you! :-)


As for the destiller plugin, I had high hopes that the devs would unify the inventory of equipped destillers in an alchemy table, that would have made sense and probably been easy as it might be similar to pockets slotted in cloths.
But a plugin would be nice, too, sounds about as good as the lua script I wrote on my G510 for that purpose, like, 80-90% success, hit and miss. :D
If you can't get it to work, can I have a look at the code, please? I'd hope to learn something from that about the clients gui windows, and maybe I can help in making it work reliably.

Re: Plug-in system for Latikai's client

PostPosted: Fri May 05, 2017 9:25 pm
by Kandarim
yes, that was exactly the reason I put it off for so long: hoping they would get round to a bunch of QoL fixes. Now that seems to be a way off, i figured what the hell.

Re: Plug-in system for Latikai's client

PostPosted: Sat May 06, 2017 7:23 pm
by Kandarim
there we go, new version of the stall seller is up. Note that you'll have to manually download the new version

Re: Plug-in system for Latikai's client

PostPosted: Sat May 06, 2017 7:31 pm
by Taipion
Kandarim wrote:there we go, new version of the stall seller is up. Note that you'll have to manually download the new version


Thank you very much! :-)