Script to sense multiple mobs after one fails

Posted by Traz on Wed 17 Jan 2018 12:17 AM — 9 posts, 29,010 views.

#0
I'm trying to make a script to sense a new mob after I've failed to sense another mob already. Here's the setup:

sense mob1

returns: That mob does not exist, cannot be sensed, or there is no path to them.

trigger then sends: sense mob2

if it succeeds, the trigger stops, but if it fails with "That mob does not exist, cannot be sensed, or there is no path to them." again then it tries "sense mob3" and so on.

Is it possible?
Australia Forum Administrator #1
It would be possible, yes. I would have a table of mobs, eg.


mobs = { "mob1", "mob2", "mob3" }


Then sense the first one, and if you get that message, add 1 to the counter and sense another one. Something like this ...

An alias to start the process:


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

mobs = { "mob1", "mob2", "mob3" }

mobs_index = 1

Send ("sense " .. mobs [mobs_index])  -- sense first one

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


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


And the trigger to catch the un-sensed mob:


<triggers>
  <trigger
   enabled="y"
   match="That mob does not exist, cannot be sensed, or there is no path to them."
   send_to="12"
   sequence="100"
  >
  <send>

if mobs_index &gt;= #mobs then
  ColourNote ("lime", "", "No more mobs to sense")
  return
end -- if

mobs_index = mobs_index + 1  -- next mob

Send ("sense " .. mobs [mobs_index])  -- sense next one

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

#2
How do I get the trigger to see the table of mobs?
Amended on Wed 17 Jan 2018 04:03 AM by Traz
Australia Forum Administrator #3
It just does, it's in the same script space. However if the trigger fired before you used the alias it wouldn't work.

These are global variables.

I assume you would use the alias first, and that establishes the mobs table in global script space, which the trigger then uses.
#4
It wasn't working because I hadn't yet used the alias. But now my other sense alias is getting interrupted by this one. Is it possible to set a client variable to a local variable?

I tried SetVariable ("sensed" , "mobs") but that didn't work and it's difficult to search for these terms on the forum.
Australia Forum Administrator #5
What other sense alias?

You don't have to call the alias "sense", you can call it "foo" if you like.

Quote:

Is it possible to set a client variable to a local variable?


Yes, you can do something like:


SetVariable ("counter", my_counter)


That puts the local variable my_counter into the client variable "counter" (as a string).
#6
Ok, I have an alias that works with a trigger.


<aliases>
  <alias
   match="sense *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable ("sensed" , "%1")
Send ("sense %1")</send>
  </alias>
</aliases>



<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   match="You concentrate and sense their ki * of here."
   sequence="100"
  >
  <send>sense @sensed</send>
  </trigger>
</triggers>


Together, these make it so when I sense something, I move in that direction and keep going until I'm in the same room with whatever I'm sensing. I need to be able to set the current value of the mobs table to @sensed if possible to make this all work smoothly.

And thank you so much for your help so far, I've been learning and playing around a lot but there's still stuff that I can't wrap my head around on my own.
Australia Forum Administrator #7
Yes, but you mentioned going onto other mobs in your original question. What other mobs would you be wanting to sense if your original alias only senses one?
#8
There are multiple mobs in an area and if one type of mob is all dead, they can't be sensed any longer. When a sense succeeds, I have it set up to keep sensing that mob until I find it. I'm trying to get this to work in that same way and so far the "sense" alias we made here does the initial sense and my trigger can take care of the rest if the @sensed variable matches what the current mob table value is.