Repository navigation
Getting started
To get started with HmOog, you will need two things:
- A fairly recent Node.js version
- A copy of Hackmud that is running
You can install HmOog with your favorite package manager from the NPM registry:
pnpm install @sarahisweird/hmoogThe central class you will work with is aptly called HmOog. It allows you to perform in-game actions, mostly via promises.
Before you can use it, you have to run init though. If you forget, it will complain!
import { HmOog } from '@sarahisweird/hmoog';
const oog = new HmOog();
await oog.init();Now you're ready to run your first command using run. It is your main gateway into the MUD and allows you to run any script.
So think twice before running commands! Even in OOG, scripts.get_level is your friend.
Warning
Do not use run to enter hardline! It won't work because of the hardline sequence. Exiting hardline through run can lead to issues as well due to the exit animation.
Check below for info on how to enter and exit hardline!
const result = await oog.run('scripts.user');result is an object that contains information about the result. If the script returned SUCCESS or FAILURE, result.success will be set.
If the script didn't return a success message though, result.success will be undefined, like in the call to scripts.user above.
The object also contains the output of the script in several forms alongside the command that you ran. There are three objects inside result:
-
result.coloredcontains the raw output from theshell.txt. -
result.uncoloredcontains the same output, but with all tags removed, so just the plain text is left. -
result.ansicontains the output formatted with ANSI escape sequences, which will give you pwetty colors in your terminal.
Each of these contains three things:
-
commandis the command that was ran, but with(out) the corresponding coloring from in-game. -
rawis the output from the command as a big string. -
linesis the output from the command split into lines. (Literally justraw.split('\n'))
That's quite a lot. It's pretty likely you will just work with result.uncolored though, except for printing:
if (result.uncolored.raw.includes('Error:')) {
console.error('An error occurred:');
console.error(result.ansi.raw);
}You probably also want to enter and exit hardline though. You can do this easily through enterHardline and exitHardline.
- If successful,
enterHardlinereturns0. - If no hardline is available, it returns the number of milliseconds you have to wait until the next one is ready.
- If you already are in hardline, it returns
-1. You can also just callisInHardlineto get that info.
import { waitMs } from '@sarahisweird/hmoog';
const cooldown = await oog.enterHardline();
if (cooldown > 0) {
await waitMs(cooldown);
if (await oog.enterHardline() !== 0) throw new Error();
}
// <insert cool hacking sequence here>
await oog.exitHardline(); // or oog.enterRecon(), if you prefer the store_list name
console.assert(oog.isInHardline() == false);