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, 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 ➜ Lua ➜ Mission point Counter?

Mission point Counter?

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


Posted by Biran   (8 posts)  Bio
Date Fri 13 Jan 2023 05:51 PM (UTC)
Message
I'm new to this type of script and iv looked into the forum for something similar but have had little luck getting it to work.
This is the trigger line.

Raichek says 'As a reward, I am giving you 18 mission points, and 14 Ryo.'
Trigger:
match="^'As a reward, I am giving you (\d+) mission points, and (\d+) Ryo.'$"

Send:
var.mpcount = (var.mpcount or 0) + %1
var.totmp = (var.totmp or 0) + %1

I have it going to script,enabled, regular expression,custom_2
Also my lua file is C:\Program Files (x86)\MUSHclient\scripts\exampscript.lua

My alias recall this number is
Alias = missions

You have gained : @mpcount

It gives the Error variable "mpcount" has not been defined
Top

Posted by AdInfinitum   (74 posts)  Bio
Date Reply #1 on Fri 13 Jan 2023 08:58 PM (UTC)

Amended on Mon 16 Jan 2023 12:52 PM (UTC) by AdInfinitum

Message
A couple things to check:

1. Your script contains require 'var', right?
2. Did you enable 'Expand Variables' in the alias?
Top

Posted by Biran   (8 posts)  Bio
Date Reply #2 on Fri 13 Jan 2023 09:55 PM (UTC)
Message
AdInfinitum said:

A couple things to check:

1. Your script contains requires 'var', right?
2. Did you enable 'Expand Variables' in the alias?


I have expanded variables on the alias but I don't have Require var...what would that look like? in the send area or is that a click option?

Thank you for the quick response! i have this trigger that collects sends everything to notepad but having them auto-totaled up would be so much better.
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 15 Jan 2023 01:38 AM (UTC)

Amended on Sun 15 Jan 2023 01:40 AM (UTC) by Nick Gammon

Message
Rather than describing every aspect of your trigger, please copy/paste whole here, see:

Template:copying For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


That would have answered the questions AdInfinitum asks.

And if your script is in a separate script file (not strictly necessary, you can "send to script" and put the script inline) please also copy/paste the script file contents.




As for how to require something you put, for example:


require "var"


... at the start of your script code.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #4 on Sun 15 Jan 2023 01:46 AM (UTC)
Message
There are examples of using "var" in this post:

http://www.gammon.com.au/forum/?id=4904&reply=6#reply6

That shows using the "require" statement.

Also, if you don't need to keep the counts over multiple sessions (you might) then simple Lua variables will do, they would reset each time you started the client.

- Nick Gammon

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


6,459 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.