Register forum user name Search FAQ

Gammon Forum

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 ➜ Tips and tricks ➜ Counter Scripting

Counter Scripting

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


Posted by Ventrilo   (10 posts)  Bio
Date Mon 10 Apr 2006 03:17 PM (UTC)
Message
Hey all,

I'd like to make a script where it calculates the total hp, mana, move, pracs, and trains i got in a day before i reset it with a command.

The trigger is something like this:
Your gain is: 17 hits, 6 mana, 10 moves, 5 practices, and 1 trains.

Thanks.
Top

Posted by Ventrilo   (10 posts)  Bio
Date Reply #1 on Thu 13 Apr 2006 03:44 PM (UTC)
Message
Ok, someone with ZMUD got the script. It's just that since I have zero knowledge of scripting, could anyone please help with translate this?


#CLASS {Utility|stat_capture} {enable}
#ALIAS gains {#show Your gains are: @hpcount hp, @manacount m, @levelcount levels, @avexp ave xp}
#ALIAS gainrep {say Your gains are: @hpcount hp, @manacount m, @levelcount levels, @avexp ave xp}
#ALIAS averep {#var ahp 0;#math ahp @tothp/@totlevel;#var aman 0;#math aman @totmana/@totlevel;#sh Your ave gains are: @ahp hp, @aman m, over @totlevel levels}
#ALIAS masterreset {#var totlevel 0;#sh master reset successful}
#ALIAS reset {#var levelcount 0;#var manacount 0;#var hpcount 0;#var expcount 0;#var killcount 0;#var avexp 0;#var levels_sofar "Levels 0";#show Counters reset}
#VAR killcount {0}
#VAR expcount {0}
#VAR levelcount {0}
#VAR hpcount {0}
#VAR managain {0}
#VAR tothp {0}
#VAR totmana {0}
#VAR totlevel {0}
#VAR manacount {0}
#VAR avexp {0}
#VAR ahp {0}
#VAR aman {0}
#TRIGGER {Your slash (%w)} {#add expcount 1}
#TRIGGER {Your pierce (%w)} {#add expcount 1}
#TRIGGER {Your gain is: (%d) hits, (%d) mana} {#add hpcount %1;#add tothp %1;#add manacount %2;#add totmana %2;#add levelcount 1;#add totlevel 1;#var levels_sofar "Levels ";#add levels_sofar %string( @levelcount)}
#TRIGGER {Page Length} {#show;gains;#co blue;averep;#co blue}
#TRIGGER {You receive (%d) experience points.} {#add expcount %1;#add killcount 1;#math avexp @expcount/@killcount}
#TRIGGER {Your flamestrike} {#add expcount 2}
#CLASS 0


Thanks
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #2 on Sat 15 Apr 2006 08:48 AM (UTC)
Message
To get you started, I have converted a couple of these examples:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="^Your gain is\: (\d+) hits\, (\d+) mana$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
var.hpcount = (var.hpcount or 0) + %1
var.tothp = (var.tothp or 0) + %1
var.manacount = (var.manacount or 0) + %2
var.totmana = (var.totmana or 0) + %2
var.levelcount = (var.levelcount or 0) + 1
</send>
  </trigger>
</triggers>

<aliases>
  <alias
   match="gains"
   enabled="y"
   expand_variables="y"
   send_to="2"
   sequence="100"
  >
  <send>Your gains are: @hpcount hp, @manacount m, @levelcount levels</send>
  </alias>
</aliases>



This example assumes you are using the Lua language, and the "exampscript.lua" file as your script file (which ships with MUSHclient). This defines the "var" behaviour which is a quick way of accessing MUSHclient variables.

The example illustrates how you would add to the MUSHclient variables you named, plus the alias will show the results of the new values.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ventrilo   (10 posts)  Bio
Date Reply #3 on Sun 16 Apr 2006 10:42 AM (UTC)
Message
Thanks Nick,

I've added some to the triggers and alias and looks like I still got some problems. Here is what I've got so far

I got a trigger of:

<triggers>
<trigger
custom_colour="2"
enabled="y"
match="^Your gain is\: (\d+) hits\, (\d+) mana, (\d+) moves, (\d+) practices, and (\d+) trains.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>var.hpcount = (var.hpcount or 0) + %1
var.tothp = (var.tothp or 0) + %1
var.manacount = (var.manacount or 0) + %2
var.totmana = (var.totmana or 0) + %2
var.movcount = (var.movcount or 0) + %3
var.totmov = (var.totmov or 0) + %3
var.prac = (var.prac or 0) + %4
var.totprac = (var.totprac or 0) + %4
var.levelcount = (var.levelcount or 0) + 1
</send>
</trigger>
</triggers>


and an alias of:

<aliases>
<alias
match="gains"
enabled="y"
expand_variables="y"
send_to="2"
sequence="100"
>
<send>Your gains are: @hpcount hp, @manacount mn, @movcount mv, @prac prac, and @levelcount levels</send>
</alias>
</aliases>


With also my Lua script enabled (called Erwin.lua) but contains no data in it.


and whenever I level, i got an error message of:

Error number: 0
Event: Run-time error
Description: [string "Trigger: "]:1: attempt to index global `var' (a nil value)
stack traceback:
[string "Trigger: "]:1: in main chunk
Called by: Immediate execution


Sorry if this is getting very long Nick, and thanks alot for your help.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #4 on Sun 16 Apr 2006 09:23 PM (UTC)
Message
In my earlier post I said you needed to make the exampscript.lua file your script file. That makes "var" work. Read this post, it describes what it is doing:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4904

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ventrilo   (10 posts)  Bio
Date Reply #5 on Mon 17 Apr 2006 12:34 AM (UTC)
Message
Cool, getting closer!

I used exampscript as my Lua script, when i run it, I got this error message:

Error number: 0
Event: Run-time error
Description: [string "Trigger: "]:1: attempt to perform arithmetic on a string value
stack traceback:
[string "Trigger: "]:1: in main chunk
Called by: Immediate execution


I've seen some posts regarding changing the values but don't quite get them since i got no knowledge in scripting. Help please?
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #6 on Mon 17 Apr 2006 01:33 AM (UTC)
Message
So it is complaining about this line:

var.hpcount = (var.hpcount or 0) + %1

Either %1 is not a number (which it should be from the trigger), or the hpcount variable has a string in it.

Check what the hpcount variable has in it (from the Variables tab in the world configuration) and if it isn't a number, either make it zero or delete it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ventrilo   (10 posts)  Bio
Date Reply #7 on Mon 17 Apr 2006 11:13 AM (UTC)
Message
Woohoo, it worked!

What i did was, i previously had all these variables manually entered into the variable table. I just deleted them all and it worked!


Thanks Nick!
Top

Posted by Hopelessly Blond   (1 post)  Bio
Date Reply #8 on Sat 13 Aug 2011 11:44 PM (UTC)
Message
This is the exact thing I'm looking for to use on my current mud of choice and it even runs off of the exact line that my gains (hp, mana, mov, practices and trains) do.
I could EASILY copy and paste this and have it work in my mud, but the only thing is - as you can tell by my forum name, I'm hopelessly blond and have no idea of where to even start with trying to implement this.
There's many other things that I'm interested in scripting/triggering/aliasing for the game, but unless it comes in a format that's easily understandable, such as:
-http://www.gammon.com.au/forum/?id=8411
... that, then I'm afraid that most of this just looks like gibberish to me.
I've spent the past 24 hours reading up on triggers and aliases and scripts and I've had some minor success, but no where near enough for me to even attempt this.

The trigger line for gains is:
Your gain is: 2 hits, 4 mana, 6 moves, 5 practices, and 1 trains.
The numbers are, of course, ever changing. I would like to be able to count the levels (levels end at 150, so after that it's just rising in power everytime you recieve the gains line), hit points, mana and moves. There are some additional things that I'd like to include, though I don't know if it would have to be in the same script or different, but I would like to total the average hp, mana and movement points that I get.
I would LOVE for it to be in a table format, much like the killed mobs one... so if anyone could please help out a code dummy like me, that would be great.
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.


32,499 views.

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

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.