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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  Random alias

Random alias

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


Posted by Sparafucile   (9 posts)  [Biography] bio
Date Wed 19 Oct 2005 12:16 AM (UTC)
Message
Hey guys. I have no scripting experience, and I need some help. I'm trying to do a random alias thing for a certain chat channel on the mud I play. Basically, every time I do 'bc (text)' I want it to do something like this:

Input: bc (text)
Output: {Buddy) [Alias 1] (text) OR
(Buddy) =Alias 3= (text) OR
(Buddy) ---Alias 2--- (text) OR... etc

So, every time I type in the channel, I want the script to pick a random alias to put a certain string before my text. I know it's asking alot to write a whole script out for me, but hey, I wouldn't know where to start. Or maybe at least give me the basics; I have -some- programming experience. Thanks!
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Wed 19 Oct 2005 08:26 AM (UTC)

Amended on Wed 19 Oct 2005 08:27 AM (UTC) by Nick Gammon

Message
This will do it, if you have Lua selected as your scripting language. Just copy and paste into the Alias list box (click the Paste button). You can add any number of names to the "names" table below. It randomly chooses one from the list.


<aliases>
  <alias
   match="bc *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
do
local names =
  {
  "John",
  "Nick",
  "Peter",
  "Margaret"
  }

Send ("(Buddy) " .. 
     names [math.random (1, table.getn (names))] ..
     " %1")

end
</send>
  </alias>
</aliases>


- Nick Gammon

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

Posted by Sparafucile   (9 posts)  [Biography] bio
Date Reply #2 on Wed 19 Oct 2005 10:49 PM (UTC)
Message
Thanks, I really appreciate it. Unfortunately, I'm still having some trouble, this time calling the script. Here's what I did:

- Selected Lua as Scripting Language, checked the Enable Script box, copied the program in a .lua file, set the path to it in the Script File box.

- I assumed the name of the routine was aliases, so I put 'aliases' (without the '') in the Get Focus box. This could be my problem, but I don't think it is becase...

- when I click ok, I get an error message that looks like this. Error Number: 0, Event: Compile Error, Description: "[string "Script file"]:1: unexpected symbol near `<'", Called by: Immediate execution.

Sorry, I really know nothing about this, heh. Also, in the event that I do get it working, I make an alias 'bc *', and put what in the send box? the script filename? or the name of the subroutine, aliases?
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #3 on Thu 20 Oct 2005 02:07 AM (UTC)
Message
Copy that whole thing (<aliases> to </aliases> inclusive) and then go to the alias screen (thats the one you get to when you push the alias button, with the grid of aliases), and click the 'paste' button on that screen.

That's all you have to do! No mucking with script files.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Sparafucile   (9 posts)  [Biography] bio
Date Reply #4 on Thu 20 Oct 2005 02:30 AM (UTC)
Message
Beautiful! thank you so much, both of you. Works like a charm!
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Thu 20 Oct 2005 06:47 AM (UTC)
Message
For future reference, the post Pasting triggers describes the general process. Although it refers to triggers the same idea applies to aliases.

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


19,367 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]