TracNav menu
-
Documentation
- Running TWCore on Windows
- Running TWCore on Linux?
- Troubleshooting / problems with TWCore
-
Programming on/with TWCore
- Programming guidelines
- Tutorial 1: Making a basic bot
- Tutorial 2: Handling Events
- Tutorial 3: Commands
- Tutorial 4: Configuration Files and Spawning
- Tutorial 5: TWBotExtension Basics
- Tutorial 6: Single-Use TimerTasks
- Tutorial 7: Repeating TimerTasks
- Tips & Tricks
- Contributing to TWCore: Committing/submitting your changes
- How to debug TWCore using Eclipse
- Home
-
About TWCore...
- Download
-
Links...
Tutorial 1: Making a basic bot
Written by D1st0rt @ Friday, 19 November 2004
Last update: Monday, 31 January 2005
In this step, you'll see how to make simple bot that just logs in. Create a folder in your bots folder called mybot. Then create this file mybot.java:
//Make the package name the same as the bot's name so you can //spawn it package twcore.bots.mybot; //Import all of the TWCore classes so you can use them import twcore.core.*; public class mybot extends SubspaceBot { //Creates a new mybot public mybot(BotAction botAction) { //This instantiates your BotAction super(botAction); } //What to do when the bot logs on public void handleEvent(LoggedOn event) { //Get the data from mybot.cfg BotSettings config = m_botAction.getBotSettings(); //Get the initial arena from config and enter it String initial = config.getString("InitialArena"); m_botAction.joinArena(initial); //NOTE: m_botAction is inherited from SubspaceBot } }
This is the the most basic bot you can make. You should familiarize yourself with m_botAction because you're going to be using it a lot. It is what enables you to interact with the game and do many useful things. Notice how in the LoggedOn event handler, you must join an arena. If you don't do this, your bot won't show up.
