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
➜ Aardwolf Quest Tracker plugin
Aardwolf Quest Tracker plugin
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Gedeon
(4 posts) Bio
|
Date
| Tue 30 Oct 2018 01:55 AM (UTC) |
Message
| A nice simple GMCP quest tracker plugin I wrote to track quest average, total quests and to tell me total qp when I complete a quest, all modifiers included through GMCP
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="Quest_Tracker"
author="GIDEON_THE_BIBLE_BOOK_JUDGES"
id="0594aa70c008365aa5070abc"
language="Lua"
save_state="y"
date_written="2018-10-13"
requires="4.98"
version="2.11"
>
</plugin>
<include name="constants.lua"/>
<aliases>
<alias
match="gmcpquest"
enabled="y"
send_to="12"
sequence="100"
>
<send>
QuestCounter = GetVariable("QuestCounter")
QuestCounter = tonumber(QuestCounter)
print(QuestCounter, "Quests Completed")
QPtotal = GetVariable("QPtotal")
QPtotal = tonumber(QPtotal)
print(QPtotal, "QP total quest points with plugin")
print(tonumber(GetVariable("QPtotal"))/tonumber(GetVariable("QuestCounter")), " QP Average")
</send>
</alias>
</aliases>
<script>
require "serialize"
function OnPluginBroadcast (msg, id, name, text)
if (text == "comm.quest") then -- if we receive some GMCP quest data then do the following block of code up to end of if statement
res, gmcparg = CallPlugin("3e7dedbe37e44942dd46d264", "gmcpval", "comm")
luastmt = "gmcpdata = " .. gmcparg
assert (loadstring (luastmt or "")) ()
local action = gmcpval("quest.action")
if (action == "comp") then -- begin is statement with then
LastQuestQPTotal = GetVariable("LastQuestQPTotal")
LastQuestQPTotal = gmcpval ("quest.totqp")
print (LastQuestQPTotal, " QP from quest")
SetVariable ("LastQuestQPTotal", LastQuestQPTotal)
QuestCounter = GetVariable("QuestCounter")
QuestCounter = tonumber(QuestCounter)
QuestCounter = QuestCounter + 1
SetVariable ("QuestCounter", QuestCounter)
print(QuestCounter, " Quests Completed with GMCP_Quest_Recorder")
QPtotal = GetVariable("QPtotal")
QPtotal = tonumber(QPtotal)
QPtotal = QPtotal + LastQuestQPTotal
SetVariable ("QPtotal", QPtotal)
print(QPtotal, "Quest Points earned with GMCP_Quest_Recorder")
print(tonumber(GetVariable("QPtotal"))/tonumber(GetVariable("QuestCounter")), " QP Average")
end -- end if statement
end -- if gmcp quest data receieved comm.quest
end -- function onpluginbroadcast
require "gmcphelper" -- this line is necessary for us to be able to use the gmcpval helper function defined in gmcphelper.lua
function OnPluginInstall ()
QuestCounter = tonumber(GetVariable("QuestCounter"))
if QuestCounter == nil then
SetVariable ("QuestCounter", "0")
QuestCounter = tonumber(QuestCounter)
end
QPtotal = tonumber(GetVariable("QPtotal"))
if QPtotal == nil then
SetVariable ("QPtotal", "0")
QPtotal = tonumber (QPtotal)
end
end
function OnPluginSaveState() -- begin OnPluginSaveState function block, NOTE : VARIABLES MUST BE SAVED AS TYPE STRING TO SAVE CORRECTLY AND THEN CONVERTED BACK TO NUMBERS during OnPluginInstall function as demonstrated above
SetVariable("QuestCounter", QuestCounter)
if QPtotal == nil then -- begin if statement with then
SetVariable("QPtotal", "0")
QPtotal = tonumber(QPtotal)
end
end -- end OnPluginSaveState function block
</script>
</muclient>
Enjoy! :)
- Gedeon | Top |
|
Posted by
| Fiendish
USA (2,537 posts) Bio
Global Moderator |
Date
| Reply #1 on Sat 03 Nov 2018 12:52 AM (UTC) Amended on Sat 03 Nov 2018 12:53 AM (UTC) by Fiendish
|
Message
| Thanks! Just a few tips!
This little dance is no longer necessary in the Aardwolf MUSHclient package:
res, gmcparg = CallPlugin("3e7dedbe37e44942dd46d264", "gmcpval", "comm")
luastmt = "gmcpdata = " .. gmcparg
assert (loadstring (luastmt or "")) ()
See: https://github.com/fiendish/aardwolfclientpackage/wiki/Using-GMCP
In:
LastQuestQPTotal = GetVariable("LastQuestQPTotal")
LastQuestQPTotal = gmcpval ("quest.totqp")
that first line is wasted because you immediately overwrite the value
In:
QuestCounter = GetVariable("QuestCounter")
QuestCounter = tonumber(QuestCounter)
print(QuestCounter, "Quests Completed")
QPtotal = GetVariable("QPtotal")
QPtotal = tonumber(QPtotal)
print(QPtotal, "QP total quest points with plugin")
print(tonumber(GetVariable("QPtotal"))/tonumber(GetVariable("QuestCounter")), " QP Average")
You've already gotten and tonumbered your variables, so you don't need to do it again in your print. You should just use the local QuestCounter and QPtotal variables that you set. (This happens twice in two different parts of your code)
When you do something like:
if QuestCounter == nil then
SetVariable ("QuestCounter", "0")
QuestCounter = tonumber(QuestCounter)
I'm not sure that it's doing what you think. tonumber(nil) is nil. So QuestCounter will still be nil. (Likewise QPtotal). Maybe this is what you intended, but maybe not? Maybe you meant QuestCounter = 0? |
https://github.com/fiendish/aardwolfclientpackage | 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.
11,518 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top