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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Script to sense multiple mobs after one fails

Script to sense multiple mobs after one fails

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


Posted by Traz   (31 posts)  [Biography] bio
Date Wed 17 Jan 2018 12:17 AM (UTC)
Message
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?
[Go to top] top

Posted by Nick Gammon   Australia  (22,980 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Wed 17 Jan 2018 02:16 AM (UTC)
Message
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>


- Nick Gammon

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

Posted by Traz   (31 posts)  [Biography] bio
Date Reply #2 on Wed 17 Jan 2018 03:49 AM (UTC)

Amended on Wed 17 Jan 2018 04:03 AM (UTC) by Traz

Message
How do I get the trigger to see the table of mobs?
[Go to top] top

Posted by Nick Gammon   Australia  (22,980 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 17 Jan 2018 04:13 AM (UTC)
Message
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.

- Nick Gammon

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

Posted by Traz   (31 posts)  [Biography] bio
Date Reply #4 on Wed 17 Jan 2018 04:32 AM (UTC)
Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,980 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Wed 17 Jan 2018 06:14 AM (UTC)
Message
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).

- Nick Gammon

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

Posted by Traz   (31 posts)  [Biography] bio
Date Reply #6 on Wed 17 Jan 2018 06:32 AM (UTC)
Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,980 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Wed 17 Jan 2018 06:53 AM (UTC)
Message
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?

- Nick Gammon

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

Posted by Traz   (31 posts)  [Biography] bio
Date Reply #8 on Wed 17 Jan 2018 07:08 AM (UTC)
Message
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.
[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.


17,248 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]