[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]  Simple kill alias
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Simple kill alias

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


Pages: 1  2 3  4  

Posted by Nick Gammon   Australia  (21,493 posts)  [Biography] bio   Forum Administrator
Date Reply #15 on Fri 16 Sep 2011 06:06 AM (UTC)
Message
Here is an example:


<triggers>
  <trigger
   enabled="y"
   group="Tests"
   keep_evaluating="y"
   match="^M - (.*)"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
local monsters = utils.split ("%1", ",")

for k, v in ipairs (monsters) do
  Execute ("autokill " .. Trim (v))
end -- for

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



Testing:


M - wolf, adder, adder
autokill wolf
autokill adder
autokill adder
M - werewolf, zombie
autokill werewolf
autokill zombie
M - wolf, wolf, troglodyte
autokill wolf
autokill wolf
autokill troglodyte
M - troll
autokill troll


- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,493 posts)  [Biography] bio   Forum Administrator
Date Reply #16 on Fri 16 Sep 2011 06:08 AM (UTC)
Message
Or a bit shorter:


<triggers>
  <trigger
   enabled="y"
   group="Tests"
   match="M - *"
   send_to="12"
   sequence="100"
  >
  <send>

for k, v in ipairs (utils.split ("%1", ",")) do
  Execute ("autokill " .. Trim (v))
end -- for

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


- Nick Gammon

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

Posted by Blixel   (54 posts)  [Biography] bio
Date Reply #17 on Fri 16 Sep 2011 09:06 AM (UTC)
Message
Thanks again Nick. I'll test out these new ideas. Here's what I'm using at the moment, which seems to work? (This is just the relevant section.)

moblist = wait.regexp ("^M\ -\ (.*)", 1)
local mob = nil    
roomcleared = false
for mob in string.gmatch (moblist, "%a+") do

  local x = nil

  if not (mob == "M") then
    while not (x or giveup) do
      Send ("kill ", mob)
      x = wait.regexp ("^The .* (is slain!)|(flees in panic!)|(^There is no .* here\.)|(^You can\'t attack yourself!)", 1.2)
    end -- while

    -- After a kill, we send a short wait to
    -- prevent a "One moment please" message
    -- from coming up.
    wait.time (0.5)

  end -- end if
end -- for



I'm going to use your new ideas to see if I can get rid of that if not (mob == "M") check. I feel like that shouldn't be in the list in the first place.

Is this regular expression the best for my mob line?
^M\ -\ (.*)

Should there be a question mark or a dollar sign in there somewhere?

[Go to top] top

Posted by Blixel   (54 posts)  [Biography] bio
Date Reply #18 on Fri 16 Sep 2011 09:46 AM (UTC)
Message
Nick Gammon said:



M - wolf, adder, adder
autokill wolf
autokill adder
autokill adder
M - werewolf, zombie
autokill werewolf
autokill zombie
M - wolf, wolf, troglodyte
autokill wolf
autokill wolf
autokill troglodyte
M - troll
autokill troll



How are you cutting off the "M - " part?

In my testing, I'm getting this:

ou have come to an intersection in the trail. To the south is a small cave,
with a sign over the opening that reads:"Scariton".

............
-----dn-----
 M   x    
[][]    [][]
  [] $  []
  []    []

M - frostbat

>kill M - frostbat
There is no M here.


If a room has two monsters, it will error on the first one, and the kill the second one.

You are at another bend in the trail. The makers of this path appear to have
been uncertain as to which way they wanted to go.

[]  |.......
[]  |.......
[]M |.......
[]  --------
[] x   $      
[][][][][][]

M - brigand, icetoad

>kill M - brigand
There is no M here.
>kill icetoad
You missed!


Here is my code.

