Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Launching a Bot With Custom Settings

Kell edited this page Jan 18, 2023 · 10 revisions

Prerequisites

This tutorial assumes you already have a bot class to work from. This tutorial is relevant for any bot for any RuneLite-based game. I will refer to your bot class as <bot>, and the game it's for as <game>.

Launching a Bot With Custom Settings

In some cases, your bot may benefit from a further-customized RuneLite plugin configuration. For instance, if you bot requires numerous objects on screen to be highlighted various colors, it is not ideal to force the user to do that manually each time they use the bot. This tutorial will show you how to add a launch game button to your bot's control panel.

Step 1: Create a Settings File

  1. Launch OSBC.
  2. Navigate to your game's Home View via the sidebar.
  3. Launch RuneLite via the Launch <game> button.
  4. Manually configure the RuneLite plugins to your liking via the RuneLite interface.
    1. Sometimes you need to stay logged in for a few minutes for the changes to take effect.
    2. It is wise to not change object/tile/npc tagging plugin properties, such as their width and feathering. This may negatively affect OSBC's ability to locate outlined objects. You can safely adjust their colors though if you intend to pre-tag objects with specific colors.
  5. Log out, and close RuneLite. Your custom settings have been saved to src/runelite_settings/temp.properties.

Step 2: Organize Your Bot Files

  1. In src/model/<game>/ create a new folder where your bot file & settings file will live.
    1. Give it a name relevant to <bot>.
  2. Move your bot file into this new folder.
  3. In src/model/<game>/__init__.py, adjust the reference to your bot such that it points to the new location (from .<folder>.<bot_filename> import <bot>).
  4. Copy src/runelite_settings/temp.properties into the new folder. Call it custom_settings.properties.
  5. Edit this file, removing any lines that contain rsprofile. These lines may expose your account name, so it is best to remove them.

Step 3: Add a Launch Button to Your Bot's Control Panel

  1. In src/model/<game>/<bot>.py, import the game_launcher utility, and pathlib.
import utilities.game_launcher as launcher
import pathlib
  1. Make your bot inherit from launcher.Launchable.
# your bot will likely inherit a game-specific baseclass instead of RuneLiteBot
class BotName(RuneLiteBot, launcher.Launchable):
  1. Add a launch_game method to your bot. I like to put it above the main_loop() method.
def launch_game(self):
    pass
  1. In the launch_game method, identify the path to your custom settings file, and pass it to the launch_runelite_with_settings method.
def launch_game(self):
    settings = pathlib.Path(__file__).parent.joinpath("custom_settings.properties")
    launcher.launch_runelite_with_settings(self, settings)
  1. (Optional) If it is important that the user does not have an instance of RuneLite already running, add this:
def launch_game(self):
    if launcher.is_program_running("RuneLite"):
        self.log_msg("RuneLite is already running. Please close it and try again.")
        return
    settings = pathlib.Path(__file__).parent.joinpath("custom_settings.properties")
    launcher.launch_runelite_with_settings(self, settings)

Step 4: Test Your Bot

  1. Close RuneLite if it's running.
  2. Launch OSBC.
  3. Navigate to your game's Home View via the sidebar.
    1. Select skip to unlock the scripts in the sidebar.
  4. Select your bot from the sidebar.
  5. The bot should now have a Launch button in its control panel. It is disabled until you've configured your bot's options.
  6. Launch RuneLite via the Launch button.

Since the Launch button waits for your bot to be configured, you have an opportunity to further modify your custom settings file before launching RuneLite. For instance, the OSRSCombat bot's option menu allows users to identify what items should be looted, and then the settings file is modified automatically to highlight those items.