A one-size-fits-all toolbox for detailed logging in TypeScript-based Screeps codes.
# npm
npm install --save screeps-inscribe
# yarn
yarn add screeps-inscribe
To enable accessing Inscribe commands through the CLI, you should add screeps-inscribe
to your global. To do this, add the following to your main.js
, outside of the game loop.
import Inscribe from 'screeps-inscribe'
global.Inscribe = Inscribe()
If you use TypeScript, don't forget to include Inscribe: any
in the Global
interface of your declaration file as well.
declare namespace NodeJS {
interface Global {
// ...
Inscribe: any
// ...
}
}
screeps-inscribe
doesn't have any extra dependencies, and can be easily integrated to your existing logging utility.
import * as Inscribe from 'screeps-inscribe'
console.log(`[${Inscribe.color('main', 'skyblue')}] Scripts bootstrapped`)
This codebase uses husky to auto-compile changes on commit.
To get started, simply clone this repository, and run npm install
. After that, make any changes you want in src/
. When you commit the changes, husky will first automatically run npm run compile
and compile your changes.
Inscribe.color(str: string, fontColor: string): string
Decorates a string of text with color.
str: string
The string to format.fontColor: string
Any HTML color name (teal
) or hex code (#33b5e5
).
Returns: A string output of the color-formatted text.
Inscribe.link(href: string, title: string): string
Appends a link to log output
href: string
Any string-escaped link.title: string
The link title.
Returns: A console output string with link.
Inscribe.tooltip(str: string, tooltipText: string): string
Allows tooltip to be sent to the formatter
str: string
The string to formattooltipText: string
The tooltip text to give away
Returns: The tooltipped text for the Screeps console.
Inscribe.time(color?: string)
Outputs a formatted version of Game.time
color?: string
Any HTML color name (teal
) or hex code (#33b5e5
). Defaults togray
if empty.
Returns: A pretty-formatted Game.time
.