Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make commandSeparator settable with a function #3677

Closed
KitchenMUD opened this issue Apr 25, 2020 · 27 comments
Closed

Make commandSeparator settable with a function #3677

KitchenMUD opened this issue Apr 25, 2020 · 27 comments
Labels

Comments

@KitchenMUD
Copy link
Contributor

We already have the getCommandSeparator() function, we need a way to set the command separator without having to jump into the preferences. I suggest adding a setCommandSeparator() function.

Reasons for adding feature:

  1. Mudlet has been gaining traction on my MUD and players prefer using a single semi-colon command separator, but of course the issue with that is you can't winky smiley face and you can't create server side mud aliases, which also use a semi-colon for separating commands.
  2. With setCommandSeparator() players wouldn't have to do any annoying menu hopping when they want to establish a server side mud alias.
  3. setCommandSeparator() could be used in conjunction with getCommandSeparator() to share scripts more easily by doing something like:
local x = getCommandSeparator()
if x ~= ";" then setCommandSeparator(";")
send("com1;com2;com3;com4")
setCommandSeparator(x)
else
send("com1;com2;com3;com4")
end

This will (I think) retreive the command separator, check whether not it is a semi-colon, and if it isn't a semi-colon then change it to a semi-colon then execute the code and then change it back to whatever it was before.

@demonnic
Copy link
Member

or you could use the proper form, which is sendAll("com1", "com2", "com3", "com4")
or you can use getCommandSeparator and then use the output of that to form your string, IE

local cs = getCommandSeparator
local commands = {
  "com1",
  "com2",
  "com3",
  "com4",
}
send(table.concat(commands, cs))

I'm not sure we want to encourage script authors to be setting/resetting the command separator in their scripts. I'll end up with tons of people coming in asking why they can't use a semi-colon again, or why the colon suddenly splits things into two commands and all it takes is your function erroring once before resetting it. Especially since you don't do anything with it if it's ; and now the player is left with an unexpectedly broken setup.

@demonnic
Copy link
Member

That being said, setCommandSeparator could be good to have just to have the full suite of preference getters/setters but this is exactly what it shouldn't be used for.

@KitchenMUD
Copy link
Contributor Author

Fair enough. Potential issues aside, being able to lua setCommandSeparator("somethingElseTemporarily") from the main console would be a step towards fixing problems for players accustomed to ';' as a command separator. Were it implemented, it might need a >>>Be careful as with misuse, your scripts could break.<<< in the manual.

@demonnic
Copy link
Member

I'm confused why all this temporary changing of the command separator is going on. If they're used to ; why wouldn't they just change it to ; like they're used to? That's a lot to type out twice to change it back and forth when they can just go into the settings and change it once to what they actually want it to be.

@Kebap
Copy link
Contributor

Kebap commented Apr 25, 2020

It seems like you want an alias that will feed into sendAll along the lines of demonnic's first comment

What exactly do folks type then in your other clients to send multiple commands, but not interfere with winky smileys and server side shenannigans?

@SlySven
Copy link
Member

SlySven commented Apr 25, 2020

I also thought that the omission of a function to set the command separator was a conscious and deliberate decision at the executive level 😁 to avoid the breakage that could arise from one script/package changing it whilst another (possibly asynchronous one run from a timer!) was active.

As far as I can tell the main discussion on this was in #1866 .

@demonnic
Copy link
Member

That does sound like something we might have done, but I think accessibility may wind up requiring that we create some way to set it from the command line at least, even if it's separate from the lua API itself.

@KitchenMUD
Copy link
Contributor Author

I'm confused why all this temporary changing of the command separator is going on. If they're used to ; why wouldn't they just change it to ; like they're used to? That's a lot to type out twice to change it back and forth when they can just go into the settings and change it once to what they actually want it to be.

The problem lies in cases where the MUD accepts ';' as input and there's no way to input a ';' without menu hopping if ';' is your command separator. Being able to make smiley faces is one thing (one could create a mudlet alias that switches the command separator temporarily to something innocuous when using a chat channel to avoid that). Another is that the MUD can store server side aliases, which are generally going to be faster to process and quicker/easier to create than client side aliases, but these use ';' to separate the command as well.

@demonnic
Copy link
Member

these all sound to me like reasons not to use ; as the command separator.

@KitchenMUD
Copy link
Contributor Author

Not an option unfortunately when we already have hundreds of triggers and client side aliases that use send("tens of commands separated by ;") that all break upon changing the command separator. I think the habit comes from ZMud which uses ; to separate commands, though the parser for ZMud sends ; if it is surrounded by spaces. What about if doubling whatever the command separator was would just send that to the Mud instead? Like if your command separator such as in my case were ; then sending ;; would send one ; to the mud instead so for example typing say hello everyone;;) would send say hello everyone;). If you used ;; as a command separator then you would do ;;;; to escape out the command separator and send ;;. Could have a checkbox in preferences that would enable / disable that option, disabled by default, as well to avoid breaking functionality for any thing that doubling the command separator might break, though I can't think what the harm would be there.

@vadi2
Copy link
Member

vadi2 commented Apr 28, 2020

If you used ;; as a command separator then you would do ;;;; to escape out the command separator

Do you think people will take well to typing out the semicolon four times? 🤔 I don't think that is realistic.

@KitchenMUD
Copy link
Contributor Author

Do you think people will take well to typing out the semicolon four times? 🤔 I don't think that is realistic.

I don't think those who have adopted a 2-character command separator already would find the need to escape their command separator very often. How often would you need to escape out of a command separator this is already set to ;;? The alternative is just never being able to send ;; to the MUD in any way, right? I agree escaping would get tedious for those with 2 or more characters set for their command separator, but wasn't the point of setting 2 or more characters in your command separator that you wouldn't run into an issue with sending to the mud a single character of the escaped character? It'd be interesting to see a poll of what people use as a command separator, and whether or not they've adopted ;; or some other doubled character.

@vadi2
Copy link
Member

vadi2 commented Apr 28, 2020

I don't think a poll will help because that's saying "let's screw the minority", whoever the minority ends up being.

The original script:

local x = getCommandSeparator()
if x ~= ";" then setCommandSeparator(";")
send("com1;com2;com3;com4")
setCommandSeparator(x)
else
send("com1;com2;com3;com4")
end

This is an insane amount of work, why complicate things so much? If you have several things to send, use sendAll()?

@KitchenMUD
Copy link
Contributor Author

I don't think a poll will help because that's saying "let's screw the minority", whoever the minority ends up being.

I don't see how anybody would be screwed by a method to escape the command separator. A new preferences option or function shouldn't be breaking any current functionality. I am curious about what people actually use for their command separator, if people have adopted a 2 character command separator so that they can send that character to the MUD or not. If your command separator is a single ; , then ;;) would send ;) and bypass the command separator. If your command separator is a double ;; then ;) would still send ;) without activating the command separator. If you wanted to send ;; for whatever reason, for example gossip Hey guys, I use Mudlet and my command separator is ;; , then you would be able to type ;;;; to send the ;; to the MUD in the previous example.

This is an insane amount of work, why complicate things so much? If you have several things to send, use sendAll()?

It would be a workaround if we had a setCommandSeparator() function for those who like using ; as the command separator but still on occasion need to actually send ; to their MUD. sendAll() works great if it's just 2 or 3 commands but when you get to 30 or 40 commands in a row, those get tedious to write pretty quickly versus separating the commands with the already existing ; command separator.

I guess this has become 2 suggestions now, one for setCommandSeparator() function, and the other a preferences checkbox option for Double command separator to bypass the command separator. Not sure about the etiquette for Github in this case so my apologies there!

@vadi2
Copy link
Member

vadi2 commented Apr 28, 2020

I don't think you're being realistic when you're telling someone that they have to type ;;;;... sorry! The response you're likely to get is "are you kidding me?"

We didn't include the function to begin with for a specific reason - it enables bad habits. I understand the friction the players in your game have with this bad habit and how difficult it is, and they'd like to do more work by putting in really large scripting aliases that change, edit, etc mess with the separator instead of changing the habits... but perhaps it's best to change the habit to something better instead?

If you'd like to send multiple things, don't use send() with the command separator. That's bad practice. We have sendAll() for this reason that avoids these messes entirely. See code demonnic pasted up a bit on top earlier.

I totally get that you'd like to make the transition to Mudlet smoother. But enabling bad habits probably isn't a good way to go, because in the end Mudlet will become as shitty as the other clients then, wouldn't it?

@KitchenMUD
Copy link
Contributor Author

I don't think you're being realistic when you're telling someone that they have to type ;;;;... sorry! The response you're likely to get is "are you kidding me?"

They don't have to of course, only if they want to escape the command separator for whatever purpose. If they used a single ; as the command separator they'd only need to type it twice to escape and send a single ;. ;)

If you'd like to send multiple things, don't use send() with the command separator. That's bad practice. We have sendAll() for this reason that avoids these messes entirely. See code demonnic pasted up a bit on top earlier.

Unfortunately I didn't realize that sendAll() was the preferred option for this when I wrote a lot of the aliases and triggers nor did I know about the speedwalk() for inputting lots of directions.
So I ended up with a lot of aliases that look something like this "brief;compact;s;s;w;w;w;w;w;w;w;w;w;w;w;w;w;w;w;w;s;w;w;s;s;w;s;s;s;s;s;e;s;s;e;e;s;e;e;n;e;e;n;e;n;d;d;n;n;n;d;e;e;s;s;s;u;u;u;n;u;u;n;n;w;n;n;u;u;u;n;n;enter lift;u;s;s;s;s;s;s;s;d;d;d;e;e;e;s;s;s;e;e;e;s;s;e;s;e;s;e;e;s;u;u;u;u;u;e;n;n;n;e;n;n;n;e;n;n;n;n;e;e;s;e;s;e;n;n;e;n;e;n;e;s;e;s;e;e;s;s;s;e;e;e;s;brief;compact"

Back to the topic though, I don't believe that having to menu hop to swap command separators when the need arises to send whatever character the user has chosen for command separator to the MUD, then menu hop again to switch it back, is a design improvement over other clients in this regard and I think Mudlet can do better.

@vadi2
Copy link
Member

vadi2 commented Apr 28, 2020

Open up an editor that can do regex search & replace, put this pattern in: (.+?); and replace with "\1", and that'll get you 95% of the way there for every alias.

Unfortunately I didn't realize that sendAll() was the preferred option for this when I wrote a lot of the aliases and triggers nor did I know about the speedwalk() for inputting lots of directions.

Alright we'll improve the docs here so it helps for the future.

Edit: that's done in all relevant places.

@Kebap
Copy link
Contributor

Kebap commented Apr 28, 2020

My question still remains unanswered:

What exactly do folks type then in your other clients to send multiple commands, but not interfere with winky smileys and server side shenannigans?

For example, I can assume most players don't even want to dive into alias scripting all too much, they just want to type something like for example speedy s;s;w;w;w;s;s;s;e;s;s;e;e;u;u;u;n;n;enter lift;u;s;s;d;e;e and so on.

If so you can easily build and distribute an alias that will recognize the speedy command and split the remainder into individual items which can then be sent separately with sendAll as explained above.

Voilá, players are happy, no need to use or change any separators at all, at all.

In no way I recommend the menu hopping to keep setting and resetting your favorite command separator vs. the one someone used in their scripts (remember, there could be conflicting authors as well).
Nor would I condone one author being able to change the separator without player's notice and all other scripts' authors and the player herself be affected by it.

@KitchenMUD
Copy link
Contributor Author

My question still remains unanswered:

What exactly do folks type then in your other clients to send multiple commands, but not interfere with winky smileys and server side shenannigans?

From the players that I've asked, I've heard four different methods for disabling/bypassing the command separator outside of menu hopping.

  1. ~ before command separator, so ~; would send ;
  2. Doubling the command separator it so ;; would send ;
  3. Hot key ctrl+r to disable, among other things, the command separator
  4. An icon at the end of the console input bar that disables the command separator

From what I can tell, the preferred command separator is ; amongst our users but other clients offer various ways to escape out of the command separator, so sending smiley faces or issuing commands to the mud that require a ; are not an issue.

@vadi2
Copy link
Member

vadi2 commented Apr 28, 2020

Escaping it sounds fine to me - anyone know what zmud/mush do?

@Kebap
Copy link
Contributor

Kebap commented Apr 28, 2020

ZMUD says:

text is parsed as a series of commands separated by the command separator character (defaults to ;). Each command consists of the command name as the first word, preceeded by the command character (defaults to #). Command separators used within quotes ("" or '') or brackets ([] <> or {}) are ignored in breaking up the individual commands. For example
#SAY {a;b}
is a single command, where as
#SAY a;b
is two commands.

MUSHCLIENT community hints:

In MUSHclient, if you start a line with a semicolon, subsequent semicolons are no longer treated as line separators.

@vadi2
Copy link
Member

vadi2 commented Apr 28, 2020

Mushclient's approach seems more reasonable... but still, do want to help condone bad behaviour? Fixing existing aliases isn't hard, see #3677 (comment), and with better docs less people would start making the mistake.

@KitchenMUD are you able to repair your aliases with it?

@KitchenMUD
Copy link
Contributor Author

@KitchenMUD are you able to repair your aliases with it?

It is tedious, but I can convert those that use send to sendAll using the method you suggest.

@vadi2
Copy link
Member

vadi2 commented Apr 30, 2020

Hopefully not much more work than embedding the use of setCommandSeparator()

@KitchenMUD
Copy link
Contributor Author

Hopefully not much more work than embedding the use of setCommandSeparator()

@vadi2 Perhaps that was a poor example on my part. I figured since we already have getCommandSeparator(), then a counterpart setCommandSeparator() function would be an easy fix. The main issue, I think, is Mudlet should have a method for escaping the chosen command separator outside of requiring the user to menu hop.

Maybe a better function would be a new one that ignores parsing of the command separator altogether and sends directly what is input in the code? That is safer to keep end users from mucking something up, outside of a UI solution.

@vadi2
Copy link
Member

vadi2 commented May 30, 2020

Maybe a better function would be a new one that ignores parsing of the command separator altogether and sends directly what is input in the code?

I like that idea. Would it solve it for you?

What do others in @Mudlet/lua-interface think?

@SlySven
Copy link
Member

SlySven commented Nov 20, 2022

I think this has run its course and we have given strong reasons for not wanting to do what the OP requested - It is hoped that the alternatives that we do provide will be sufficient for them.

@SlySven SlySven closed this as completed Nov 20, 2022
@SlySven SlySven closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants