Trigger, Alias & Script for Tracking Statting
Posted: Thu Nov 24, 2016 7:25 am
I am going to post here with some description on what you need to do to program a basic capture log of your own using Mudlet. Each componant will be outlined and if you have any questions or have difficulty getting it to work just ask. I'm Kiwakera & Glifieu in game. I'll try and keep up on the forums but can't say this will be the quickest way to getting an answer or help with whatever your needing. But please feel free to leave feedback and questions, I will get to them ASAP. I've used Mudlet for a number of years now and have some experiance in Zmud & Cmud as well, although I remember little but I'll post the link to the user manual that should be able to referance most questions to. Anyways, on with the Stat Capture Project.
Item #1 The Trigger:
First you will need to make a new Item, to do this, go to your Triggers and select Create New. Now Lable that new trigger Store Stats. Second you will put the following on the line marked 1 below where the rows are numbered. Also notice the drop down box next to where you pasted that on line 1, it says Substring, change that to Perl Regex.<-- that one gets me still from time to time so make sure you don't miss this detail.
Your base abilities are: (.*).$
Next you will need to enter the following in the big box at the bottom.
StoreStats(matches[1])
Now Save Item and you have just created a Trigger that will look for when the mudd displays your Stat Roll at lvl 3 it will capture and store them for later. (once we program the Script to make it all work that is)
Step 1 is now completed your doing great!
Next we will need to create a way to recall the stored stats once they are captured. This will allow us to collect and look at them together as it builds a database over time. This will be your key command to recall the database.
First you will need to go to your Alias menu and select New Item. Now we will name this new item Recall Stats.
Next In the line marked "Patterns" past the following, this will be your command to recall your stat database. You will be able to simpy type "sstats" (short for showstats) and it will give display your latest portion of the database. Or you can imput a number up to 250 following the "sstats" command (example: sstats 100 would display the last 100 stat rolls in your database.
^sstats(?: (.+))?$
To complete this Alias you will need to also past the following in the big box area below just like you did before.
ShowStats(tonumber(matches[2] or intShowLines))
Now again, Save Item and you have just completed Step 2. We are almost there, only a little more to go.
Ok now we need to create a script to bring it all together and make the magic happen. First go to your Script menu and once again make a New Item. Let's name this one Show Stats. Next we will need to paste the following into the big box below. Then Save Item and that takes care of the Script part.
-------------------------------------------------
-- The following lines can be modified --
-------------------------------------------------
intShowLines = 25 -- How many lines to show by default if no line count is specified (i.e. ShowChats 10 will show 10 lines while ShowChats will show 20 lines)
intMaxLines = 250 -- How many lines to store in the buffer. Older lines will be deleted as newer ones are added.
tblStats = {}
function StoreStats(strStat)
local timestamp = getTime(true, "yyyy.MM.dd hh:mm:ss.zzz")
local intCount = #tblStats
if intCount > intMaxLines - 1 then
table.remove(tblStats,1)
end
table.insert(tblStats,timestamp .. " " .. strStat)
end
function ShowStats(intStatCount)
if table.is_empty(tblStats) then
cecho("\n<orange>No Stats Stored!\n")
else
intTotalStats = #tblStats
if intTotalStats == nil then
intTotalStats = 0
end
cecho("\n<orange>ShowStats(" .. intStatCount .. ") of (" .. intTotalStats ..")\n")
if intTotalStats > intStatCount then
for intLoop = intTotalStats-intStatCount, intTotalStats, 1 do
strLine = tblStats[intLoop]
strLine = string.sub(strLine, 12)
strLine = string.sub(strLine,1,8) .. string.sub(strLine,13)
cecho("\n<LightSkyBlue>" .. strLine)
end
echo("\n")
else
for intLoop = 1, intTotalStats, 1 do
strLine = tblStats[intLoop]
strLine = string.sub(strLine, 12)
strLine = string.sub(strLine,1,8) .. string.sub(strLine,13)
cecho("\n<LightSkyBlue>" .. strLine)
end
echo("\n")
end
end
end
One last thing you will need to do is create a trigger that checks for stats every time you level. Notice that when you are below Lvl 3 and you type Stats you do not have a Base Abilities line.. See the Trigger checks for that line, and when it sees it then it will copy it to the database so you can compile it and recall it later.
Ok so this part is simple, we will one last time go to the Triggers menu and create a New Item, this one lable Stat Check. Now below on line 1 like before you will paste the following. Also change this to a Perl Regex as well like before.
You gain a level!$
Lastly you will need to enter the word Score in the line marked Send plain text to the left of the name of this trigger near the upper right corner. Again be sure to Save and you should have a completed working Script that can capture your stat rolls and recall them as desired. Again any questions or if something isn't working we can figure it out and get things rolling for you. Now this is also adaptable for capturing other things. Enjoy.
Item #1 The Trigger:
First you will need to make a new Item, to do this, go to your Triggers and select Create New. Now Lable that new trigger Store Stats. Second you will put the following on the line marked 1 below where the rows are numbered. Also notice the drop down box next to where you pasted that on line 1, it says Substring, change that to Perl Regex.<-- that one gets me still from time to time so make sure you don't miss this detail.
Your base abilities are: (.*).$
Next you will need to enter the following in the big box at the bottom.
StoreStats(matches[1])
Now Save Item and you have just created a Trigger that will look for when the mudd displays your Stat Roll at lvl 3 it will capture and store them for later. (once we program the Script to make it all work that is)
Step 1 is now completed your doing great!
Next we will need to create a way to recall the stored stats once they are captured. This will allow us to collect and look at them together as it builds a database over time. This will be your key command to recall the database.
First you will need to go to your Alias menu and select New Item. Now we will name this new item Recall Stats.
Next In the line marked "Patterns" past the following, this will be your command to recall your stat database. You will be able to simpy type "sstats" (short for showstats) and it will give display your latest portion of the database. Or you can imput a number up to 250 following the "sstats" command (example: sstats 100 would display the last 100 stat rolls in your database.
^sstats(?: (.+))?$
To complete this Alias you will need to also past the following in the big box area below just like you did before.
ShowStats(tonumber(matches[2] or intShowLines))
Now again, Save Item and you have just completed Step 2. We are almost there, only a little more to go.
Ok now we need to create a script to bring it all together and make the magic happen. First go to your Script menu and once again make a New Item. Let's name this one Show Stats. Next we will need to paste the following into the big box below. Then Save Item and that takes care of the Script part.
-------------------------------------------------
-- The following lines can be modified --
-------------------------------------------------
intShowLines = 25 -- How many lines to show by default if no line count is specified (i.e. ShowChats 10 will show 10 lines while ShowChats will show 20 lines)
intMaxLines = 250 -- How many lines to store in the buffer. Older lines will be deleted as newer ones are added.
tblStats = {}
function StoreStats(strStat)
local timestamp = getTime(true, "yyyy.MM.dd hh:mm:ss.zzz")
local intCount = #tblStats
if intCount > intMaxLines - 1 then
table.remove(tblStats,1)
end
table.insert(tblStats,timestamp .. " " .. strStat)
end
function ShowStats(intStatCount)
if table.is_empty(tblStats) then
cecho("\n<orange>No Stats Stored!\n")
else
intTotalStats = #tblStats
if intTotalStats == nil then
intTotalStats = 0
end
cecho("\n<orange>ShowStats(" .. intStatCount .. ") of (" .. intTotalStats ..")\n")
if intTotalStats > intStatCount then
for intLoop = intTotalStats-intStatCount, intTotalStats, 1 do
strLine = tblStats[intLoop]
strLine = string.sub(strLine, 12)
strLine = string.sub(strLine,1,8) .. string.sub(strLine,13)
cecho("\n<LightSkyBlue>" .. strLine)
end
echo("\n")
else
for intLoop = 1, intTotalStats, 1 do
strLine = tblStats[intLoop]
strLine = string.sub(strLine, 12)
strLine = string.sub(strLine,1,8) .. string.sub(strLine,13)
cecho("\n<LightSkyBlue>" .. strLine)
end
echo("\n")
end
end
end
One last thing you will need to do is create a trigger that checks for stats every time you level. Notice that when you are below Lvl 3 and you type Stats you do not have a Base Abilities line.. See the Trigger checks for that line, and when it sees it then it will copy it to the database so you can compile it and recall it later.
Ok so this part is simple, we will one last time go to the Triggers menu and create a New Item, this one lable Stat Check. Now below on line 1 like before you will paste the following. Also change this to a Perl Regex as well like before.
You gain a level!$
Lastly you will need to enter the word Score in the line marked Send plain text to the left of the name of this trigger near the upper right corner. Again be sure to Save and you should have a completed working Script that can capture your stat rolls and recall them as desired. Again any questions or if something isn't working we can figure it out and get things rolling for you. Now this is also adaptable for capturing other things. Enjoy.