Jump to content

Featured Replies

Posted
comment_9

Tutorial: Creating and Testing Mods with the aiostool CLI

The aiostool CLI is a command-line tool that makes it easy to create and test mods for the aiostool integration with aiosbot. This guide will walk you through the full process—from installation to running your first mod.


Prerequisites

Before you begin, make sure you have Node.js installed on your system.

To verify that it's installed, run these commands in your terminal:

node -v
npm -v


Installing the aiostool CLI

The CLI is available as an official package on npm:

npm install -g @aiostool/cli

This will install the aiostool command globally so you can use it anywhere on your system.


Creating a New Mod

To create a new mod, use the create command:

aiostool create my-first-mod

This will generate a folder my-first-mod with the following structure:

my-first-mod/
├── aiostool-mod.d.ts     # Type definitions for mod development
├── main.js               # Your mod's entry script
└── mod.json              # Mod configuration

Inside main.js, you'll find a basic starter template:

/// <reference path="./aiostool-mod.d.ts" />

registerFunction("main", () => {
    console.log("Hello from my-first-mod!");
    return resolve("Hello from my-first-mod!");
});


Running and Testing Your Mod

To test your mod, open the mod directory:

cd my-first-mod

Then run:

aiostool run

This will:

  1. Load the mod.json config

  2. Execute the main function automatically

  3. Launch an interactive mode where you can trigger any other registered functions

Example:

> main
 main returned: Hello from my-first-mod!
> exit

If there's an error in your mod code, the CLI will stop immediately and print the error message.


Tips for Development

  • You can register multiple functions using registerFunction("name", fn), not just main.

  • Use alert("Title", "Message") in your mod for alerts (prints to console in CLI; shows as popup in aiostool).

  • Want to use npm modules like axios? Just install them and require() as usual. Currently you must pack the node_modules into the zip.


More Info

Edited by BlackRider
Uploading node_modules has become obsolete

@BlackRider
Founder · Lead Developer · System Administrator
Development · Infrastructure · Feature Design · Community & Project Management
🔗 My links & socials

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...