Jump to content

[Infodump] Common Script Elements


Recommended Posts

Unfinished post. Will be editing. I do not have time now.


I realized that most of my time so far is testing, debugging, (decompiling 😇), and documenting what each of the API things do. 

I still don't know the full API yet, so much of the methods I'm using are probably already in the API somewhere.

If I do anything wrong, or there is a better way to do it, please tell me. 🤕

I need to know if the API context ever changes so I can stop making all my classes static and functional.

It'll probably help to post some general guides here. Everything's probably going to have antipasta. Not on purpose, I just don't have time right now.

The current list in no particular order is

  1. How to log
  2. Initial setup GUI (looks like it's just swing with extra steps)
  3. Saving to the settings folder (profiles button on the pro scripts)
  4. Performing various in-game actions like harvesting, grinding, mining, idk
  5. Listening to game ticks 600ms and not GameCycles
  6. How I am structuring my project, although I literally just started using this, so I'm still changing how I'm doing this
  7. Selling items, buying items, banking
  8. Inventory management
  9. Script events
  10. Moving around effectively and getting locations
  11. Tasks (after I figure them out)
  12. Scheduling (after I figure them out with the mysterious getScriptProfile)
  13. I really want to know if a live menu is realistically possible so I can change settings on the fly. Don't know when I'll actually get to this or just remove it.
  14. How to actually use the documentation (still struggling with this myself especially since I can't find a search button. Ctrl + F All Classes for now) 
  15. Probably not going to do any project setup stuff. If you know, you know. Otherwise, there would be no antipasta.
  16. world hopping
  17. Discord

Random things I need to figure out

  1. Do interactions have callbacks

A warning. There is a small, but non-zero chance this never gets updated again because I am lazy.

Edit: I'm tired and what I'm adding now seems a bit rough to me, but idk how to make it better for now.




Being able to see what stage your script is at or where it is stuck is crucial. EpicBot has log4j built in and while it is completely possible to either just use System.out.println("xxx") and 

import org.apache.logging.log4j.LogManager;

to create a log, I didn't realize there was a built in function for it so you only had to create a field for your logger.

import org.apache.logging.log4j.Logger;

private Logger logger = getLogger();





EpicBot has a built in way to send status updates to a Discord Webhook. To set it up, first create a Discord Webhook which can be found in the settings of a server you have admin permissions in.


Click in to the Webhook and create a new one. Whatever picture and name it has will be what EpicBot has when it sends messages. Copy the Webhook URL to the EpicBot settings.


Now, the setup is done. All bots will share the same Discord Webhook. Sending a message will need two imports.


import com.epicbot.api.shared.discord.model.DiscordMessage;
import com.epicbot.api.shared.discord.model.DiscordMessage.DiscordMessageBuilder;

Then creating a message will be like so.

public static void sendMessage(APIContext ctx, String text) {
    DiscordMessage message = DiscordMessageBuilder.aDiscordMessage().withContent(text).build();

There is a Discord instance within the context that has a sendMessage. IDiscordAPI (epicbot-api 1.0 API)

I was confused at first how messages were sent. There is a DiscordMessageBuilder object within the DiscordMessage object that then has an aDiscordMessage function that you can call. This will finally create a basic message. To add content, continually call member function withContent and some others which are in the API at DiscordMessage.DiscordMessageBuilder (epicbot-api 1.0 API). When you want to convert the DiscordMessageBuilder object to a DiscordMessage, call the final command chain with build() and it will return a DiscordMessage. Finally, you can send that with the context Discord instance.





Runescape runes on GameTicks. After clicking on something, it may take up to 600ms for it to react. Explained more here https://www.epicbot.com/forum/index.php?/topic/364-writing-a-simple-prayer-script/.

Most of the tutorials I've seen now use the loop() override to continuously run the script, although there are somethings like mining, woodcutting, or harvesting wheat that will require the next game tick to arrive before anything will happen relating to it.

Instead of sleeping while constantly checking for isAnimating, isMoving, isVisible, or anything similar, a function alongside the loop() override can be made called the onGameTick() override. LoopScript (epicbot-api 1.0 API)

The documentation is linked above. I haven't found if there is somewhere that GameTicks are tracked, so I decided to track them myself using a field.

private int tickCounter = 0;


protected void onGameTick(GameTickEvent event) {

The first function is the field. When the script starts, it initializes with a count of 0. onGameTick is called similarly to loop(), but instead of being called every so much time, it is called when the game updates and the GameTick progresses. (Please fact check me on this. My preliminary glance looked like this.)

Although I was using a tickCounter, that was because the rest of my code was already too far gone to move into the onGameTick() override (rather I was too lazy), so I took a bandaid approach and tracked it. In my original code, I began tracking which relative tick things occurred on and only progressed that task if at least one game tick passed since the previous. This was also because I structured my project to be stateless. Every loop would grab information and determine what to do without needing past information. I chose this way because I thought that if the script was started at any random point of progression, it would be able to seamlessly flow into the next step without needing to excessively clog the onStart() override.







Edited by AntiAlchemist
Link to comment
Share on other sites

  • 1 month later...

Very nice! I'm learning Java so this will be a big help. Looking forward to updates, especially in regards to tasks since I'd like to clean up and organize my scripts instead of being one big script. The discord bit is also a nice add as I didn't know how to use it. 🙂

Link to comment
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.

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.

  • Create New...