how do i repeat a command in VB script?

Posted by Babochka on Sat 27 May 2006 06:32 AM — 7 posts, 34,027 views.

USA #0
Hello

I'm Babochka and I love to play Achaea as Cymru, a Rajamalan Druid. Druids can harvest herbs which they use to brew elixirs.

I may come into a room and see the following:

The following plants are growing in this room:
A ginseng plant (ginseng) 26 left.
A myrrh bush (myrrh bush) 11 left.
A lobelia wildflower (lobelia) 21 left.
A purple coneflower (echinacea) 13 left.
A red elm tree (red elm) 20 left.
A wild ginger plant (wild ginger) 39 left.

I need to harvest the ginseng. What I would do is type 'harvest ginseng' 14 times! Can't I create an alias or something like:

harvest * *

for w = 1 to %1
harvest %2
next w

i would enter harvest 14 ginseng and it would harvest 14 ginseng with typing it 14 times

Can you help me? Thanks.

USA #1
Well, The wildcards need to be separated, since the two of them together like that amkes it impossible for MUSH to determine between the two.

My suggestion is something like this:

harvest *|*

then set it to send to script...

dim w

for w = 1 to %1
world.send "harvest %2"
next


Use: harvest 10|ginseng
Australia Forum Administrator #2
For one thing, you can type Ctrl+R to repeat the last command, so you only need to type "harvest ginseng" once, and then hit Ctrl+R to keep doing it.

You can easily make an alias to to the "repeat n times" idea as well.
Australia Forum Administrator #3
Also read this post, it discusses a number of ways of doing it:

http://www.gammon.com.au/forum/?bbsubject_id=3311
Australia Forum Administrator #4
So as that post said (amongst other ideas), if you have speedwalking enabled, and "#" as your speedwalk prefix, all you would have to type is:

#14 (harvest ginseng)
USA #5
Which is actually more characters to type than the alias idea. :P
Australia Forum Administrator #6
Yes, well I was demonstrating how you could do it without even needing an alias.

This alias here requires less typing again. For example, the "|" will be a pain to type:


<aliases>
  <alias
   match="^h (\d+) (\w+)$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
for i = 1 to %1
  Send "harvest %2"
next
</send>
  </alias>
</aliases>


Now you just type: h 5 ginseng