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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  Triggering on a variable, aliases, speedwalks etc.

Triggering on a variable, aliases, speedwalks etc.

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


Posted by Jeffrey F. Pia   (49 posts)  [Biography] bio
Date Thu 02 May 2002 05:33 PM (UTC)
Message
1) Is it possible to write a trigger that keys on a variable?
(i.e. Trigger: "^@CurEnemy flees .+$" or something)

2) Is it possible to print out a list of all triggers? Can this be done with a script maybe? It would make debugging and changing triggers much easier if I knew how to do this.
3) Is it possible to use Global variables in VBscript? If so, when would the variables initialize, and what would the lifespan of the variables be?
4) Is it possible to use a Trigger to fire an Alias? I could save quite a few redundant lines if I knew how to do this.

Lastly,
5) Do any of the high-speed individuals who use MUSHclient have a website showing off some of their technical expertise at creating triggers, aliases, timers, and scripts?

Thanks!
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #1 on Thu 02 May 2002 07:42 PM (UTC)
Message
Hmm.

Item 1: Gammon says he is going to support this starting with version 3.18.

Item 2: world.gettriggerlist, then use world.gettriggerinfo on each one and dump the results into a note window. But no direct means exists to print the list as far as I am aware.

Item 3: Yes. You place them like you would globals in any other languages. As the first lines in the script and outside of any subs. The last as long as you don't reload the script or otherwise cause them to be reinitialized from scratch. So Closing the world would kill them, as would a forced script reload, but disconnecting I am not sure of. There was a bug that cropped up with that, but I am not sure if it was a premature script shutdown or a system conflict with the script trying to execute while the client was still busy with a dialog and couldn't respond to return codes, so not too sure what happens in that case.

Item 4: Umm. I think so. Try it and see. I haven't really had a situation where I needed to, so haven't tried.

Item 5: High speed?? Well Magnum has a page with a number of things he has done. I may in the future, though I may need to find someone besides Yahoo to host it now that they no longer support direct FTP of files to the page (or maybe that is from it... Not entirely sure). As for anyone else.. I couldn't say.
[Go to top] top

Posted by Magnum   Canada  (580 posts)  [Biography] bio
Date Reply #2 on Thu 02 May 2002 09:43 PM (UTC)
Message
3: I think Shadowfyr may be misleading you:

World.SetVariable
World.GetVariable
World.DeleteVariable

...are the two most often used commands to interact with MushClient variables. The variables initialize when you "World.SetVariable" for the first time. (You can also create a variable using the menu's). The variable will persist as long as you have the .MCL file for the world, and "save" when you close the client program. Check out the configuration for a box to flag, which turns on prompting to save variables on exit.

From the main Mushclient webpage here, look for a link called "List all functions" or something to that effect on the left side of the screen. List them all alphabetically. You can click the various commands for help on them.

4: Not directly, however, you can write a script subroutine, and have both the alias and trigger call the same subroutine.

5: I'm not highspeed (only 56k). I've posted my "Eq Handling script" at my website, and eventually I plan to post more. My website is very much outdated, and needs an update badly. The "muds" subpage was thrown together quickly as well. I plan to overhaul the whole site, as well as make a nice "mud scripts" page, but I've been putting it off till I have a lot of time on my hands.

Also, I haven't posted my entire 2000 line script there... What I am trying to do it break it up into "plug-in" scripts, however, there is some difficulty in that there are a core of variables that are used all over the place, so it's hard to "black box" them into subsections only. It's another thing I plan to do when I have more time.
For now, you can check out what I have to offer:
http://www.MagnumsWorld.com/muds/

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
[Go to top] top

Posted by Magnum   Canada  (580 posts)  [Biography] bio
Date Reply #3 on Thu 02 May 2002 09:50 PM (UTC)
Message
I'm sorry, it was me misleading you. Sometimes I think of mushclient variables as "Global", but it's me who has the syntax wrong.

Dim MyVariable

...Can be put outside the subroutine(s) to be considered global. It gets inititialized every time you load mushclient, when you re-save the script, or when you manually select "Game | Reload Script File" from the pulldown menu. I do not believe they get re-initialized if you disconnect, but keep the client loaded.

of course, putting the "Dim" statement INSIDE a subroutine makes it local to that subroutine only. ...Your standard programming rules, essentially.

If you want a variable to be persistant across multiple sessions, use "MushClient" variables, as I said in my earlier post.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
[Go to top] top

Posted by Magnum   Canada  (580 posts)  [Biography] bio
Date Reply #4 on Thu 02 May 2002 09:58 PM (UTC)
Message
One other tip, I find an excessive number of mushclient variables slows down my petty P166. I would advise using regular variables whenever possible, and only use MushClient variables when you really want the value to persist for as long as you have the world's file on your HD.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Fri 03 May 2002 01:57 AM (UTC)
Message
Quote:

2) Is it possible to print out a list of all triggers? Can this be done with a script maybe? It would make debugging and changing triggers much easier if I knew how to do this.


Try:


/world.debug "triggers"


Quote:

4) Is it possible to use a Trigger to fire an Alias? I could save quite a few redundant lines if I knew how to do this.


Not directly. The alias can call a script, and the trigger can call the same script (they both take 3 arguments) - you could do it that way.

- Nick Gammon

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

Posted by Jeffrey F. Pia   (49 posts)  [Biography] bio
Date Reply #6 on Fri 03 May 2002 04:33 AM (UTC)

Amended on Fri 03 May 2002 04:35 AM (UTC) by Jeffrey F. Pia

Message
Quote:
High speed??

Quote:
I'm not highspeed (only 56k).

LoL Sorry guys, "high speed" is a military term I use a lot to describe someone who knows what they're doing, or knows the subject-matter more in-depth than the average person. In other words, it was a reference to the techies of the group as opposed to the average user. :-)

Quote:
4) Is it possible to use a Trigger to fire an Alias? I could save quite a few redundant lines if I knew how to do this.

Sorry, I asked the wrong question here. What I meant to ask was:
4) Is it possible to use an Alias to fire another Alias? For example: I have and Alias "GOHOME" that takes a teleporter out of my bag, uses it, and puts it back in the bag. I have several speedwalk Aliases that start from my "home" position. Instead of manually calling both Aliases, I wanted to use "GOHOME" as the first command in my speedwalk Aliases, but it doesn't seem to work that way. It is sending the actualy text to the MUD instead of firing the Alias. Any ideas?

Thanks for all the help guys! Nick, this is a great app. I love programming, and that aspect of MUSHclient enhances my MU* experience exponentially! Keep up the good work. Magnum, I am checking out your script file as we speak and am learning a lot, especially regarding the uses of multiple scripte files. I read the thread on that topic, but couldn't figure out how to implement it until I read your code. Thanks! Shadow, I am looking forward to checking out your site when you get it up and running. :-)
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Fri 03 May 2002 05:39 AM (UTC)
Message
It is funny, the more I answer questions here the more I realise you can do things I never thought of before. I just answered a question about how to send the same command to all worlds (via an alias) which I had never tried before.

As for the alias from an alias, an idea occurred to me that seems to work pretty well...

1. Make a variable to do what you want to go home, whatever that is. eg.


Variable name: gohome

Contents:
open bag
get teleporter
use teleporter
put teleporter in bag
close bag


2. Make aliases as appropriate, checking the "expand variables box...

eg.


Alias: gohome
Send: @gohome
Expand variables: checked


3. Do the same for speedwalks, except put the action in brackets, as speed walks require ...

eg.


Alias: gohome_and_shop
Send: (@gohome)4w 3e 4s
Speed walk: checked
Expand variables: checked

- Nick Gammon

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

Posted by Jeffrey F. Pia   (49 posts)  [Biography] bio
Date Reply #8 on Fri 03 May 2002 03:58 PM (UTC)
Message
It works GREAT! Thanks again for all your help!
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #9 on Fri 03 May 2002 05:27 PM (UTC)

Amended on Fri 03 May 2002 05:29 PM (UTC) by Shadowfyr

Message
Another less 'alias everything' method similar to what I use would be two aliases:

alias: gohome - For when you just want to go home, since aliases can't match on empty.
send: open bag
get teleporter
use teleporter
put teleporter in bag
close bag

alias: gohome *
send: nothing
label: gohnm
script: gohnm

sub gohnm (Alias, Output, Wildcards)
  dim Destin
  Destin = Wildcards(1)
  world.send "open bag"
  world.send "get teleporter"
  world.send "use teleporter"
  world.send "put teleporter in bag"
  world.send "close bag"
  select case Destin
    case "list"
      world.note "Put a list of places here to remind yourself."
    case "someplace" - Name of first place you want to go.
      world.send "w" - Your first movement.
      ...            - The rest of the moves.
    case else
      world.note "Not a know destination."
  end select
end sub


This is a lot easier to work with since you don't have to remember/sort through a bunch of aliases and every new area can have it's name added to the 'list', so if you do forget you can get a quick reminder. Just remember if you rename one to change it in both places (oops for me). ;)

You may be able to replace the world.send commands for each destination with evaluatespeedwalk, but there is little point to this, since it only returns a send string and due to the fact that scripts must finish executing 'before' the client can continue to do anything there is no direct means to send the speedwalk from inside the script with the correct delay. This could cause a few problems in some cases, but the most common one is buffer overloading making the descriptions for rooms dissappear. I fixed that by making sure that if I was goung to move 4 n, e, 5 se for instance I build the sends like so (Magnum's advice actually):

world.send "brief"
world.send "4 n"
world.send "e"
world.send "4 se"
world.send "brief"
world.send "1 se"

Assuming your mud has a similar command making it the first and second to last command should generally result in being able to see the full description of at least the last room you enter, even if the others are just a blur. ;)
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Fri 03 May 2002 10:44 PM (UTC)

Amended on Fri 03 May 2002 10:50 PM (UTC) by Nick Gammon

Message
Quote:

due to the fact that scripts must finish executing 'before' the client can continue to do anything there is no direct means to send the speedwalk from inside the script with the correct delay.


Actually, Shadowfyr, you can use Queue for that. Like this ...


world.queue world.evaluatespeedwalk ("4n"), true


Quote:

world.send "brief"
world.send "4 n"
world.send "e"
world.send "4 se"
world.send "brief"
world.send "1 se"


That's a great idea! However you can also do that with speedwalks, like this ...


world.queue world.evaluatespeedwalk ("(brief) 4n e 4(se) (brief) (se)"), true

- Nick Gammon

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

Posted by Jeffrey F. Pia   (49 posts)  [Biography] bio
Date Reply #11 on Mon 06 May 2002 04:57 PM (UTC)
Message
That's a great idea for tracking the millions (or atleast dozens) of speedwalks I use, Shadow. Thanks for the suggestion! Fortunately, my MUD already takes speedwalks into consideration. They offer a RUN command: RUN 4ne3dwu, which I think is great and eliminates any timing/buffer overrun issues that some MUDs have. Basically, I can enter my whole SW in one line with the only exceptions being if I needed to open any doors along the way. Open door commands, as far as I can tell, have to be sent on a separate line. Would it be possible to use evaluatespeedwalk to put the commands on one line? For instance:

world.queue world.evaluatespeedwalk ("(RUN 4ne3dwu) OW (RUN 3w2un)"), true


Or would I use the command stacking option? I didn't fully understand the help file on this topic.

One thing I did find interesting was the option of pressing Ctrl+D to cancel out remaining SW comands. Do you think it's possible (in a future version maybe) to have a function similar to evaluatespeedwalk, but for regular commands? I know of a few situations in which it would definitely be helpful. In combat for example, I occasionally send a list of spells using an Alias, only to find out halfway through the list that the mob is WAY too powerful for me, and is about to kill me! Since all the spell commands have already been sent to the MUD, there's not much I can do except wait it out and hope for the best. Sending the list in a timed interval, and being able to stop (or maybe just PAUSE) the list if needed, would be a great thing indeed.
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #12 on Mon 06 May 2002 08:36 PM (UTC)
Message
>That's a great idea! However you can also do that with speedwalks, like this ...

>world.queue world.evaluatespeedwalk ("(brief) 4n e 4(se) (brief) (se)"), true

Well... For Jeffrey using speedwalk would work, since he has the RUN option, but then it really isn't speedwalking, since the mud is handling it, not the client. For myself I found that the added delay needed to keep the buffer from overflowing was so great I could get most places moving my hand in the time it would take to speedwalk it. lol It was simpler for me to just send them individually and easier to fix bugs in the path.


To Jeffrey ->
>world.queue world.evaluatespeedwalk ("(RUN 4ne3dwu) OW (RUN 3w2un)"), true

This should work. Command stacking is as far as I know done in the command window only. I could be wrong though and admittedly have been often. ;) By using evaluatespeedwalk you are basically stacking them anyway, so it probably doesn't matter. Not sure what to do about the batch of spells problem you mention though... There is something to be said for having a delay in casting and being able to move and interrupt the spell(s) before they cast. Your mud seems to be a lot less forgiving of stupid mistakes as a result. ;)
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #13 on Tue 07 May 2002 03:02 AM (UTC)
Message
Quote:

Would it be possible to use evaluatespeedwalk to put the commands on one line? For instance:

world.queue world.evaluatespeedwalk ("(RUN 4ne3dwu) OW (RUN 3w2un)"), true


Yes, you could do that.


Quote:

Or would I use the command stacking option? I didn't fully understand the help file on this topic.


Command stacking is really for what you actually type. Then you can use a character (eg. ';') to break up one line into multiples, eg. north;kill dragon

Quote:

One thing I did find interesting was the option of pressing Ctrl+D to cancel out remaining SW comands.
Do you think it's possible (in a future version maybe) to have a function similar to evaluatespeedwalk, but for regular commands?


You could probably script that, assuming your command didn't contain "(" or ")", to take a command split it up (say, at a semicolon), and then queue them up. In fact, for single commands, a straight alias would do it.

For instance, the alias:


Alias: *
Send: %0
Queue command: checked


That would effectively queue everything you typed, so that you could cancel it, assuming your speedwalk delay is greater than zero.

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


26,339 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]