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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  print(os.date ("%c")) works with script prefix but alias doesn't.

print(os.date ("%c")) works with script prefix but alias doesn't.

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


Posted by Zack   (23 posts)  [Biography] bio
Date Mon 26 Oct 2020 08:56 PM (UTC)

Amended on Mon 26 Oct 2020 10:32 PM (UTC) by Nick Gammon

Message
Hello.
I'm trying to get print(os.date ("%c")) working inside of an alias. My script prefix is / so when I'm in the normal window where I can send commands to the mud and I use / it works great. When I put print(os.date ("%c")) inside of the send field for the alias it gives me problems.
My goal is to have a trigger fire the alias or have the trigger directly use print(os.date ("%c but so far nothing is working.
the current alias...


<aliases>
  <alias
   match="time"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>print(os.date ("%c"))</send>
  </alias>
</aliases>


Error message...


Compile error
World: dw
Immediate execution
[string "Alias: "]:1: unfinished string near '"<aliases>'


Here's the error message from the trigger attempting to print.


Compile error
World: dw
Immediate execution
[string "Command line"]:1: '=' expected near '<eof>'


Thank you for your help!
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 26 Oct 2020 09:18 PM (UTC)

Amended on Mon 26 Oct 2020 10:33 PM (UTC) by Nick Gammon

Message
Inside an alias (and a trigger) "Send" box, the sequence %x where x is various letters and digits has a special meaning, as documented here:

http://www.gammon.com.au/scripts/doc.php?dialog=IDD_EDIT_ALIAS

In particular, %1 is the first wildcard, %2 the second wildcard, and so on. And, %c is the clipboard contents.

To pass "%c" down to Lua you need to double the % symbols, eg.


print(os.date ("%%c"))

- Nick Gammon

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

Posted by Fiendish   USA  (2,525 posts)  [Biography] bio   Global Moderator
Date Reply #2 on Mon 26 Oct 2020 09:23 PM (UTC)
Message
Quote:
Inside an alias

Inside a <send> </send> xml block, because it will happen for triggers too.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Zack   (23 posts)  [Biography] bio
Date Reply #3 on Mon 26 Oct 2020 09:28 PM (UTC)
Message
Thank you so much Nick. I totally forgot about that being the norm. I use %1 all the time and it didn't even click in my brain that it was the issue.
I got it working now. Also thank you for making such an awesome accessible mud client! I love MC.
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Mon 26 Oct 2020 10:33 PM (UTC)
Message
Fiendish said:

Quote:
Inside an alias

Inside a <send> </send> xml block, because it will happen for triggers too.


Amended my reply to make that clearer.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Mon 26 Oct 2020 10:36 PM (UTC)
Message
This happens more generally in trigger and alias "send" boxes, using send-to-script. For example, doing a string.match, and using %c to detect control characters would have a similar issue.

In those cases you should double the "%" symbols if you are using them other than for their intended purposes (wildcard 1, wildcard 2 etc.).

In fact, it is somewhat simpler in many ways to call a script function in your script file (and not use send-to-script) because functions inside your script file do not have these problems.

- 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.


14,649 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 HostDash]