View unanswered posts | View active topics It is currently Fri Apr 19, 2024 3:54 pm



Reply to topic  [ 1 post ] 
 Weapon M plugins and mouse overlays 
Author Message
Chief Warrant Officer

Joined: Sat Nov 17, 2001 3:00 am
Posts: 175
Unread post 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.


Mon Jan 28, 2013 3:44 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware.