[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Escape of brackets in speedwalk string
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Escape of brackets in speedwalk string

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Jcl2016   (5 posts)  [Biography] bio
Date Fri 23 Dec 2016 06:37 AM (UTC)
Message
According to the document, we can use non-standard directions or general commands in speedwalk by putting them in brackets. For example: #3(say hello)

I want to know whether there is a escape character, so we can use commands containing brackets?
For example, I want to evaluate "say (hello)" command in speedwalk, "#3(say (hello))" is invalid, and "#3(say \(hello\))" is invalid too.
Is there a way to do this?
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Fri 23 Dec 2016 07:53 AM (UTC)
Message
Is this for using speedwalks as a command? Or in a script?

If you are just typing something in, like:


#3(say (hello))


You can always make an alias that matches on "#*" and then make your own rules for evaluation of what follows. It doesn't look as if the inbuilt rules allow for what you have in mind.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Jcl2016   (5 posts)  [Biography] bio
Date Reply #2 on Fri 23 Dec 2016 09:08 AM (UTC)
Message
Nick Gammon said:

Is this for using speedwalks as a command? Or in a script?

If you are just typing something in, like:


#3(say (hello))


You can always make an alias that matches on "#*" and then make your own rules for evaluation of what follows. It doesn't look as if the inbuilt rules allow for what you have in mind.


I use it in a script. The command is not just repeat someting. For example, I will use it like this:
#3n2e(ne/sw)3(turn left)3(turn right)(enter/out)

In most cases, the speedwalks have no problem.
But there are some special scenarios where commands will contain brackets, so the speedwalks will be broken.

Now I'm using server side alias to avoid the commands containing brackets. But the server side alias can't be too much. So I want to know whether there is client side solution.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Fri 23 Dec 2016 10:48 PM (UTC)

Amended on Fri 23 Dec 2016 10:50 PM (UTC) by Nick Gammon

Message
In a script you could always do part of the speed walk, send the next bit, and then do the next part. eg.


Queue (EvaluateSpeedwalk("4n"), true)
Queue ("say (hello)", true)
Queue (EvaluateSpeedwalk("3n2e(ne/sw)3(turn left)3(turn right)"), true)


Or you could choose some replacement characters (eg. "[" and "]") and then fix them up, eg.


sw = "4n3n2e(ne/sw)(say [hello])3(turn left)3(turn right)"
evaluated = EvaluateSpeedwalk(sw, true)
-- turn square brackets into round brackets, queue the speedwalk
Queue (string.gsub (evaluated, "[%[%]]", { ["["] = "(", ["]"] = ")" } ))

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


1,563 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]