JScript Enable Trigger after Speedwalk

Posted by Mat on Sat 17 May 2014 12:57 PM — 5 posts, 26,652 views.

#0
Is there any way to enable a trigger after the speedwalk completes? It's as if you'd be putting it into the queue so that when the command goes through the trigger is added, instead of immediately when you do enableTrigger.

I tried world.send(aliasname) which would put it in the queue, but the aliasname isn't recognized. It only works when I do world.execute(aliasname), yet that's done immediately.

To explain further, I have a trigger which detects exits. I want to disable this trigger, speedwalk somewhere, and enable the trigger after the speedwalk is complete. I can't use a timer or doafter because I'm not sure how long it will take.

Any help is appreciated :)
Australia Forum Administrator #1
There doesn't seem to be a way to queue commands, which would help, because commands can be caught by aliases, which can then call a script. This plugin would add that ability:

Template:saveplugin=SpeedwalkCompleted
To save and install the SpeedwalkCompleted plugin do this:
  1. Copy the code below (in the code box) to the Clipboard
  2. Open a text editor (such as Notepad) and paste the plugin code into it
  3. Save to disk on your PC, preferably in your plugins directory, as SpeedwalkCompleted.xml
    • The "plugins" directory is usually under the "worlds" directory inside where you installed MUSHclient.
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file SpeedwalkCompleted.xml (which you just saved in step 3) as a plugin
  7. Click "Close"
  8. Save your world file, so that the plugin loads next time you open it.




<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="SpeedwalkCompleted"
   author="Nick Gammon"
   id="7aad77576345785635c646fe"
   language="Lua"
   purpose="Shows when a speedwalk completes"
   date_written="2014-05-18 07:35:24"
   requires="4.90"
   version="1.0"
   >
</plugin>

<!--  Script  -->

<script>
<![CDATA[
function OnPluginSend (sText)
  if sText == "SpeedwalkCompleted" then
    Execute ("TellPlayerSpeedwalkCompleted")
    return false  -- do not send to the MUD
  end -- if
  
  return true -- process other commands
end -- function

]]>
</script>
</muclient>


If you install that, then whenever the client tries to send "SpeedwalkCompleted" to the MUD, it catches it and replaces it with executing "TellPlayerSpeedwalkCompleted".

Now make an alias to respond to that:


<aliases>
  <alias
   match="TellPlayerSpeedwalkCompleted"
   enabled="y"
   send_to="12"
   omit_from_output="y"
   sequence="100"
  >
  <send>

Note ("Execute some script here ...");

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


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


That alias could re-enable your trigger (and send a message, or whatever).


Now to put it all together, make the speedwalk send the special word, eg.


#4n e s (SpeedwalkCompleted)


A word in brackets in a speedwalk is sent verbatim to the MUD. However in our case the plugin will catch that word, and it ends up calling the script as described above.
#2
Thanks for responding in such detail Nick.
I tried getting everything going on Mushclient, but whenever I do the speedwalk it executes the alias immediately. I left the TellPlayerSpeedwalkCompleted alias with the Note command and it sends the note right as I press enter, not after the speedwalk has completed. I'd imagine it would do the same with adding/enabling triggers.

I did have to change the minimum Mushclient version to 4.84 since I didn't have 4.90 and I couldn't find it on your downloads page, could that have affected it?
Australia Forum Administrator #3
Later versions are here:

http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=1

Do you have a speedwalk delay set up? If not, speedwalking is the same as sending (ie. there is no delay).

Note that the speedwalk commands might be sent faster than the MUD executes them.
#4
I see, that does work with the speedwalk delay.
I just have to make sure there isn't anything executed before the speedwalk that would delay the speedwalk from beginning as well as figuring out the correct ms for delay.

Thanks for your help Nick!