Trigger, Alias & Script for Tracking Statting

... A place to ask for help on any topic whether it be starting out to player killing to IT issues.
Post Reply
Kiwakera
Posts: 6
Joined: Wed Nov 23, 2016 6:11 pm

Trigger, Alias & Script for Tracking Statting

Post by Kiwakera » 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.

Kiwakera
Posts: 6
Joined: Wed Nov 23, 2016 6:11 pm

Re: Trigger, Alias & Script for Tracking Statting

Post by Kiwakera » Thu Nov 24, 2016 7:55 am

This is Zuggsoft's Library of files and a chapter by chapter of their manual for Zmud. Hope this helps those of you who don't have Mudlet or choose to use Zmud/Cmud. Wish I could help yall more but it's been like 5-8 years since I was serious into those. I prefer Mudlet personally because it is more adaptable in the programing side of things. Zmud/Cmud are very good products but are simplified while Mudlet is more dynamic and adaptable to whatever you want to do. I've been learning about Luna Functions lately and plan on continuing to develop my understanding of the programing languages used and how we can put quality functional adaptations into things. BTW I rightly don't care about spelling or grammer or whatnot so if I get confusing or whatnot please feel free to ask questions. I'll help the best I can. :)

http://www.zuggsoft.com/page.php?file=library/index.htm

Jomin
Posts: 160
Joined: Thu Feb 19, 2015 3:54 pm
Location: White Tower Libraries or Deepest Wiltshire, UK

Re: Trigger, Alias & Script for Tracking Statting

Post by Jomin » Fri Nov 25, 2016 6:46 pm

Just a thought :idea:, with your Script you use the following line:

Code: Select all

tblStats = {}
I was under the impression that will clear the tblStats table each time the script is run, I was under the impression that it would be better to use:

Code: Select all

tblStats = tblStats or {}
which will only assign a new, empty table to the tblStats variable if tblStats is itself a Lua boolean false (which it won't be) or a Lua nil (which it will be if it has not been previously used). This is particularly relevant if you check the box against the table where it is in the tree which enables the variable to be saved auto-magically between sessions in modern versions of Mudlet.

(Be aware that the table may get "hidden" in subsequent sessions as I think we have a not properly documented feature that makes stuff from past sessions become hidden and not show in the "Variables" display unless "Show Hidden Variables" is enabled - I didn't write anything in that area of the code and I haven't got a comprehensive grip on how the Lua/C++ Variable code works at the moment.)

Kiwakera
Posts: 6
Joined: Wed Nov 23, 2016 6:11 pm

Re: Trigger, Alias & Script for Tracking Statting

Post by Kiwakera » Sat Nov 26, 2016 12:01 am

This is an example of my current output when I type the alias we set up sstats

ShowStats(20) of (100)

20:07:27 Your base abilities are: Str:15 Int:14 Wil:15 Dex:15 Con:16.
20:09:37 Your base abilities are: Str:17 Int:14 Wil:13 Dex:16 Con:16.
20:12:06 Your base abilities are: Str:15 Int:12 Wil:14 Dex:15 Con:19.
20:15:25 Your base abilities are: Str:13 Int:13 Wil:15 Dex:17 Con:14.
20:19:03 Your base abilities are: Str:16 Int:14 Wil:13 Dex:12 Con:16.
20:22:36 Your base abilities are: Str:15 Int:14 Wil:13 Dex:18 Con:16.
20:25:50 Your base abilities are: Str:15 Int:17 Wil:14 Dex:14 Con:19.
20:29:25 Your base abilities are: Str:15 Int:16 Wil:16 Dex:15 Con:15.
20:33:39 Your base abilities are: Str:15 Int:18 Wil:13 Dex:15 Con:16.
20:38:04 Your base abilities are: Str:15 Int:14 Wil:12 Dex:18 Con:16.
20:39:36 Your base abilities are: Str:14 Int:16 Wil:13 Dex:13 Con:19.
20:41:24 Your base abilities are: Str:15 Int:14 Wil:13 Dex:15 Con:18.
20:45:14 Your base abilities are: Str:18 Int:14 Wil:13 Dex:18 Con:12.
20:47:57 Your base abilities are: Str:16 Int:13 Wil:13 Dex:17 Con:12.
20:50:24 Your base abilities are: Str:15 Int:11 Wil:13 Dex:18 Con:16.
20:50:25 Your base abilities are: Str:15 Int:11 Wil:13 Dex:18 Con:16.
20:52:00 Your base abilities are: Str:15 Int:14 Wil:13 Dex:15 Con:15.
20:53:51 Your base abilities are: Str:16 Int:14 Wil:15 Dex:18 Con:15.
20:56:02 Your base abilities are: Str:17 Int:14 Wil:10 Dex:15 Con:18.
20:57:34 Your base abilities are: Str:18 Int:17 Wil:12 Dex:15 Con:17.
20:59:12 Your base abilities are: Str:11 Int:14 Wil:15 Dex:18 Con:19.

A stout young sapling swiftly dodges your attempt to cleave it.

statting an Illian Warrior at the moment. well have been for awhile now lol but anyways, this serves as an example of the output. When you shut down the program it will clear the database. Or if you deactivate and reactivate the trigger or script portion it will also clear the held stat data.

Jomin
Posts: 160
Joined: Thu Feb 19, 2015 3:54 pm
Location: White Tower Libraries or Deepest Wiltshire, UK

Re: Trigger, Alias & Script for Tracking Statting

Post by Jomin » Mon Dec 05, 2016 10:39 pm

The reason why Kiwakera is correct in their assertion "Or if you deactivate and reactivate the trigger or script portion it will also clear the held stat data." is the unmodified "tblStats={}" statement at the start of the script that assigns an empty table (the {} value) to that variable, the "tblStats=tblStats or {}" that I suggest only does that if the table doesn't exist - it would then be perfectly feasible to have an additional alias that then clears the table only upon request...

Extending my previous posting if you make the above change and you find your tblStats variable in the editor's tree widget display on the "Variables" page you can (on modern versions of Mudlet) click on it to "check it" in the tree and then it will be saved with the profile and will be restored when you restart a new session (assuming you answer "Yes" to the "Do you want to save this profile" question when you close the profile or Mudlet itself down!) :ugeek:

Paelos
Posts: 16
Joined: Sat Dec 03, 2016 4:52 am

Re: Trigger, Alias & Script for Tracking Statting

Post by Paelos » Tue Dec 06, 2016 3:08 am

good suggestion :)

Post Reply