screepers / screeps-multimeter

The most useful tool on your screeps workbench.
MIT License
89 stars 28 forks source link

Add shard support to Watch plugin (Fixes #32) #36

Closed InValidFire closed 4 years ago

InValidFire commented 4 years ago

This fixes #32, however it does not expand the /shard command as suggested in that issue. I opted to create a secondary command /wshard in the Watch plugin to manage shard selection for the plugin. The functionality for the command is identical to the original /shard command on the user's end.

My reasoning for this is to keep plugin territory separate from the core application while accomplishing what we needed.

Upon /wshard's usage, it will also save the given shard to the config file under the name watchShard. I mirrored this functionality to the original /shard command, keeps these values updated.

SystemParadox commented 4 years ago

Hi, thanks very much for this.

I've been wondering how best to integrate this with /shard, or whether it should be integrated at all. Keeping this totally separate is an interesting idea. I think there's a strong case for wanting to run commands on one shard but keep watching another shard, particularly if like me you've got most of your empire on one "primary" shard.

My only concern is whether it might be confusing having extra commands and two different states. What do you think? Are you specifically wanting them separate, or would it still make sense to you if watch tied in with the existing /shard command?

Some other thoughts:

@CGamesPlay, you might want to weigh in on this one!

InValidFire commented 4 years ago

Tie /wshard and /shard together; There are two things I dislike about this:

Avoiding confusion; I made a few changes to ensure this didn't happen:

Saving:

I appreciate the feedback, definitely look through the code if y'all haven't already, always helps to have a second set of eyes.

Oh yeah, with regard to changing the command name, it doesn't really matter at the end of the day what it's called, /wshard is just faster to type. Since it's part of the watch plugin, I felt we didn't need to spell it out haha, but this can of course change.

SystemParadox commented 4 years ago

I initially implemented it this way as a modification to /shard, syntax was modified to be the following "/shard MODE SHARD", however I decided against this in the committed version as it felt messier

If we're thinking of tying it together I meant completely tied, so /shard shard0 would set the command shard and the watch shard, and there would be no way of having them be different.

One other suggestion if we're keeping them separate would be to add this to /watch, so the plugin still provides a single command:

/watch console [expr] /watch status [expr] /watch shard [shardName]

So you would do /shard 0 to change the command shard and /watch shard 0 to change the watch shard.

Avoiding confusion; I made a few changes to ensure this didn't happen:

  • Watch will send the message, 'Watch plugin disabled: no expressions found for active shard.' in the event it sees your memory data, but no expressions are found. (aka you're on a shard without expressions)
  • I modified the text that both /shard and /wshard output when listing the active shard to be 'Command Shard: SHARD' and 'Watch Shard: SHARD' respectively, to further illustrate that the two are separate values.

If we decide to go for separate commands then this definitely helps to clarify what's going on :). Adding the hint to the "no expressions found" message is a good idea as well.

So the options at the moment are:

  1. /shard 0 changes both command shard and watch shard at the same time
  2. /watch shard 0
  3. /wshard 0
InValidFire commented 4 years ago

Ah, if tying it together means removing the individual shard control I'd prefer we do otherwise. As you mentioned in the first comment, I like the idea of being able to watch one shard but issue commands on another should the user desire.

An interesting idea for tying it together and still allowing the user to specify shards if needed that I didn't think of before would be modifying the /shard command to accept flags for the target to change.

  1. /shard 0 - set both the watch and command shard
  2. /shard 1 -w - set the watch shard
  3. /shard 2 -c - set the command shard

This would fit well with the -save flag we may implement with this.

The only possible problem with this method is if you don't know about these flags the feature doesn't exist, but i'm sure that'd be easily fixable with some help text modification.

However, any option that completely removes the ability of specifying the individual shard to change should be avoided.

CGamesPlay commented 4 years ago

Hi @InValidFire, thanks for contributing! After reading over the discussion happening here I'm wondering if maybe a more holistic view on shards should be taken?

In the more-distant future it might make sense to switch to a tabbed interface like slack, where each each is a different "channel". This might help alleviate all of these issues. I'm not asking for this to be implemented here, but that mindset (shards are like completely separate instances of screeps and multimeter can just read from all of them) might help make the implementation of this more intuitive.

InValidFire commented 4 years ago

The reasons for the secondary command originally, as you saw was partially because of me being unwilling to change any of the established command syntax if I could avoid it, no need for the added confusion there. If we're all good with changing the syntax for either the /shard or /watch command I can get to work on modifying those once we figure out how we want to change it.

While I really like the idea of listening to all shards from a broad standpoint. The limitations I can think of with this mostly comes down to the current implementation of the status bar. I feel like having each shard's watch data being sent to one bar fighting for dominance would be a bad idea. If we wanted to go the route of listening to all shards like the console, we'd have to figure out how to address the issue with the status bar. There are no issues that come to mind with handling console messages via the plugin. (however I feel the status bar is the more used feature of the Watch plugin, at the very least personally)

CGamesPlay commented 4 years ago

I agree with your assessment about the status bar. I don't understand why there should be 2 commands, and while I agree that /shard shouldn't know about the existence of /watch, I don't understand why /watch shouldn't look at the current command shard to dictate its behavior.

So, to rephrase my original comment in more actionable terms, I believe it should look like this:

Then there's a choice about the status bar. I only see 3 reasonable options:

I don't have a preference about which behavior is taken, because I haven't used multiple screeps shards much in the past. Both seem reasonable to me, so perhaps if one is technically easier to implement it makes sense to just go with that option.

InValidFire commented 4 years ago

Here's my suggestion on how we handle this:

Currently the only way I know we can do this is to add the logic directly to the function that controls the /shard command, breaking my original intent of keeping the command shard logic and watch shard logic completely separate.

I'd suggest later down the line that we add the ability for plugins to wrap other command functions somehow (probably with checks to ensure no abuse by 3rd party plug-ins), thus being able to move the watch related shard logic outside of the /shard function. However for now, until we get something like this implemented... I personally would be happy with what we have here.

SystemParadox commented 4 years ago

If we can avoid two having different shard states then I'd really like to do that.

It seems like a reasonable compromise to subscribe to all shards for "watch console", but have "watch status" use the current shard set with /shard. This still gives you the ability to watch something on a different shard, just not the status.

That said, is there a reason why we can't just watch status for all shards as well? Perhaps with an option to display the values as columns on one line, or as separate lines, depending on how long your status information is?

I think we will need to add a watchShards option to tell watch which shards it should subscribe to, because I don't see any way to tell which shards are even available on the server, let alone which the player is using. We could auto-add this to the config file when adding a new watch expression perhaps?