if (readytokill) then

  readytokill = false
 
  require "wait"

  wait.make (function ()
    
    -- This is our failsafe. With enough logic,
    -- this should never be needed. But just in
    -- case something goes sideways, we can type
    -- giveup to force our kill loop to stop.
    giveup = false

    -- Initialize moblist to nil
    local moblist = nil
 
    -- Have a look at the room to see if there is
    -- a line that starts with "M - ".
    Send ("look")

    -- If there is, that will become our list of
    -- mobs to kill.
    moblist = wait.regexp ("^M\ -\ (.*)", 1)

    moblist = utils.split (moblist, ",")
    
    if (moblist) then

    -- The ColourNote below is useful for following
    -- the logic. But it should be disabled for
    -- normal use.
    -- ColourNote ("white", "blue", moblist)


      -- Initialize mob variable to nil
      local mob = nil    
      roomcleared = false

      for k, mob in ipairs (moblist) do
      
        -- Initialize x variable to nil
        local x = nil

        -- The ColourNote below is useful for following
        -- the logic. But it should be disabled for
        -- normal use.
        ColourNote ("white", "blue", Trim (mob))
 
        -- Our main kill loop
        while not (x or giveup) do
          
          -- Keep hitting until the mob is
          -- dead or until the mob runs away.
          Send ("kill ", Trim (mob))

          -- So far we have 4 known reasons to
          -- quit hitting.
          -- 1.) Mob is slain!
          -- 2.) Mob has run away.
          -- 3.) We have stupidly tried to hit
          --     something that isn't there.
          -- 4.) We are trying to attack ourself!
          x = wait.regexp ("^The .* (is slain!)|(flees in panic!)|(^There is no .* here\.)|(^You can\'t attack yourself!)", 1.2)
          
        end -- while
        
        -- After a kill, we send a short wait to
        -- prevent a "One moment please" message
        -- from coming up.
        wait.time (0.5)

      
      end -- for

    else
      -- There was no "M - " line in the room, so 
      -- we'll just set the roomcleared variable to
      -- true and exit.
      roomcleared = true
      ColourNote ("white", "blue", "No mobs detected")
    end -- if (moblist)

     
    -- One of our conditions has been met.
    -- The mob was killed or it ran away.
    -- In either case, we are ready to kill
    -- again. So we set the readytokill
    -- variable back to true so this routine
    -- can be called again.
    readytokill = true
  
  end) -- end wait function

end -- end main if statement



[Go to top] top

Posted by Nick Gammon   Australia  (21,493 posts)  [Biography] bio   Forum Administrator
Date Reply #19 on Sat 17 Sep 2011 04:12 AM (UTC)
Message
Blixel said:

How are you cutting off the "M - " part?


Looking at the documentation for the wait module:

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

You had:


 -- If there is, that will become our list of
    -- mobs to kill.
    moblist = wait.regexp ("^M\ -\ (.*)", 1)


But wait.regexp returns 3 results:


  1. The matching line
  2. The wildcards (in a table)
  3. The style runs (in a table)


Since you are using the first result you are getting the entire matching line.

The first wildcard (the mob names) would be wildcards [1].

eg.


    line, wildcards = wait.regexp ("^M\ -\ (.*)", 1)
    if line then
      moblist = wildcards [1]

      ...

    end -- if


- Nick Gammon

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

Posted by Blixel   (54 posts)  [Biography] bio
Date Reply #20 on Sat 17 Sep 2011 05:43 AM (UTC)
Message
Nick Gammon said:
But wait.regexp returns 3 results:

*The matching line
*The wildcards (in a table)
*The style runs (in a table)


Ah-ha. It took me a few minutes to get what you were talking about, but now I understand.

I finally have my general purpose autokill working exactly how I want. I can't really imagine a better way of doing this. (For this particular MUD.)

