www.ClassicTW.com
https://mail.black-squirrel.com/

Weapon M plugins and mouse overlays
https://mail.black-squirrel.com/viewtopic.php?f=15&t=33716
Page 1 of 1

Author:  mrdon [ Mon Jan 28, 2013 3:44 am ]
Post subject:  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 tutorial

The 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.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/