Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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.
Entire forum
➜ MUSHclient
➜ Getting Started
➜ Making a script to count mobs killed
Making a script to count mobs killed
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2 3
Posted by
| WizardsEye
(24 posts) Bio
|
Date
| Reply #15 on Tue 24 Feb 2009 09:16 AM (UTC) |
Message
| Yes, that works...a bit to well. After I cleared it. It won't record any kills now. Tried restarting the client. Tried recreating it too. No luck. | Top |
|
Posted by
| Nick Gammon
Australia (23,072 posts) Bio
Forum Administrator |
Date
| Reply #16 on Tue 24 Feb 2009 06:32 PM (UTC) |
Message
| I don't see why that would happen, unless you somehow removed something important from the plugin. Is the trigger firing? It needs to, to count kills. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| WizardsEye
(24 posts) Bio
|
Date
| Reply #17 on Tue 24 Feb 2009 07:58 PM (UTC) |
Message
| It doesn't appear like it is. Here's what I have.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Tuesday, January 08, 2008, 3:26 -->
<!-- MuClient version 4.20 -->
<!-- Plugin "Count_Mobs_Killed" generated by Plugin Wizard -->
<muclient>
<plugin
name="Count_Mobs_Killed"
author="Nick Gammon"
id="f11e3bb0e48d526152798439"
language="Lua"
purpose="Counts how many mobs I have killed"
save_state="y"
date_written="2008-01-08 15:17:18"
requires="4.00"
version="1.0"
>
<description trim="y">
<![CDATA[
Counts how many mobs have been killed.
Type "show_killed" to see a count.
]]>
</description>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
custom_colour="2"
enabled="y"
match="* is DEAD!!"
send_to="12"
sequence="100"
>
<send>killed_mobs = killed_mobs or {} -- make mobs table
mob_name = "%1" -- this mob's name (first wildcard)
-- add this mob if first time
killed_mobs [mob_name] = killed_mobs [mob_name] or { count = 0 }
-- add 1 to count of mobs
killed_mobs [mob_name].count = killed_mobs [mob_name].count + 1
-- remember when we last killed it
killed_mobs [mob_name].last_time = os.time ()
</send>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
match="show_killed"
enabled="y"
send_to="12"
sequence="100"
>
<send>if not killed_mobs or next (killed_mobs) == nil then
ColourNote ("white", "blue", "No mobs killed yet")
return
end -- if nothing
-- go through each one
count = 0
for k, v in pairs (killed_mobs) do
Note (string.format ("%%-30s x %%i (last at %%s)",
k,
v.count,
os.date ("%%H:%%M %%d %%b %%Y", v.last_time)))
count = count + v.count
end -- for loop
-- show total
Note (string.format ("%%5i mobs killed.", count))</send>
</alias>
</aliases>
<aliases>
<alias
match="reset_mob_counts"
enabled="y"
send_to="12"
sequence="100"
>
<send>
killed_mobs = {} -- clear mobs table
</send>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
-- on plugin install, convert variable into Lua table
function OnPluginInstall ()
require "serialize" -- needed to serialize table to string
killed_mobs = {} -- ensure table exists, if not loaded from variable
assert (loadstring (GetVariable ("killed_mobs") or "")) ()
end -- function OnPluginInstall
-- on saving state, convert Lua table back into string variable
function OnPluginSaveState ()
SetVariable ("killed_mobs", "killed_mobs = " ..
serialize.save_simple (killed_mobs))
end -- function OnPluginSaveState
]]>
</script>
<!-- Plugin help -->
<aliases>
<alias
script="OnHelp"
match="Count_Mobs_Killed:help"
enabled="y"
>
</alias>
</aliases>
<script>
<![CDATA[
function OnHelp ()
world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script>
</muclient>
| Top |
|
Posted by
| Nick Gammon
Australia (23,072 posts) Bio
Forum Administrator |
Date
| Reply #18 on Wed 25 Feb 2009 12:27 AM (UTC) |
Message
| Can you copy and paste some of the MUD output that happens when something dies? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| WizardsEye
(24 posts) Bio
|
Date
| Reply #19 on Wed 25 Feb 2009 06:11 AM (UTC) |
Message
| Sure can, It was working just fine before I did the count reset.
Snow crab claws you.
Snow crab pinches you.
You got 1245 xp.
Snow crab died horribly.
Snow crab dies. | Top |
|
Posted by
| Nick Gammon
Australia (23,072 posts) Bio
Forum Administrator |
Date
| Reply #20 on Wed 25 Feb 2009 06:17 AM (UTC) |
Message
| The trigger match is:
There is no way that will match any of what you posted.
You need to change it to:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| WizardsEye
(24 posts) Bio
|
Date
| Reply #21 on Wed 25 Feb 2009 06:46 AM (UTC) |
Message
| GAH! I had forgotten I had changed that. sigh | Top |
|
Posted by
| Dfmalh
(3 posts) Bio
|
Date
| Reply #22 on Tue 01 Sep 2009 09:55 PM (UTC) |
Message
| Hi, I just started to give Triggers, Aliases, etc a try, so I am very much a newbie...
I followed the example and I get the trigger working as well as the "tprint" module. Here is the output for "/tprint (killed_mobs)":
"the wyvern":
"count"=1
"last_time"=function: 00D6FCD8
"the goblin":
"count"=8
"last_time"=function: 00D6FCD8
I follow the example further, but run into problems after I have configured and added the alias. I get the following output for "show_killed"
Run-time error
World: WaterdeepMUD - CharName
Immediate execution
[string "Alias: "]:13: bad argument #2 to 'date' (number expected, got function)
stack traceback:
[C]: in function 'date'
[string "Alias: "]:13: in main chunk
I do not know what is wrong, some thing with the date argument?
| Top |
|
Posted by
| Nick Gammon
Australia (23,072 posts) Bio
Forum Administrator |
Date
| Reply #23 on Tue 01 Sep 2009 11:01 PM (UTC) |
Message
| Hmmm - can you post what you did please?
|
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
|
Quote:
"last_time"=function: 00D6FCD8
Offhand, this looks like are storing a function, not a function result. For example, this might do it:
That stores a function, whereas you want:
Note the brackets. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Dfmalh
(3 posts) Bio
|
Date
| Reply #24 on Wed 02 Sep 2009 01:17 PM (UTC) |
Message
| Hi Nick, thanks for the quick response.
Sorry I jumped into my problem without enough background...
I am following the "Making a script to count mobs killed" example/tutorial that can be found here:
I basically cut and past the code from the website into MC.
As I said before, I get the trigger working as well as activate the "tprint" module. Here is the code:
killed_mobs = killed_mobs or {} -- make mobs table
mob_name = "%1" -- this mob's name (first wildcard)
-- add this mob if first time
killed_mobs [mob_name] = killed_mobs [mob_name] or { count = 0 }
-- add 1 to count of mobs
killed_mobs [mob_name].count = killed_mobs [mob_name].count + 1
-- remember when we last killed it
killed_mobs [mob_name].last_time = os.time
And here is the output for "/tprint (killed_mobs)":
Quote:
"the wyvern":
"count"=1
"last_time"=function: 00D6FCD8
"the goblin":
"count"=8
"last_time"=function: 00D6FCD8
So everything up to here works. I follow the example further. But run into problems after I have configured and added the alias. Here is my Alias code:
if not killed_mobs or next (killed_mobs) == nil then
ColourNote ("white", "blue", "No mobs killed yet")
return
end -- if nothing
-- go through each one
count = 0
for k, v in pairs (killed_mobs) do
Note (string.format ("%%-30s x %%i (last at %%s)",
k,
v.count,
os.date ("%%H:%%M %%d %%b %%Y", v.last_time)))
count = count + v.count
end -- for loop
-- show total
Note (string.format ("%%5i mobs killed.", count))
With this code I get the following output for "show_killed":
Quote:
Run-time error
World: WaterdeepMUD - CharName
Immediate execution
[string "Alias: "]:13: bad argument #2 to 'date' (number expected, got function)
stack traceback:
[C]: in function 'date'
[string "Alias: "]:13: in main chunk
I hope I have explained my problem a little better. Hmmm, as an after thought, I use Mc through Wine on Ubuntu. My other trigers (Drink water and Show Exits, also from you website works fine). | Top |
|
Posted by
| Bast
(78 posts) Bio
|
Date
| Reply #25 on Wed 02 Sep 2009 06:04 PM (UTC) |
Message
|
Dfmalh said:
-- remember when we last killed it
killed_mobs [mob_name].last_time = os.time
os.time should be os.time()
That should do the trick.
Bast |
Bast
Scripts: http://github.com/endavis | Top |
|
Posted by
| Dfmalh
(3 posts) Bio
|
Date
| Reply #26 on Wed 02 Sep 2009 08:17 PM (UTC) |
Message
| Hi Nick and Bast,
Thanks for pointing the specific "()" problem. I completely missed it in the previous post. I also went back to check the code from where I cut it... and well... all my fault, I missed, or did not select the final two characters, ()
Thanks for your help! Now I will proceed with he rest of the tut.
:-)))
| Top |
|
Posted by
| Liam
(1 post) Bio
|
Date
| Reply #27 on Tue 26 Nov 2013 02:34 AM (UTC) |
Message
| You got 57 xp.
[something]
[something]
Mob Dies.
I've got the following text on output.
What I'm trying to do is incorporate the following information into the Show_killed alias.
I want to keep a running tally of the XP accumulated from each mob type and then divide it by the number of mobs killed to gain an average xp per mob.
But can't as multi-line triggers don't work as I expect.
What are my options?
| Top |
|
Posted by
| Nick Gammon
Australia (23,072 posts) Bio
Forum Administrator |
Date
| Reply #28 on Tue 26 Nov 2013 04:03 AM (UTC) |
Message
|
Basically remember the number of xp (the first line). When the mob dies you can record that against the mob name. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Tharius
(29 posts) Bio
|
Date
| Reply #29 on Sun 01 Dec 2013 02:13 PM (UTC) |
Message
| There is one bug with this script that I had to encounter when I wrote a similar script in zmud.
The line prior to the kill line tells you who in fact made the kill. For alignment reasons groups are often disbanded just before the kill blow and so this trigger will count a false positive.
It's not critical but for some purposes I'd rather know my true list.
Is there a simple way to have this trigger fire, but then check the first word of the prior line(s) for the word "Your"... as in "Your slash horribly disfigures some-mob\nSome-mob is DEAD!!!"?
Thanks | 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.
120,088 views.
This is page 2, subject is 3 pages long:
1
2 3
It is now over 60 days since the last post. This thread is closed.
Refresh page
top