I need to set up a few exclusions, but that will be trivial I believe. (As an example, don't use this general purpose autokill for the undead. Let the Cleric turn undead and/or cast light.) Perhaps a table of exclusions. This general purpose autokill routine can then check the mob name to see if it shows up in the table. And if so, ignore mob and kill the next one on the list. Something like that. I'll figure that out later. Shouldn't be hard.


-- General purpose on/off switch for
-- the whole routine.
if (readytokill) then
  
  require "wait"

  wait.make (function ()
    
    -- This is our failsafe. With enough logic,
    -- this should never be needed. But just in
    -- case something goes sideways, we can type
    -- giveup to force our kill loop to stop.
    giveup = false

    -- Initialize moblist to nil
    local moblist = nil
 
    -- Have a look at the room to see if there is
    -- a line that starts with "M - ".
    Send ("look")

    -- If there is, that will become our list of
    -- mobs to kill.
    -- The line variable is returned by wait.regexp
    -- and will have the entire line, including the
    -- "M - " part. The wildcards variable will only
    -- include the wildcard part of our line, which
    -- in this case will be a comma separated string
    -- of monster names. (e.g. owl, wolf, icetoad)
    line, wildcards = wait.regexp ("^M\ -\ (.*)", 1)

    -- If wait.regexp didn't return a line, then there
    -- was no "M - " line in this room. Presumably,
    -- this would mean the room is clear of mobs.
    if (line) then

      -- If wait.regexp does return a line, then we
      -- set the moblist equal to the wildcards.
      moblist = wildcards [1]

      -- Initialize mob variable to nil. This is our
      -- general purpose variable name that we'll use
      -- as we step through the list of mob names.
      local mob = nil    

      -- Tells other triggers that may be
      -- watching that the room is not
      -- clear. There is killing to be done.
      roomcleared = false

      -- Split the monster list into a table
      moblist = utils.split (moblist, ",")

      -- Cycle through our monster table one
      -- mob at a time.
      for k, mob in ipairs (moblist) do
      
        -- Initialize x variable to nil
        local x = nil

        -- Our main kill loop
        while not (x or giveup) do
          
          -- Keep hitting until the mob is
          -- dead or until the mob runs away.
          -- The Trim function removes white space
          -- around the monster name. So we will
          -- "kill owl" as opposed to "kill  owl "
          Send ("kill ", Trim (mob))

          -- So far we have 6 known reasons to
          -- quit hitting.
          -- 1.) Mob is slain!
          -- 2.) Mob has run away.
          -- 3.) We have specified an invalid target.
          -- 4.) We are trying to attack ourself!
          -- 5.) We are trying to attack inside a town.
          -- 6.) We did not specify a target.
          x = wait.regexp ("^The .* (is slain!)|(flees in panic!)|(^There is no .* here\.$)|(^You can\'t attack yourself!$)|(^A being clothed in white appears before you\.$)|(^Do what\.?$)", 1.5)
          
        end -- while
        
        -- After a kill, we send a short wait to
        -- prevent a "One moment please" message
        -- from coming up.
        wait.time (0.75)

      end -- for

    else
      -- There was no "M - " line in the room
      -- ColourNote here for troubleshooting only
      -- ColourNote ("white", "blue", "No mobs detected")
    end -- if (moblist)

     
    -- One of our conditions has been met.
    -- The mob was killed or it ran away.
    -- In either case, we are ready to kill
    -- again. So we set the readytokill
    -- variable back to true so this routine
    -- can be called again.
    readytokill = true
  
  end) -- end wait function

end -- end main if statement


[Go to top] top

Posted by Blixel   (54 posts)  [Biography] bio
Date Reply #21 on Sun 18 Sep 2011 10:57 AM (UTC)

Amended on Sun 18 Sep 2011 11:04 AM (UTC) by Blixel

Message
First, I want to say that I am highly appreciative of how patient and helpful you guys have been. This forum has been one of the friendliest places I've ever visited. Very impressive.

So, thanks again.


I have another question about this kill routine. As elegant as it is (at least, that's how I feel about it), it has one shortcoming.

Sometimes a monster will enter the room after you've cleared the room. When the monster comes in, the game gives the name of the monster. The text is always in this format:

>A wererat appears suddenly and attacks!


Or, in terms of a regular expression, it's always in this format:

^\>?A (.*?) appears suddenly and attacks\!$


Did I get the regular expression right finally? Is it (.*?) or should it just be *?

At any rate, since we know the name of the monster, there is no reason to Send ("look") in order to get the "M - *" line.

My thinking was to split the kill routine into two pieces. The first piece would get the moblist and then kill the monsters in a for loop like this (I'm cutting out all my comments to make it more concise):

require "wait"

wait.make (function ()
  moblist = nil
  Send ("look")

  line, wildcards = wait.regexp ("^M\ -\ (.*)", 1)

  if (line) then
    moblist = wildcards [1]
    mob = nil
    roomcleared = false
    moblist = utils.split (moblist, ",")

    for k, mob in ipairs (moblist) do
      Execute ("autokill " .. Trim (mob))
    end

    roomcleared = true

  end -- if (line)
end) -- wait


The advantage of doing it this way is that the autokill part of the script can now accept an argument.

if (readytokill) then

  readytokill = false
 
  require "wait"
  wait.make (function ()
    giveup = false
    local x = nil
    while not (x or giveup) do
      Send ("kill %1")

      -- So far we have 6 known reasons to
      -- quit hitting.
      -- 1.) Mob is slain!
      -- 2.) Mob has run away.
      -- 3.) We have specified an invalid target.
      -- 4.) We are trying to attack ourself!
      -- 5.) We are trying to attack inside a town.
      -- 6.) We did not specify a target.
      x = wait.regexp ("^The .* (is slain!)|(flees in panic!)|(^There is no .* here\.$)|(^You can\'t attack yourself!$)|(^A being clothed in white appears before you\.$)|(^Do what\.?$)", 1.2)
          
    end -- while
        
    wait.time (0.5)
    readytokill = true
  
  end) -- end wait function

