To affect things in space, you often want to activate a module of your ship. This guide shows how to make your bot do this.
If you want to select a target first, see the guide on how to select a target.
To activate a module in eve online, we toggle the module when it is inactive. With this approach, the task of activating the module is divided into the following two subtasks:
- Check if the module is active
- If it is not yet active, toggle the module
How to Check If a Module Is Active
All your ships visible modules are represented in Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule
.
To check whether a module is active, pick its representation from there then use it’s property RampActive
to determine activity.
The following sample code demonstrates this:
var shipModule = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule?.FirstOrDefault();
Host.Log("Module is " + ((shipModule?.RampActive ?? false) ? "active" : "inactive"));
How to Make Your Bot Toggle a Module
A module can be toggled by clicking on its representation in the ship UI.
To make a bot do this, we use our module representation from Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule
to click on, using the left mouse button.
This can be done using the following code:
Sanderling.MotionExecute(shipModule.MouseClick(MouseButtonIdEnum.Left));
Solution to Activate a Module
After learning how checking for activity and toggling works, we can combine those two into one code to activate a module.
Since the toggle should only happen when the module is not already active, we use an if-statement to branch on this condition.
Below you see the complete code to activate a module, also containing the if-statement:
var shipModule = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule?.FirstOrDefault();
if(!(shipModule?.RampActive ?? false))
Sanderling.MotionExecute(shipModule.MouseClick(MouseButtonIdEnum.Left));
Related guide: How to Select a Target