Weapon M plugins and mouse overlays
I've added the aforementioned
mouse overlays to my version of Weapon M, and to make it easier to customize and share, I've added a simple plugin concept you can read about in the new
plugin tutorialThe overlays are also extensible from a plugin. Here is an "overlay detector" that finds the sector from a sector display:
Code:
/**
* Detects sectors in a density scan
*/
function detect(buffer, cursorX, cursorY) {
let line = buffer.getLine(cursorY)
if (line.indexOf("Sector ") == 0) {
let match = /(\d+)/.exec(line);
let start = match.index;
let end = start + match[1].length;
if (start <= cursorX && cursorX <= end) {
return {
type : "sector",
start : start,
end : end,
value : match[1]
};
}
}
}
And here is an "overlay-action", which adds a menu option when you right-click on the above defined overlay:
Code:
/**
* Move to the adjacent sector
* @label Safe Move
* @weight 10
*/
function appliesTo(type, sector) {
return (type == "sector") &&
db.you.sector.number != sector;
}
function execute(sector) {
loadScript("starter", "Move.js", {
target: parseInt(sector)
})
}
Notice the action, if it applies, will call the "Move.js" script and pass in the target parameter, which would normally require a UI prompt.
So far, I've added some simple detection of sectors and ports, with actions that will scan, safe move, and pair trade among other things.