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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  How do I make an Experience Counter
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

How do I make an Experience Counter

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


Posted by Trigger   (5 posts)  [Biography] bio
Date Thu 01 Mar 2007 03:19 PM (UTC)
Message
Ok heres another good one that I know will envolve variables. Keep in mind That I have no idea how this program works on variables and triggers because copying and pasting a trigger doesnt really help me to much. Script wise that is. Although I havent really tried to hard for the capitals cause I got it typed 4 times instead of one. Either way you guys are awsome.

Anyways back to the question at hand. I want MUSHclient to count the experience gained from a mob kill.

You receive 150 experience points.
You receive 150 experience points.


and every time I type xp I want it to say
300 xp
untill I kill another mob
You receive 150 experience points.
In whitch it will say you have gained 450 xp
I suppose I want it to say
You have gained a total of 450 xp since last reset.
Any chance you lady's and gents could give me a hand with this without making it to complicated?:)
[Go to top] top

Posted by Nick Gammon   Australia  (21,648 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 01 Mar 2007 07:51 PM (UTC)

Amended on Thu 01 Mar 2007 07:52 PM (UTC) by Nick Gammon

Message
I was going to suggest searching the forum, but previous posts on this subject seemed to use VBscript, and I prefer to script in Lua these days.

As a style issue can you please use [mono] for output from the MUD rather than bold? Bold is really for emphasis, but mono (or code) is better to show monospaced output.

To make an experience counter, you really just need to keep adding experience gains into a variable. This variable will be stored when you save the MUSHclient world file (if you save it). Here is what I had:


<triggers>
  <trigger
   enabled="y"
   match="You receive * experience points."
   send_to="12"
   sequence="100"
  >
  <send>

SetVariable ("xp", (GetVariable ("xp") or 0) + %1)
Note ("You have gained a total of " ..
      GetVariable ("xp") .. " xp since last reset.")

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

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

SetVariable ("xp", 0)
Note "xp reset to zero"

</send>
  </alias>
  <alias
   match="xp"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

Note ((GetVariable ("xp") or 0) .. " xp")

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


The first part is a trigger to match on the experience gain line, and this adds to the "xp" variable, and notifies you of the new number.

The alias "xp" reports the current value, and the alias "resetxp" resets the variable to zero.

- Nick Gammon

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

Posted by Trigger   (5 posts)  [Biography] bio
Date Reply #2 on Thu 01 Mar 2007 11:05 PM (UTC)

Amended on Thu 01 Mar 2007 11:50 PM (UTC) by Trigger

Message
Yo thank you guys a million for your helping me in triggers because I read alot of the stuff you guys wrote in the past but it doesnt help me half as much as you just did man.

Everything he wrote worked!

Heres another one.
I want that same xp counter to also count the gold I pick up.
Anyway to do this without making 4 aliases?
[Go to top] top

Posted by Shaun Biggs   USA  (644 posts)  [Biography] bio
Date Reply #3 on Fri 02 Mar 2007 04:16 AM (UTC)
Message
You will either have to have a seperate trigger for each possible way of displaying how much gold you gain, or one really long, messy regex trigger. I have a gold monitor I use, with about 8 triggers for various gold gains, and another one to remove gold you split with party members. I just tossed the functions into the world script file, and had the triggers call that script, so I only needed about three functions, saving a bit of space and effort for me.

It is much easier to fight for one's ideals than to live up to them.
[Go to top] top

Posted by Nick Gammon   Australia  (21,648 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Fri 02 Mar 2007 04:45 AM (UTC)
Message
Since you are matching on a different message, and adding to a different counter, it is probably simplest to copy the general idea for the experience counter, but duplicate it, for a gold counter.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


3,875 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 FutureQuest]