-
Notifications
You must be signed in to change notification settings - Fork 141
Launching a Bot With Custom Settings
In some cases, your bot may benefit from a further-customized RuneLite plugin configuration. For instance, if your bot requires numerous objects on screen to be highlighted various colors, it is not ideal to force the user to tag them 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 that will fire-up the game with specific settings.
This tutorial assumes you already have a bot script to work with. This tutorial is relevant for any RuneLite-based game.
I will refer to your bot script file as <bot>
, and the game it's meant for as <game>
.
NOTE: If your RuneLite version is 1.9.11.2 or higher, know that RuneLite uses a new feature for managing plugin configurations called the Profile Manager. At the time of writing this document, OSRS is likely the only game that uses this feature. Please be aware that the instructions below will specify if you need to take any special steps to use the Profile Manager.
- Launch OS Bot COLOR.
- Navigate to your game's Home View via the sidebar in the app.
- Launch RuneLite via the
Launch <game>
button on the UI.
NOTE: If your game uses the Profile Manager, you can access it from the menu bar (see image below). If OSBC launched RuneLite successfully, you should already have a temp
profile selected.
- Manually configure the RuneLite plugins to your liking via the RuneLite interface.
- Sometimes you need to stay logged in for a few minutes for the changes to take effect.
- 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.
-
(Profile Manager only) Once you are happy with your settings, open the
temp
profile in the Profile Manager menu, and selectExport profile
. Save it to a temporary location you can easily access. -
(Legacy RuneLite only) Log out, and close RuneLite. Your custom settings have been saved to
src/runelite_settings/temp.properties
in the OSBC filesystem. You can either leave this file here for now, or move it to an easier-to-access location.
Next, we are going to bundle your bot file along with its custom settings file into a single folder. This will make it neat and tidy. Additionally, it'll be easier to distribute your bot to others if you decide to do so.
- In
src/model/<game>/
create a new folder where your bot file & settings file will live. Give it a name relevant to<bot>
.- E.g., if my bot is called "
OSRSCombat
", I might name it's parent folder "Combat
".
- E.g., if my bot is called "
- Move your bot file into this new folder.
- In
src/model/<game>/__init__.py
, adjust the reference to your bot such that it points to the new location (from .<folder_filename>.<bot_filename> import <bot>
). - Move the plugin config (
.properties
) file from Step 2 into the new folder. Rename it tocustom_settings.properties
. - Edit this file, removing any lines that contain
rsprofile
. These lines may contain your account name, so it is best to remove them if you plan to distribute your bot.
- In
src/model/<game>/<bot>.py
, import thegame_launcher
utility, andpathlib
.
import utilities.game_launcher as launcher
import pathlib
- Make your bot inherit from
launcher.Launchable
by adding it within the parentheses in your class declaration.
# Note: your bot class may inherit from a different base class (i.e., not OSRSBot).
class BotName(OSRSBot, launcher.Launchable):
- Add a
launch_game
method to your bot. I like to put it above themain_loop()
method. It must be namedlaunch_game
exactly.
def launch_game(self):
pass
- In the
launch_game
method, identify the path to your custom settings file and save it to some variable.
def launch_game(self):
settings = pathlib.Path(__file__).parent.joinpath("custom_settings.properties")
The previous line can be read as: "Get the path to the current file (__file__
, i.e., your script), then get the parent directory (i.e., its containing folder), then add custom_settings.properties
to the end of that path."
- Call
launcher.launch_runelite()
. Carefully specify each required argument.
If using Profile Manager
def launch_game(self):
settings = pathlib.Path(__file__).parent.joinpath("custom_settings.properties")
launcher.launch_runelite(
properties_path=settings,
game_title=self.game_title,
use_profile_manager=True,
profile_name="OSBCCombat", # Supply a name if you'd like to save it to PM permanently
callback=self.log_msg,
)
If using Legacy RuneLite
def launch_game(self):
settings = pathlib.Path(__file__).parent.joinpath("custom_settings.properties")
launcher.launch_runelite(
properties_path=settings,
game_title=self.game_title,
use_profile_manager=False,
callback=self.log_msg,
)
-
(Optional) If it is important that the user does not have an instance of RuneLite already running, add this to the top of your
launch_game
method:
def launch_game(self):
# If playing RSPS, change `RuneLite` to the name of your game
if launcher.is_program_running("RuneLite"):
self.log_msg("RuneLite is already running. Please close it and try again.")
return
...
# Other code below...
- Close RuneLite if it's running.
- Launch OSBC.
- Navigate to your game's Home View via the sidebar.
- Select
skip
to unlock the scripts in the sidebar.
- Select
- Select your bot from the sidebar.
- The bot should now have a
Launch
button in its control panel. It is disabled until you've configured your bot's options. - 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. See the OSRSCombat
bot's source code for an example of how to do this.