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.
Entire forum
➜ MUSHclient
➜ Lua
➜ Trouble with a script
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Dawastedpanda
(14 posts) Bio
|
Date
| Wed 01 Apr 2020 09:04 PM (UTC) Amended on Wed 01 Apr 2020 09:14 PM (UTC) by Dawastedpanda
|
Message
| I am hoping to have this plugin track my KiLevel. The problem is that the mud has a prompt with commas in it.
(LifeForce:<86> Ki:<16,050>)
<triggers>
<trigger enabled="n"
match="*(LifeForce:<*> Ki:<*>)*"
group="prompt"
ignore_case="y"
script="trackKiLevel"
sequence="100"/>
</triggers>
<!-- Aliases to set the alert level. -->
<aliases>
<alias enabled="y"
match="firstAlert *"
ignore_case="y"
script="setFirstWarning"
sequence="100"/>
</aliases>
<script>
<![CDATA[
require "tprint"
firstWarning = 0
currentKiLevel = 0
function setFirstWarning(name, list, args)
firstWarning = args[1] + firstWarning -- sets the level to a number
ColourNote("yellow","", "First Alert set to: ","cyan", "", firstWarning)
EnableTriggerGroup("prompt", true)
end -- function
function trackKiLevel(name, list, args)
currentKiLevel = tonumber(args[3]) + currentKiLevel
ColourNote("yellow","", "Current Ki Level: ","cyan", "", currentKiLevel)
if currentKiLevel < firstWarning then
ColourNote("yellow","","WARNING! YOUR KI HAS DROPPED BELOW","","cyan", firstWarning)
end -- if
end -- function
]]>
</script>
The error I get with it is:
Run-time error
Plugin: KiTracker (called from world: DB-Infinity)
Function/Sub: trackKiLevel called by trigger
Reason: processing trigger ""
[string "Plugin"]:164: attempt to perform arithmetic on a nil value
stack traceback:
[string "Plugin"]:164: in function <[string "Plugin"]:163>
Error context in script:
160 : EnableTriggerGroup("prompt", true)
161 : end -- function
162 :
163 : function trackKiLevel(name, list, args)
164*: currentKiLevel = tonumber(args[3]) + currentKiLevel
165 : ColourNote("yellow","", "Current Ki Level: ","cyan", "", currentKiLevel)
166 : if currentKiLevel < firstWarning then
167 : ColourNote("yellow","","WARNING! YOUR KI HAS DROPPED BELOW","","cyan", firstWarning)
168 : end -- if
| Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 02 Apr 2020 02:02 AM (UTC) |
Message
| You will need to get the comma out of that number (16,050).
For example:
kilevel = string.gsub (args [3], ",", "")
currentKiLevel = tonumber(kilevel) + currentKiLevel
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Dawastedpanda
(14 posts) Bio
|
Date
| Reply #2 on Thu 02 Apr 2020 02:05 PM (UTC) |
Message
|
Nick Gammon said:
You will need to get the comma out of that number (16,050).
For example:
kilevel = string.gsub (args [3], ",", "")
currentKiLevel = tonumber(kilevel) + currentKiLevel
Thank you, this worked. I was doing gsub wrong. Appreciate the quick response. | 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.
9,494 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top