An AbstractScript in the context of Dreambot3 (a popular botting client for RuneScape) is a Java class template used to create custom automation scripts. It defines the core structure and lifecycle methods required for script execution. Below is a simplified example of what an AbstractScript implementation looks like:
Basic Structure:
import org.dreambot.api.script.AbstractScript;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
@ScriptManifest(
name = "My Woodcutting Bot", // Script name
author = "YourName", // Author
version = 1.0, // Version
category = Category.WOODCUTTING // Script category
)
public class MyScript extends AbstractScript {
@Override
public int onLoop() {
// Core logic runs repeatedly (like a game loop)
chopTree();
return 600; // Delay (ms) before next loop iteration
}
private void chopTree() {
// Example: Find and interact with a tree
if (getInventory().isFull()) {
bankItems();
} else {
getGameObjects().closest("Tree").interact("Chop");
}
}
private void bankItems() {
// Banking logic here
}
}
Key Components:
-
@ScriptManifest Annotation:
- Declares metadata (name, author, version, category).
- Categories include
WOODCUTTING, MINING, COMBAT, etc.
-
onLoop() Method:
- The core loop called repeatedly by Dreambot.
- Contains your script's main logic (e.g., skilling, combat).
- Returns an
int representing the sleep/delay (in ms) before the next loop.
-
Dreambot API Methods:
- Access game objects:
getGameObjects().closest("Tree")
- Check inventory:
getInventory().isFull()
- Interact with entities:
.interact("Chop")
- Walk:
getWalking().walk(bankTile)
Lifecycle Methods (Optional Overrides):
@Override
public void onStart() {
// Runs ONCE when the script starts
log("Script started!");
}
@Override
public void onExit() {
// Runs ONCE when the script stops
log("Script stopped!");
}
Example Use Case:
A simple woodcutting bot might:
- Chop trees until the inventory is full.
- Walk to a bank.
- Deposit logs.
- Repeat.
Important Notes:
- Dreambot Dependency: Scripts require the Dreambot library (
dreambot-api).
- Security: Botting violates RuneScape's terms of service. Use only on private servers or at your own risk.
- Debugging: Use
log("Message") to print to Dreambot's console.
For advanced scripts, you’d add:
- State machines
- Antiban routines
- Dynamic pathfinding
- GUI configuration (using
ScriptSettings)
For the official framework, refer to the Dreambot API Docs.