Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Call setTickRate from client console #8

Open
olee opened this issue Jul 10, 2018 · 4 comments
Open

Call setTickRate from client console #8

olee opened this issue Jul 10, 2018 · 4 comments
Labels

Comments

@olee
Copy link

olee commented Jul 10, 2018

Hi, I saw in the code, that it looks like it should be possible to call setTickRate from the client console:

  config.engine.on('playerSandbox', function (sandbox, userID) {
    sandbox.setTickRate = function (value) {
      if (!value) return sandbox.console.log('Value required')
      if (!config.auth) { return sandbox.console.log(`screepsmod-auth is required to set tick rate from player console.`) }
      if (!config.auth.getUser) { return sandbox.console.log(`screepsmod-auth is outdated, please update screepsmod-auth`) }
      config.auth.getUser({ _id: userID }).then(user => {
        if (user.hasGroup('admin')) {
          pubsub.publish('setTickRate', value)
          sandbox.console.log(`Tick rate set to ${value}ms`)
        } else {
          sandbox.console.log(`Unauthorized. Only Admins can set tick rate.`)
        }
      })
    }
    sandbox.getTickRate = function () {
      env.get('tickRate').then(value => {
        sandbox.console.log(`Tick rate is ${value}ms`)
      })
    }
  })

However when I try to call setTickRate, the console says setTickRate is not defined.

How do I use this feature?
Would be awesome to set the tickRate from code for testing

@AlinaNova21
Copy link
Member

That is broken due to changes when IVM was introduced, it also relies on the undocumented group feature of screepsmod-auth, which I never finished developing and documenting :(

@olee
Copy link
Author

olee commented Jul 10, 2018

Is there any plan to get this working again?

@AlinaNova21
Copy link
Member

Currently not, IVM changes the sandbox in a way that makes this much harder to do. This kinda cheats and calls the DB directly from user code, which isn't allowed in IVM. It would need to set an intent then listen for it, adding a lot of extra complexity. You can still call it from CLI though.

@olee
Copy link
Author

olee commented Jul 16, 2018

If you can give me some pointers on how to implement this (that stuff with intent etc.) I would like to try adding this feature again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants