Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Multiple MOB and Influence Tracker
Multiple MOB and Influence Tracker
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Thuzle
(2 posts) Bio
|
Date
| Thu 24 Aug 2006 01:29 AM (UTC) |
Message
| "monk74904" a monk disciple in grey robes
"monk74869" a monk disciple in grey robes
"monk74940" a monk disciple in grey robes
"monk74145" a monk disciple in grey robes
Number of objects: 4
This is the main piece of information I need to work with in my mud. I currently have a trigger to pull the first monk into a kill variable (@prey) but I need to somehow keep track of which ones I have killed (Won or Lost)because they don't go away.
Once kept track of, the next step is to bring that screen up again, and have it check with an if statement agaisn't whats already been influenced.
That way I don't have to walk into a room of 10 Monks, check the numbers by hand to see which I've fought and when checking the list such as above, it will automatically select the one I haven't.
Last thing is a clear command for the array.
I am just not sure how to do this in MushClient. If anyone could give me some pointers? | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #1 on Thu 24 Aug 2006 05:00 AM (UTC) |
Message
| You'll need a script along the following lines:
influenced = {}
function PickTarget(n,o,wildcs,...)
local mob = string.lower(wildcs[1])
if not influenced[mob] then
SetVariable("prey", mob)
end
end
function SaveInfluenced(...)
local mob = string.lower(GetVariable("prey"))
influenced[mob] = true
end
On top of that you'll need two triggers: one to match on the output you quoted and call the PickTarget function with mob's id in the first wildcard, and another to match on whatever message is given when an influence succeeds or fails and call the SaveInfluenced function. | Top |
|
Posted by
| Thuzle
(2 posts) Bio
|
Date
| Reply #2 on Fri 25 Aug 2006 12:40 AM (UTC) |
Message
| Thank you for the information. I'm not very proficent with scripting or coding, but can find my way eventually.
I wanted to input the script as either VB or Lua.
I'm getting most of the information from the script, but don't get all the items inside PickTarget() or the extra dots in SaveInfluenced.
This script is nice and will allow me to use the SaveInfluenced bit to colour the numbers of those influenced as well on a successive IH.
Help me understand the (...) and what needs to be in PickTarget and why? | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #3 on Fri 25 Aug 2006 07:25 AM (UTC) |
Message
| The script is in Lua, and the "(...)" means that the function can take any number of arguments (including no arguments at all). It allows that function to be conveniently called from either a trigger or a script.
The pick target must be called by the mob trigger. The one that matches on the: ""monk74904" a monk disciple in grey robes" lines. The only requirement is that "monk6354" (without quotes) is in the first captured wildcard. So the trigger might look like:
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #4 on Fri 25 Aug 2006 07:33 AM (UTC) Amended on Fri 25 Aug 2006 07:34 AM (UTC) by Nick Gammon
|
Message
|
Quote:
The script is in Lua, and the "(...)" means that the function can take any number of arguments (including no arguments at all).
However in your example, the ... is not necessary because you are not using the optional arguments. Lua will happily accept more or less arguments than the function defines.
For example, supplying too few arguments:
function foo (a, b)
print (a,b)
end -- foo
foo (1) --> 1 nil
You can also supply too many arguments:
function foo (a, b)
print (a,b)
end -- foo
foo (1, 2, 3) --> 1 2
In this case the 3 is discarded.
However if you want to use the ... construct, then everything from ... onwards is put into the local "arg" table, like this:
function foo (...)
table.foreach (arg, print)
end -- foo
foo (42, "nick", "gammon", 12345)
Output
1 42
2 nick
3 gammon
4 12345
n 4
You can see from this that arg is a table comprising the 3 arguments in numeric order (argument 1 is 42), and also an extra entry "n" which tells you how many arguments were supplied in the first place. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #5 on Fri 25 Aug 2006 07:58 AM (UTC) |
Message
| But I find (...) to be more descriptive of what's intended: allow the function to be called from both triggers and scripts without arguments. I use empty parameter lists for functions to be called only from the script, and it's very helpful in distinguishing how what is called by just glancing over the code.
And I never let functions that can be called both ways accept any meaningful arguments, since that leads to needing awkward decision-making code within the function's body.
| 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,367 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top