Jump to content

AntiAlchemist

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by AntiAlchemist

  1. 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 How to log Initial setup GUI (looks like it's just swing with extra steps) Saving to the settings folder (profiles button on the pro scripts) Performing various in-game actions like harvesting, grinding, mining, idk Listening to game ticks 600ms and not GameCycles How I am structuring my project, although I literally just started using this, so I'm still changing how I'm doing this Selling items, buying items, banking Inventory management Script events Moving around effectively and getting locations Tasks (after I figure them out) Scheduling (after I figure them out with the mysterious getScriptProfile) 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. 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) Probably not going to do any project setup stuff. If you know, you know. Otherwise, there would be no antipasta. world hopping Discord Random things I need to figure out 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. ------ Logging 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(); ------ Discord 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(); ctx.discord().sendMessage(message); } 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. ------ GameTicks 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; @Override protected void onGameTick(GameTickEvent event) { ++tickCounter; } 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. ------
×
×
  • Create New...