[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]  Lua
. . -> [Subject]  toggling trigger groups at login
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

toggling trigger groups at login

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


Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Sun 01 Jun 2014 06:00 PM (UTC)
Message
I know I've seen this before, might have been a plugin which is why my search fu is failing so badly, but I'm looking for a way to toggle trigger groups at login based on character name. Script, trigger, whatever, it's all good if it keeps me from having to edit triggers every time I switch characters.

Once upon a time I might even have been able to do this with a few pointers after I got most of the work done but it's been 10+ years away from MUDs and MC so I'm more than a little rusty.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Nick Gammon   Australia  (21,323 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 02 Jun 2014 05:27 AM (UTC)
Message
What do you mean "based on character name"? Do you use the one world file but log on under different names?

If so you could make a trigger that matches the "welcome" message from the MUD (if there is one) or maybe just make one alias that logs in for you under one name, and another that logs in under another. Those aliases could also enable and disable various groups.

- Nick Gammon

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

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #2 on Mon 02 Jun 2014 05:46 AM (UTC)
Message
Yeah, I use a single world file (easier to maintain aliases that way) and log in with any pair of about a dozen characters. What I'd like to do is toggle a cleric trigger group based on which character is logging in.

The login info that matters will always look like:

WHAT...is your name?
drizzt

Probably a multiline trigger to toggle the cleric group but I'd need it to fire on several names and as previously mentioned, I'm better than 10 years out of practice. I'd guess a script with the multiple names in case structure would be the best way to go about it but I'm seriously fuzzy on how to set that up.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Nick Gammon   Australia  (21,323 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 02 Jun 2014 07:49 PM (UTC)
Message
Something like this:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="WHAT...is your name? "
   send_to="12"
   sequence="100"
  >
  <send>

t = { "drizzt", "gandalf", "frodo", "sam" } 
result = utils.listbox ("Log on as ...", "Log on", t, 1)  -- default is first once

-- exit if dialog dismissed
if result == nil then
  return
end -- if

-- get name from choice
name = t [result]

-- send log on name
Send (name)

-- enable groups as required
if name == "drizzt" then
  EnableGroup ("foo")
  EnableGroup ("bar")
elseif name == "gandalf" then
  EnableGroup ("fubar")
  EnableGroup ("heals")
elseif name == "frodo" then
  EnableGroup ("tank")
elseif  name == "sam" then
  EnableGroup ("warlock")
end 

</send>
  </trigger>
</triggers>


It detects being asked your name, pops up a dialog box of choices, and depending on your answer turns the various groups on. Also it sends the response to the MUD.

It could be expanded a bit to send the appropriate password (if that was required).

- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,323 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Mon 02 Jun 2014 07:51 PM (UTC)
Message
You might want to amend it to disable itself afterwards in case someone tricks you by sending "WHAT...is your name? " to you and then maybe finds out your password. However I suppose if that happens you just cancel the dialog and then the script exits without doing anything much.

- Nick Gammon

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

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #5 on Mon 02 Jun 2014 10:27 PM (UTC)
Message
Thanks Nick :) I'll tweak it for my names and trigger groups and life will be sexy again lol

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #6 on Wed 25 Jun 2014 04:18 PM (UTC)

Amended on Thu 26 Jun 2014 03:55 AM (UTC) by Meerclar

Message
Ok, been doing some tweaking and this is what I have now and I seem to have broken something. Triggers all show enabled when I open them individually but they aren't actually firing :(


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="WHAT...is your name? "
   send_to="12"
   sequence="100"
  >
  <send>

t = { "drizzt", "guenyvhar", "asmodeus", "elric", "alustriel", "meerclar", "grymgroeth", "elderel", "belial", "demogorgon" } 
result = utils.listbox ("Log on as ...", "Log on", t, 1)  -- default is first once

-- exit if dialog dismissed
if result == nil then
  return
end -- if

-- get name from choice
name = t [result]

-- send log on name
Send (name)

-- start with everything disabled
  EnableGroup ("tank", false)
  EnableGroup ("combat", false)
  EnableGroup ("heals", false)

-- enable groups as required
if name == "drizzt" then
  EnableGroup ("tank", true)
  EnableGroup ("combat", true)
elseif name == "Guenyvhar" then
  EnableGroup ("combat", true)
elseif name == "Asmodeus" then
  EnableGroup ("combat", true)
elseif  name == "Elric" then
  EnableGroup ("combat", true)
elseif  name == "Alustriel" then
  EnableGroup ("heals", true)
elseif  name == "Meerclar" then
  EnableGroup ("combat", true)
  EnableGroup ("heals", true)
elseif  name == "Grymgroeth" then
  EnableGroup ("tank", true)
  EnableGroup ("combat", true)
elseif  name == "Elderel" then
  EnableGroup ("heals", true)
elseif  name == "Belial" then
  EnableGroup ("heals", true)
  EnableGroup ("combat", true)
elseif  name == "Demogorgon" then
  EnableGroup ("combat", true)
end 

</send>
  </trigger>
</triggers>


My suspicion is I screwed up something in the "off by default" process but fresh eyes and such.

As a point of interest, any triggers that aren't in the 3 groups referenced here all work so it's definitely not a complete failure in trigger function.

Full summary info (wall of text warning):

-------------- MUSHclient summary --------------

MUSHclient version: 4.84
Compiled: Sep 30 2012.
Time now: Wednesday, June 25, 2014, 11:50 PM
Client running for:  0d 00h 14m 16s
World opened for:    0d 00h 14m 09s
World connected for: 0d 00h 03m 28s
Operating system: Windows XP
Libraries: Lua 5.1.4, PCRE 8.31, PNG 1.5.12, SQLite3 3.7.14, Zlib 1.2.5
World name: 'strange', ID: caab379828cd17c9d1bd913a
-- Scripting --
Script language: Lua, enabled: yes
Scripting active: yes
Lua sandbox is 127 characters, DLL loading allowed: yes
Scripting prefix: ''. External editor in use: NO.
Scripting for: 17.121235 seconds.
-- Triggers, aliases, timers, variables --
** Triggers: 10 in world file, triggers enabled: yes. [Triggers]
   3 enabled, 0 regexp, 304 attempts, 1 matched, 0.007968 seconds.
** Aliases: 31 in world file, aliases enabled: yes. [Aliases]
   31 enabled, 0 regexp, 62 attempts, 0 matched, 0.000039 seconds.
** Timers: 0 in world file, timers enabled: yes.
   0 enabled, 0 fired.
   Timers checked every 0.1 seconds.
** Variables: 0.
-- MCCP --
MCCP not active.
-- Plugins (Processing order) --
** Plugins: 0 loaded, 0 enabled.
-- Comms --
Connect phase: 8 (Open). NAWS wanted: NO
Received: 4749 bytes (4 Kb)
Sent: 56 bytes (0 Kb)
Received 16 packets, sent 5 packets.
Total lines received: 165
This connection: Sent 5 lines, received 141 lines.
Telnet (IAC) received: DO: 0, DONT: 0, WILL: 1, WONT: 1, SB: 0 [Telnet]
-- MXP --
MXP active: NO, Pueblo mode: NO, Activated: On command
MXP tags received: 0
MXP entities received: 0
MXP errors: 0
-- Commands --
Commands in command history: 1
Speed walking enabled: yes. Speed walking prefix: #
Command stacking enabled: yes. Command stack character: ';'
Accelerators defined: 0
-- Miniwindows --
** Miniwindows: 0 loaded, 0 shown.
-- Output window --
Output pixels: width 1899, height: 878, font width: 8, font height: 15
               can show 237 characters, wrapping at column 80, height 58 lines.
Output buffer: 183 of 5000 lines.
-- Miscellaneous --
Logging: NO, tracing: NO
** SQLite3 databases: 0
Sound buffers in use: 0

---------------------- End summary ----------------------


Trigger specific summary:

------ Trigger List (evaluation order) ------

  1. Normal, DISABLED : *trigger1      * places * in the back of *
  2. Normal, DISABLED : *trigger3      * snaps his fingers and is suddenly...
  3. Normal, DISABLED : *trigger5      * tells the group, 'heal'
  4. Normal, DISABLED : *trigger7      * tells the group, 'sanc'
  5. Normal, DISABLED : *trigger9      * tries to backstab *
  6. Normal, DISABLED : *trigger11     *The white aura around your body fa...
  7. Normal, DISABLED : *trigger13     *You are rescued by *, you are conf...
  8. Normal,  Enabled : *trigger15     WHAT...is your name? 
  9. Normal,  Enabled : *trigger17     You are hungry.
 10. Normal,  Enabled : *trigger19     You are thirsty.
10 triggers.



I def screwed something up in my tweaking - looks like turning off all of the groups is working properly but they aren't turning back on based on which character I select.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Nick Gammon   Australia  (21,323 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Wed 25 Jun 2014 10:59 PM (UTC)

Amended on Wed 25 Jun 2014 11:00 PM (UTC) by Nick Gammon

Message
Template:bug

Please provide a summary of your world configuration:

  • Either use the scripting Immediate window (Ctrl+I) to execute: Debug ("summary")

    or

  • Install the Summary plugin (see "Summary" feature) and type "summary"

Then copy the resulting information from the output window, and paste into a Forum message.

You need version 4.55 onwards of MUSHclient to do this.



Then when you get the summary (which you should post above) also click on the Triggers link:


-- Triggers, aliases, timers, variables --
** Triggers: 1 in world file, triggers enabled: yes. [Triggers]   <-------- here
   1 enabled, 1 regexp, 0 attempts, 0 matched, 0.000000 seconds.


Then copy and paste what is shown once you do that.

Do this once you have done the character selection, because this is when some of them should be enabled, right?

- Nick Gammon

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

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #8 on Thu 26 Jun 2014 04:13 AM (UTC)

Amended on Thu 26 Jun 2014 05:42 AM (UTC) by Meerclar

Message
Ok, now I'm really confused. I've commented out my addition that set everything to disabled and it still isn't enabling triggers at login. I've also removed the ", true" portion of the enable action since the documentation says it defaults to true.
***solution alert***
Found my mistake in tweaking the setup you started me off with - case sensitive string comparisons are case sensitive. Seems like I managed to capitalize the names in the if else structure after not doing so in the selection list. Fresh eyes I tell ya, fresh eyes.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[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.


5,819 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]