Jump to content
×
×
  • Create New...

Recommended Posts

  • Administrators

Both the desktop and mobile client share the same API, this allows you to develop scripts for both platforms easily. However because the underlying implementations of the client are different for each platform there are some rules to follow to ensure your scripts run as efficiently as possible.

 

1. Develop on desktop, adjust on mobile

Get your scripts working on desktop first then run them on mobile and make any adjustments required. Data collection is a lot easier on desktop and the feedback cycle is going to be a lot quicker as startup time is much less. As the API works across both platforms your scripts should work for the most part on both.

 

2. Use the stream API, don't use #filter

Wait what? Isn't filter a core part of the stream API? Yes it is however the provided filter methods such as #name, #id, #action are optimized for mobile so try to use those wherever possible and only use filter when really required. If you do use #filter make sure it's the last in your chain, for example:

 

 Npc npc = ctx.npcs.toStream()
    .name("Chicken")
    .within(area)
    .action("Attack")
    .filter(n -> !n.inMotion())
    .nearest()
    .first()

 

You can request a filter be added to the API here: https://github.com/powbot/api/issues.

 

If you are only using #filter then use #toStream(false), for example:

 Npc npc = ctx.npcs.toStream(false)
    .filter(n -> !n.inMotion())
    .nearest()
    .first()

 

3. Use variables for any game data as much as possible

Requesting game data such as game objects, npcs, players is much more expensive and slower on mobile. Therefore make use of variables where you can to prevent un-needed requests. For example:

if (ctx.players.local().animation() != -1) {
  return false;
}

if (ctx.players.local().interacting() != null) {
  return false;
}

if (ctx.players.local().inMotion()) {
  return false;
}

 

Instead you should do:

final Player player = ctx.players.local();
if (player.animation() != -1) {
  return false;
}

if (player.interacting() != null) {
  return false;
}

if (player.inMotion()) {
  return false;
}
  • Like 2
  • Thanks 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.