end -- end main if statement


So now, when this happens:

^\>?A (.*?) appears suddenly and attacks\!$


I can have that trigger: Execute ("autokill %1")

...without having to Send ("look")

It cuts down on screen scrolling big time.

The problem I'm running into is that my for loop isn't working. It kills the first mob in the list, and then stops.

Is that due to the fact that computers are fast and networks are slow?

My other idea is to make the original autokill script accept an argument. And then wrap it up in an If-Then statement. If an argument was given then behave this way ... if no argument was given, behave the other way. But in looking at the code, it seems like that would be more difficult ... and possibly more sloppy.

[Go to top] top

Posted by Nick Gammon   Australia  (21,493 posts)  [Biography] bio   Forum Administrator
Date Reply #22 on Sun 18 Sep 2011 12:26 PM (UTC)
Message
Quote:

Did I get the regular expression right finally? Is it (.*?) or should it just be *?


Template:regexp Regular expressions
  • Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
  • Also see how Lua string matching patterns work, as documented on the Lua string.find page.


The brackets make a capture group.

I would use either:


.*


That matches "anything, greedy".

or:


.*?


That matches "anything, not greedy".

Look on the regexp page for the difference between greedy and non-greedy.

So meanwhile:


(.*)


Is a greedy capture group. (ie. it becomes %1, %2 or whatever).

Which of those is best depends on what you want.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,493 posts)  [Biography] bio   Forum Administrator
Date Reply #23 on Sun 18 Sep 2011 12:29 PM (UTC)
Message
Quote:

The problem I'm running into is that my for loop isn't working. It kills the first mob in the list, and then stops.

Is that due to the fact that computers are fast and networks are slow?


I don't see anything there that makes it loop and look for another mob. Yes, computers are faster than networks. But I don't think this is the exact problem here.

- Nick Gammon

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

Posted by Blixel   (54 posts)  [Biography] bio
Date Reply #24 on Sun 18 Sep 2011 01:16 PM (UTC)
Message
Nick Gammon said:

(regexp)

The brackets make a capture group.


Ok. I'm pretty sure I get that part now. Parenthesis make it a capture group. I need it to be a capture group in that case, so I do need the parenthesis.



.*?


That matches "anything, not greedy".

Look on the regexp page for the difference between greedy and non-greedy.

I read the page all the way down to the greedy part. The first use of the ? mark I do understand.

12345? would match 1234 and it would match 12345. The 5 is optional. It wouldn't match 123 or 123456. 123 is missing the required 4, and 123456 has an extra 6 on the end.

So .*? matches everything between two points.

The .*? is attacking you.

The dog is attacking you. Matches.
The big dog is attacking you. Matches.
The really big dog is attacking you. Matches.
The big ferocious dog with snarling teeth is attacking you. Matches.
The dog seems tame. But looks can be deceiving. Upon closer inspection, you realize the dog has red glowing eyes. Before you know it, the wild animal lunges forth. Run for you life! The beast is attacking you. Matches.

And in all those cases, if we were to put the .*? in parenthesis, then everything between 'The' and 'is attacking you.' would become %1

In the last example, %1 = "dog seems tame. But looks can be deceiving. Upon closer inspection, you realize the dog has red glowing eyes. Before you know it, the wild animal lunges forth. Run for you life! The beast"

And if the question mark isn't there...

The .* is attacking you.

Then all those examples still apply anyway. So I guess the point is, there's zero difference between greedy and non-greedy in this application.
[Go to top] top

Posted by Blixel   (54 posts)  [Biography] bio
Date Reply #25 on Sun 18 Sep 2011 01:19 PM (UTC)
Message
Nick Gammon said:

Quote:

The problem I'm running into is that my for loop isn't working. It kills the first mob in the list, and then stops.

Is that due to the fact that computers are fast and networks are slow?


I don't see anything there that makes it loop and look for another mob. Yes, computers are faster than networks. But I don't think this is the exact problem here.


Isn't this a loop?


for k, mob in ipairs (moblist) do
  Execute ("autokill " .. Trim (mob))
end
[Go to top] top

Posted by Nick Gammon   Australia  (21,493 posts)  [Biography] bio   Forum Administrator
Date Reply #26 on Sun 18 Sep 2011 08:51 PM (UTC)
Message
Hmm, yes. Can you paste the whole aliases so I can test them?

Template:copying For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.

- Nick Gammon

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

Posted by Blixel   (54 posts)  [Biography] bio
Date Reply #27 on Mon 19 Sep 2011 03:32 AM (UTC)

Amended on Mon 19 Sep 2011 05:45 AM (UTC) by Blixel

Message
Nick Gammon said:
Hmm, yes. Can you paste the whole aliases so I can test them?


Sorry about all the comments. :) I'm paranoid about forgetting what stuff does.

Here is some input text:

M - wolf, adder, adder
M - werewolf, zombie
M - wolf, wolf, troglodyte
M - troll


This alias gets the monster list and sends the list of monsters (using a for loop) to the second alias.

<aliases>
  <alias
   name="GetMobList"
   match="getmoblist"
   enabled="y"
   group="Get Monster List"
   send_to="12"
   sequence="100"
  >
  <send>require "wait"

wait.make (function ()
    
  -- Initialize moblist to nil
  moblist = nil
 
  -- Have a look at the room to see if there is
  -- a line that starts with "M - ".
  Send ("look")

  -- If there is, that will become our list of
  -- mobs to kill.
  -- The line variable is returned by wait.regexp
  -- and will have the entire line, including the
  -- "M - " part. The wildcards variable will only
  -- include the wildcard part of our line, which
  -- in this case will be a comma separated string
  -- of monster names. (e.g. owl, wolf, icetoad)
  line, wildcards = wait.regexp ("^M\ -\ (.*)", 1)

  -- If wait.regexp didn't return a line, then there
  -- was no "M - " line in this room. Presumably,
  -- this would mean the room is clear of mobs.
  if (line) then

    -- If wait.regexp does return a line, then we
    -- set the moblist equal to the wildcards.
    moblist = wildcards [1]

    -- Initialize mob variable to nil. This is our
    -- general purpose variable name that we'll use
    -- as we step through the list of mob names.
    mob = nil

    -- Tells other triggers that may be
    -- watching that the room is not
    -- clear. There is killing to be done.
    roomcleared = false

    -- Split the monster list into a table
    moblist = utils.split (moblist, ",")

    -- Cycle through our monster table one
    -- mob at a time.
    -- The Trim function removes white space
    -- around the monster name. So we will
    -- "kill owl" as opposed to "kill  owl "
    for k, mob in ipairs (moblist) do
      Execute ("mobkillengine " .. Trim (mob))
    end

    -- Room should be free of mobs by now.
    roomcleared = true

  end -- if (line)

end) -- wait</send>
  </alias>
</aliases>


It is the intention to have this next alias process the list from the first one. (Or, to allow this next alias to stand alone with user input or other trigger text [see bottom for example of other trigger text].)

<aliases>
  <alias
   name="MobKillEngine"
   match="mobkillengine *"
   enabled="y"
   group="Kill Routines"
   send_to="12"
   keep_evaluating="y"
   sequence="100"
  >
  <send>-- If autokill is disabled, then forget this
-- whole routine. Presumably, autokill was
-- disabled so we can walk around without the
-- constant interruption of killing.

-- Also, if readytokill is disabled, then we
-- forget the whole routine as well. The main
-- reason readytokill would be disabled would
-- be due to the fact that we are Already
-- killing some other mob. We don't want our
-- killing to overlap, so when we start this
-- routine, we set readytokill to off so that
-- if it gets called a second time, the second
-- instance will just ignore it until the first
-- instance is done killing.

if (readytokill) then
--if (autokill and readytokill) then

  -- Autokill is on, and we are ready to kill.
  -- The first thing we do is set readytokill
  -- to false so another instance can't overlap. 
  readytokill = false
 
  require "wait"

  wait.make (function ()
    
    -- This is our failsafe. With enough logic,
    -- this should never be needed. But just in
    -- case something goes sideways, we can type
    -- giveup to force our kill loop to stop.
    giveup = false

    -- Initialize x variable to nil
    local x = nil

    -- Our main kill loop
    while not (x or giveup) do
          
      -- Keep hitting until the mob is
      -- dead or until the mob runs away.
      Send ("kill %1")

      -- So far we have 6 known reasons to
      -- quit hitting.
      -- 1.) Mob is slain!
      -- 2.) Mob has run away.
      -- 3.) We have specified an invalid target.
      -- 4.) We are trying to attack ourself!
      -- 5.) We are trying to attack inside a town.
      -- 6.) We did not specify a target.
      x = wait.regexp ("^The .* (is slain!)|(flees in panic!)|(^There is no .* here\.$)|(^You can\'t attack yourself!$)|(^A being clothed in white appears before you\.$)|(^Do what\.?$)", 1.2)
          
    end -- while
        
    -- After a kill, we send a short wait to
    -- prevent a "One moment please" message
    -- from coming up.
    wait.time (0.5)

    -- One of our conditions has been met.
    -- The mob was killed or it ran away.
    -- In either case, we are ready to kill
    -- again. So we set the readytokill
    -- variable back to true so this routine
    -- can be called again.
    readytokill = true
  
  end) -- end wait function

end -- end main if statement</send>
  </alias>
</aliases>


Here is other trigger text that makes splitting this routine into two pieces very useful. When a mob "appears suddenly", we don't need to look at the room. The game tells us the name of the mob. So if we look at the room again anyway, it just causes lots of extra screen scrolling.

<triggers>
  <trigger
   enabled="y"
   group="Monster List for Auto-Killing"
   match="^\&gt;?A (.*?) appears suddenly and attacks!$"
   name="MobAppearsSuddenly"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Execute ("mobkillengine %1")</send>
  </trigger>
</triggers>

[Go to top] top

Posted by Nick Gammon   Australia  (21,493 posts)  [Biography] bio   Forum Administrator
Date Reply #28 on Mon 19 Sep 2011 07:26 AM (UTC)
Message
Without actually testing it, I think this is the problem:


    -- Cycle through our monster table one
    -- mob at a time.
    -- The Trim function removes white space
    -- around the monster name. So we will
    -- "kill owl" as opposed to "kill  owl "
    for k, mob in ipairs (moblist) do
      Execute ("mobkillengine " .. Trim (mob))
    end


This alias spits out all the mobkillengine commands at once (there is no delay in that loop). So it would execute:


mobkillengine wolf
mobkillengine adder
mobkillengine adder


But you say later:


-- Also, if readytokill is disabled, then we
-- forget the whole routine as well. The main
-- reason readytokill would be disabled would
-- be due to the fact that we are Already
-- killing some other mob. We don't want our
-- killing to overlap, so when we start this
-- routine, we set readytokill to off so that
-- if it gets called a second time, the second
-- instance will just ignore it until the first
-- instance is done killing.


So you don't want to kill wolf, adder and adder all at once.

By splitting it into two aliases you have removed a crucial delay, that is, waiting for one mob to die before you attack another one.

- Nick Gammon

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

Posted by Blixel   (54 posts)  [Biography] bio
Date Reply #29 on Mon 19 Sep 2011 07:38 AM (UTC)
Message
Nick Gammon said:
Without actually testing it, I think this is the problem:

...

So you don't want to kill wolf, adder and adder all at once.

By splitting it into two aliases you have removed a crucial delay, that is, waiting for one mob to die before you attack another one.


I think you're right, and that was my suspicion from the start. My question was basically to ask if there was a way to make Execute ("mobkillengine %1") wait to finish before the loop would call it again.

And I think you're telling me the answer is no.

So my solution is going to have to be to have two separate aliases that do almost exactly the same thing.

One alias will look at the room, get a mob list, and loop through it ... killing one mob at a time.

The other alias will expect an argument. It will not look at the room and create a mob list. It will kill the mob that was passed in as an argument.

I guess it's not too bad. It will just duplicate the main kill routine. If I discover more reasons to quit hitting, I'll have to update it in both places.

Thanks for your input.
[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.


20,372 views.

This is page 2, subject is 4 pages long:  [Previous page]  1  2 3  4  [Next page]

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]