Counting Multiple Triggers, Displaying Counts

Posted by Caspain on Fri 27 Sep 2024 06:47 PM — 10 posts, 14,836 views.

#0
Hello, first time caller long time listener.

I'm trying to track a new mechanic in a MUD that happens 1% of the time. It's technically 4 different things that each can happen 1% of the time, and I'm interested in seeing just how often they do happen.

Ideally, I'd track these variables between sessions as well.

After that, I'd like to make an alias or recommended command to call up all four of the variables with some light framing.


Quote:
You feel a sudden sense of foreboding

Your ancestral fury ignites


These are the two for when it procs for myself.


Quote:
fueled by an ancient, relentless power!

As if sensing danger


These two are for when it procs for a mob, with the first of the two coming at the end of the sentence.

I tried to cobble something together after reading some other counting related threads, but I wasn't sure how to get it to cease some errors related to a comma or something.
Amended on Fri 27 Sep 2024 06:48 PM by Caspain
Australia Forum Administrator #1
Can you show us what you have? Perhaps we can fix the comma issue.
#2
I made 4 separate triggers, one for each line.

Inside each line of those that start their lines with the text, I have adapted this entry from another post

Quote:
parrycount = GetVariable("parrycount")

-- check variable exists
if parrycount == nil then
parrycount = '0'
end -- if

SetVariable ("parrycount", tonumber(parrycount) + 1)
Note (GetVariable("parrycount"))


Changed sento to script. And their triggers end with *.

IE I changed all instances of parrycount to 4 new variables based on the mechanics I'm tracking. foresight and relentlessness. fscount, fsmecount, lentcount, melentcount.

For the trigger that ends the line, I used.
Quote:
^* fueled by an ancient, relentless power!


When a trigger occurs I get an error that says the "error occured around ," (I don't have the exact error phrasing with me atm)

I tried adapting the parry stuff a few different ways after that but wasn't sure if I had a true error or if I tried to use the wrong thing. Ideally I'd just combine all for line tracking into a single script that either reports total counts as they happen, or with a second one just to call those 4 fields with labels. They're 1% chances to attack again or dodge, for myself and mobiles.

Edit: Grabbed the error
Quote:
[string "Trigger: "]:1: unexpected symbol near ','
Amended on Sun 29 Sep 2024 07:09 PM by Caspain
Australia Forum Administrator #3
I don't see a comma in what you posted so please show the whole thing.

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.
#4
It's on the
Quote:
SetVariable ("parrycount",
part as far as I know. They all look exactly as posted except instead of 'parrycount' they say 'fscount' 'fsmecount' 'lentcount' 'melentcount' I left everything else as is, intending to just create and track the 4 variables.
Australia Forum Administrator #5
Please do as I asked above, and post the whole thing.

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.


I can try to reproduce the problem, but I can't do that if I just get snippets of what you are trying to do.
#6
Quote:
fscount = GetVariable("fscount")

-- check variable exists
if fscount == nil then
fscount = '0'
end -- if

SetVariable ("fscount", tonumber(fscount) + 1)
Note (GetVariable("fscount"))


Quote:
fsmecount = GetVariable("fsmecount")

-- check variable exists
if fsmecount == nil then
fsmecount = '0'
end -- if

SetVariable ("fsmecount", tonumber(fsmecount) + 1)
Note (GetVariable("fsmecount"))


Quote:
lentcount = GetVariable("lentcount")

-- check variable exists
if lentcount == nil then
lentcount = '0'
end -- if

SetVariable ("lentcount", tonumber(lentcount) + 1)
Note (GetVariable("lentcount"))


Quote:
melentcount = GetVariable("melentcount")

-- check variable exists
if melentcount == nil then
parrycount = '0'
end -- if

SetVariable ("melentcount", tonumber(melentcount) + 1)
Note (GetVariable("melentcount"))


I already posted everything completely as far as I know. My first post has the phrases they trigger from. They're all sendto Script. No other options are toggled away from the default of a fresh install/new trigger. When one happens, it mentions the comma and I believe it's a compiling error if I recall the log correct.

The only one I wasn't sure on was triggering off the end of a sentence. I put ^* at the front of it in the trigger field, under the impression that means starts with anything followed by that sentence end.
Amended on Mon 30 Sep 2024 12:26 PM by Caspain
#7
I took a closer look and a look at some other threads and I think I realize how you were asking me to post it.

Quote:

<triggers>
<trigger
enabled="y"
match="You feel a sudden sense of foreboding *"
send_to="12"
sequence="100"
>
<send>setvariable "fsmecount", CInt(getvariable("fsmecount"))+1
</send>
</trigger>
</triggers>


I thought about just taking the comma out but I didn't understand what that might do.
Australia Forum Administrator #8
Lua is case-sensitive, so it is SetVariable, not setvariable.

Function arguments go inside parentheses so it is:


SetVariable ("fsmecount",tonumber(GetVariable("fsmecount"))+1)


I note that what you posted in reply #7 is quite different to the snippets in reply #6.
#9
I was replying from a different station than the one that had the actual information on it. So, I gave the base I was working from, as it came from another similar thread. I tried to take the 'most complete' version from said thread. After I directly copy pasted and then only word replaced 'parry' I ran into issues, which you're showing me is related to capitalization. I had already tried changing each of my triggers in various ways, so the last reply is just one of the various ways I tried to resolve the issue myself while not knowing what I was doing at all. Had I selected any of the other remaining, they'd each have looked different than the rest because I was trying various solutions and already had the base available.

So, my post approached it where I was, without something I was really working from other than the base post I shared. I gave the other format because I didn't know if it contained other relevant information outside the 'Trigger' field, the 'Send' field, and the Send to: drop down I had used.

Thank you for helping me resolve this issue. I do not code, only play MUDs.