Giter Club home page Giter Club logo

screeps-multimeter's Issues

Private server support

With the latest release and the update of the api, the private server support has been undone as well.
Is there any roadmap on reintroducing this feature?

Cannot watch TypeError

After following the set-up process and adding watch-client.js to the code base, I'm unable to use /watch. I call watcher() at the end of my game loop.

Below you can find the console output from executing /watch status _.keys(Game.creeps).length with some additional information:

*** Connecting to (https://screeps.com:443/) ...
*** Now showing Screeps console. Type /help for help.
*** Cannot watch: TypeError: Cannot read property 'expressions' of undefined
        at multimeter.api.memory.get.then.val (C:\Users\XATEV\AppData\Roaming\npm\node_modules\screeps-multimeter\plugins\watch.js:40:72)
        at processTicksAndRejections (internal/process/next_tick.js:81:5)
<<< JSON.stringify(Memory.watch)
>>> {"expressions":{},"values":{}}
<<< typeof Memory.watch
>>> object
<<< typeof Memory.watch.expressions
>>> object
*** This is Multimeter 1.8.3, which is the latest version.
<<< watcher = require("./watch-client")
>>> function() {
      if (typeof Memory.watch !== "object") {
        Memory.watch = {};
      }
      if (typeof Memory.watch.expressions !== "object") {
        Memory.watch.expressions = {};
      }
      if (typeof Memory.watch.values !== "object") {
        Memory.watch.values = {};
      }
      _.each(Memory.watch.expressions, (expr, name) => {
        if (typeof expr !== "string") return;
        let result;
        try {
          result = eval(expr);
        } catch (ex) {
          result = "Error: " + ex.message;
        }
        if (name == "console") {
          if (typeof result !== "undefined") console.log(result);      
        } else {
          Memory.watch.values[name] =
            typeof result !== "undefined" ? result.toString() : result;
        }
      });
    }

Multiline input

Is there a way to use multyline input? Cannot paste long chunks of code like I do with original console.

Cannot login to private server, throws Error: Not Authorized

When I start the private server via the Steam UI, call setPassword("BBCorn", "1234") and then try to start multimeter using multimeter -s private, I get Error: Not Authorized.

My .screeps.yaml:

servers:
  main:
    host: screeps.com
    secure: true
    token: '00000000-0a0a-0a00-000a-a0000a0000a0'
  ptr:
    host: screeps.com
    secure: true
    path: '/ptr'
    token: '00000000-0a0a-0a00-000a-a0000a0000a0'
  season:
    host: screeps.com
    secure: true
    path: '/season'
    token: '00000000-0a0a-0a00-000a-a0000a0000a0'
  private:
    host: 127.0.0.1
    port: 21025
    secure: false
    username: BBCorn
    password: 1234
  configs:
  multimeter:
    plugins: []
    aliases: {}
    logFilename: 'multimeter.log'

It does work if I make the same request with a REST Client:
image

Am I doing something wrong?

Cannot npm install, native deps failing to build

On a fresh checkout of this repo if I do npm install, it fails when building the native bit of the bufferutil dependency:

sample:

../../nan/nan_object_wrap.h: In static member function ‘static void Nan::ObjectWrap::WeakCallback(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’:
../../nan/nan_object_wrap.h:124:26: error: ‘class Nan::Persistent<v8::Object>’ has no member named ‘IsNearDeath’
  124 |     assert(wrap->handle_.IsNearDeath());
      |  

full log here: https://gist.github.com/Ramblurr/57b57b6bcb40ae21944ff4c94e34d128

This is on node version v12.16.1.

Is a particular version of node needed?

HTML plugin can not handle function return string

I often use strings as function return values to avoid output annoying undefined in the console. But I noticed that HTML plugin can only handle strings output by console.log.

As an example, here is a global function that prints info:

global.showLog = () => {
    console.log('<span style="color: green;">Hello, World!</span>')
    return '<span style="color: green;">Hello, World!</span>'
}

The console output is:

Is this a bug or intentionally?

Cannot start

{ Error: Cannot find module 'screeps-multimeter/plugins/alias' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at requireRelative (/home/user/.npm/lib/node_modules/screeps-multimeter/node_modules/require-relative/index.js:25:15) at _.each (/home/user/.npm/lib/node_modules/screeps-multimeter/src/multimeter.js:205:20) at arrayEach (/home/user/.npm/lib/node_modules/screeps-multimeter/node_modules/lodash/index.js:1289:13) at Function.<anonymous> (/home/user/.npm/lib/node_modules/screeps-multimeter/node_modules/lodash/index.js:3345:13) at Multimeter.loadPlugins (/home/user/.npm/lib/node_modules/screeps-multimeter/src/multimeter.js:204:7) at new Multimeter (/home/user/.npm/lib/node_modules/screeps-multimeter/src/multimeter.js:117:10) at Promise.resolve.then.then (/home/user/.npm/lib/node_modules/screeps-multimeter/bin/multimeter:13:15) code: 'MODULE_NOT_FOUND' }

App crashes when logging "<==" in console

Multimeter crashes when I log my creep state changes. My logs for standard state changes looks like this:

[21897200] creep[Builder:21896981]: idle-state ==> refilling-state
[21897200] creep[Builder:21897008]: refilling-state ==> repairing-state
[21897200] creep[Builder:21897008]: repairing-state ==> idle-state
[21897200] creep[Builder:21897008]: idle-state ==> refilling-state

but when this logs is printed in console it crashes:

[21897201] creep[Harvester:21895835]: storing-state <== moving-state

with error:
Parse Error: <== moving-state

Strip HTML tags from output

This is awesome! one feature that would be really appreciated would be the ability to strip out html tags from the console output

Alternatively, if the HTML tags could be converted to the tags that blessed uses, that could also be a win.

Secure is ignored in config

The connection code is ignoring the secure property in the config. This makes UCF compliant configs not work for servers with https such as the screepspl.us servers.

As an aside, why not use await ScreepsAPI.fromConfig(serverName, 'multimeter')? That will return an API instance + api.appConfig will contain the multimeter section from the screeps.yml and effectively replaces this entire block

var opts = {};
opts.token = this.config.server.token;
opts.protocol = this.config.server.token ? 'https' : this.config.server.protocol || 'http';
if (this.config.server.host) opts.hostname = this.config.server.host;
if (this.config.server.port) opts.port = this.config.server.port;
if (this.config.server.path) opts.path = this.config.server.path;
this.api = new ScreepsAPI(opts);

Watch plugin appears to not be working

I installed the watch-client.js file in my code base as the instructions said. And I call it at the end of my game loop as can be seen in my Foreman.endShift() function which is called as the very last line in the loop.

Below is the console output from executing /watch status _.keys(Game.creeps).length as described in the documentation, along with some things that I did to try to debug the problem myself:

*** Cannot watch: Error: watch-client.js is not installed or out of date.                                                           
        at multimeter.api.memory.get.then.val (/Users/lee/Source/lee-dohm/screeps/node_modules/screeps-multimeter/plugins/watch.js:4
4:17)                                                                                                                               
        at process._tickCallback (internal/process/next_tick.js:68:7)
<<< JSON.stringify(Memory.watch)
>>> {"expressions":{},"values":{}}
<<< typeof Memory.watch
>>> object
<<< typeof Memory.watch.expressions
>>> object
*** This is Multimeter 1.8.0, which is the latest version.
<<< watcher = require("./watch-client")
>>> function () {
      if (typeof Memory.watch !== "object") {
        Memory.watch = {}
      }
      if (typeof Memory.watch.expressions !== "object") {
        Memory.watch.expressions = {}
      }
      if (typeof Memory.watch.values !== "object") {
        Memory.watch.values = {}
      }
      _.each(Memory.watch.expressions, (expr, name) => {
        if (typeof expr !== "string") return
        let result
        try {
          result = eval(expr)
        } catch (ex) {
          result = "Error: " + ex.message
        }
        if (name == "console") {
          if (typeof result !== "undefined") console.log(result)
        } else {
          Memory.watch.values[name] = typeof result !== "undefined" ? result.toString() : result
        }
      })
    }

The app fails soon after start

After start it can work a few seconds, and then fail with the following error.

TypeError: Cannot read properties of null (reading 'slice')
    at C:\Users\Alexey\AppData\Roaming\npm\node_modules\screeps-multimeter\node_modules\blessed\lib\program.js:2543:35
    at Array.forEach (<anonymous>)
    at Program._attr (C:\Users\Alexey\AppData\Roaming\npm\node_modules\screeps-multimeter\node_modules\blessed\lib\program.js:2542:11)
    at FastLog.Element._parseTags (C:\Users\Alexey\AppData\Roaming\npm\node_modules\screeps-multimeter\node_modules\blessed\lib\widgets\element.js:498:26)
    at FastLog.Element.parseContent (C:\Users\Alexey\AppData\Roaming\npm\node_modules\screeps-multimeter\node_modules\blessed\lib\widgets\element.js:393:22)
    at FastLog.Element.setContent (C:\Users\Alexey\AppData\Roaming\npm\node_modules\screeps-multimeter\node_modules\blessed\lib\widgets\element.js:335:8)
    at FastLog.Element.insertLine (C:\Users\Alexey\AppData\Roaming\npm\node_modules\screeps-multimeter\node_modules\blessed\lib\widgets\element.js:2383:8)
    at FastLog.Element.pushLine (C:\Users\Alexey\AppData\Roaming\npm\node_modules\screeps-multimeter\node_modules\blessed\lib\widgets\element.js:2526:15)
    at C:\Users\Alexey\AppData\Roaming\npm\node_modules\screeps-multimeter\src\FastLog.js:57:14
    at processTicksAndRejections (node:internal/process/task_queues:78:11)

I'm using logging plugin, my config is like this

servers:
  main:
    host: localhost
    secure: false
    port: "21025"
    username: oleksii
    password: qwerty
configs:
  multimeter:
    plugins: []  
    logFilename: "multimeter.log"

some logs may be added to the file before the crash

Logging module not found. Release 1.8.3.

I am running screeps on a private server on my laptop. I have managed to setup screeps-multimeter to work from both Linux and windows on both boots of my desktop.

However, the import thing is the logging module. Unfortunately, I can't get this to work.
Here is my screeps-multimeter.json on both boots.

{
  "shard": "shard0",
  "password": "mypassword",
  "username": "myusername",
  "port": "21025",
  "hostname": "desktop-abcdef",
  "logFilename": "screeps.log",
  "plugins": ["Loging"]
}

I have also tried "Log", "log" and "logging" for plugin name.
Windows it just fails with no explanation.
Linux I get the stack trace.

piers@Mavin:~/Downloads/screeps-multimeter-1.8.3/bin$ multimeter
{ Error: Cannot find module 'Logging'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at requireRelative (/usr/lib/node_modules/screeps-multimeter/node_modules/require-relative/index.js:25:15)
    at _.each.name (/usr/lib/node_modules/screeps-multimeter/src/multimeter.js:240:22)
    at arrayEach (/usr/lib/node_modules/screeps-multimeter/node_modules/lodash/index.js:1289:13)
    at Function.<anonymous> (/usr/lib/node_modules/screeps-multimeter/node_modules/lodash/index.js:3345:13)
    at Multimeter.loadPlugins (/usr/lib/node_modules/screeps-multimeter/src/multimeter.js:239:7)
    at Multimeter.run (/usr/lib/node_modules/screeps-multimeter/src/multimeter.js:175:10)
    at Promise.resolve.then.then (/usr/lib/node_modules/screeps-multimeter/bin/multimeter:19:9) code: 'MODULE_NOT_FOUND' }

On windows, I just used npm install -g screeps-multimeter to install and am not sure what version it is. On Linux I used release 1.8.3 from https://github.com/screepers/screeps-multimeter/releases - only Linux binaries seem to be there.

I noticed the logging is a very recent addition, so it might be a real bug rather than me being an idiot.

Watch plugin only works with shard0

The watch plugin only appears to work with shard0 at the moment. We're currently doing api.memory.get('watch'), but this just defaults to shard0. If the player isn't on shard0, this just returns { ok: 1 }, but contains no other data.

The api.memory.get() and api.memory.set() functions appear to also accept a second argument for the shard name.

The quick-fix is to just use the shard defined in the config file, but perhaps this should integrate with /shard somehow.

Multiple servers in config

Could it be made possible for multiple configurations, to select on start/via parameter for which server to launch multimeter?

Like having:

  1. mmo
  2. s+
  3. s+2
    etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.