Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Suggestions ➜ Improve trigger copy without copying label

Improve trigger copy without copying label

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


Posted by Zhenzh   China  (68 posts)  Bio
Date Sun 22 Sep 2019 11:22 PM (UTC)
Message
when copying a trigger with label, it will failed for the label conflict. I have to additional operations remove label -> copy trigger -> add back label.

Actually, trigger label is not a necessary value to be copied. What we want is the other trigger options to be copied to created a similar trigger as the origanal one.

Copying label value seems a superfluous operation and will never get success. Can we using a null label instead of copying it during copying triggers?

Besides, why not using one button duplicate instead of copy/paste? The two buttons are always used one after another.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 23 Sep 2019 11:05 AM (UTC)
Message
Quote:

when copying a trigger with label, it will failed for the label conflict.


No, copying does not fail. Pasting an identical trigger fails.

Quote:

Actually, trigger label is not a necessary value to be copied. What we want is the other trigger options to be copied to created a similar trigger as the origanal one.


You may want that, however the copy/paste functionality is for more than merely duplicating a trigger. For example:


  • Copying a trigger from one world file to another
  • Copying a trigger from the GUI interface to a plugin
  • Copying a trigger from a world file to a forum posting


In all of these cases the trigger name is important, and might be part of the scripting, otherwise why have a name in the first place?

You can make yourself a "duplicate a trigger" alias like below, based on the "addxml" module described on this page:

http://www.gammon.com.au/forum/?id=7123

This lets you duplicate a named trigger. It finds the trigger, removes the name, and adds the new one into the world trigger space. Note that the inbuilt trigger adding code discards exactly duplicate triggers, which the code below checks for by making sure the number of triggers goes up.


<aliases>
  <alias
   match="duptrigger *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

require "addxml"  -- get extension script

if not GetTriggerInfo ("%1", 1) then
  ColourNote ("red", "", "Trigger '%1' does not exist")
  return
end -- if

-- get trigger
local t = addxml.save ("trigger", "%1")

-- get rid of label
t.name = ""

local count = #(GetTriggerList ())

-- put it back
addxml.trigger (t)

if #(GetTriggerList ()) ~= count then
  ColourNote ("green", "", "Trigger '%1' has been duplicated as an unlabelled trigger")
else
  ColourNote ("red", "", "Trigger '%1' not added, there must be an exact duplicate of it")
end -- if

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


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


13,687 views.

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

Go to topic:           Search the forum


[Go to top] top

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