|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun May 18, 2008 2:39 pm
Tick Timer |
So, my MUD has randomized ticks that all average around 41 seconds. Still, this random factor makes them slightly difficult to deal with. Plenty of players have developed tick timers, unfortunately, they all use zMUD.
Here's what they have:
Code: |
#FUNC minutes {3}
#TRIGGER {%d:({0|3})0[ap]m} {#if @minutes!=%1 {#VAR minutes {%1};#TS 41}} {ticktimer} 519
|
Here's what I changed it to:
Code: |
#FUNC minutes {3}
#REGEX Tick Timer {\d\:({0|3})0[ap]m} {#IF (@minutes!=%1) {#VAR minutes {%1};#TS}} {GENERAL TRIGGERS}
|
I was wondering if anyone could help me translate it over to function properly in CMUD.
I believe what it's trying to do is look at the clock in my prompt: (3 ticks)
<1674/1674hp 1088/1088m 456/456mv 641cp 1611pq 2315g/46s
[Cliath's Shrine Room] [EW] 2:30am [Night Time]>
<1674/1674hp 1088/1088m 456/456mv 641cp 1611pq 2315g/46s
[Cliath's Shrine Room] [EW] 3:00am [Night Time]>
<1674/1674hp 1088/1088m 456/456mv 641cp 1611pq 2315g/46s
[Cliath's Shrine Room] [EW] 3:30am [Night Time]> |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun May 18, 2008 3:49 pm |
Your regex syntax is wrong. Read the reference. You're using {} when you mean (). You also have a space in the ID, so it needs to be quoted. Oh, and #func has changed now (and it's not needed in the original anyway, #var would do).
Trouble is that without knowing what this script is trying to do, there's not a lot that we can do. It seems like the trigger is set to fire every thirty minutes (when the clock reads the hour and half past it). It seems strange that they've done that jiggery pokery with the minutes variable, because what'll happen is that the trigger will fire on the hour (when the variable is 3) and then set the variable to 0. This will mean that when the trigger fires again at half past the hour, it'll set the variable back to three. This is just going to make the trigger fire every thirty minutes (so you could just remove everything except the #ts command). This means that all that trigger does is run #tset 41 (you missed the 41 in your example) every thirty minutes.
So either something's going on with the timing that you're not explaining, that means that the variable stuff is needed, or they're doing something they really don't need to. You could get the same effect just by running #tset 41 yourself every thirty minutes. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun May 18, 2008 4:46 pm |
Well, what I think they're trying to do is reset the timer whenever the clock changes, because the clock changes by half an hour every tick. So if suddenly the clock goes from 9:00 to 9:30, then you know the tick has ended and can reset instead of letting it get out of sync by continuing on until the 41 seconds has been reached.
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun May 18, 2008 4:52 pm |
Ah, that makes sense, then. If you fix the pattern, your use of #func, and your #tset command, it should work.
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun May 18, 2008 5:08 pm |
Code: |
#REGEX Tick_Timer {\d+\:({0|3})0[ap]m} {#IF (@minutes!=%1) {#VAR minutes {%1};#TS 41}} {GENERAL TRIGGERS}
|
doesn't match: 12:30pm |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun May 18, 2008 5:22 pm |
Because you didn't fix your regex. You've got {} in there that you don't need. I mentioned this above. Twice.
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun May 18, 2008 5:36 pm |
I didn't notice the "fix your pattern"
|
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Mon May 19, 2008 4:42 pm |
Why you insist on using regex all the time especially as you don't understand it and you also have been provided a perfectly acceptable trigger is somewhat beyond anybodies reason to perceive. You should also be aware that the 519 at the end is in order to set trigger options and since you've decided to leave it off you may not get the results you expect. The numbers at the end were an early way of setting trigger options in zMUD that Zugg eventually allowed to be set via words instead, I am not entirely sure it is sensible to assume that CMUD is capable of interpreting them but it is always worth a try. If I were you I would just use the following:
Code: |
#VARFUNC minutes {3}
#TRIGGER Tick_Timer {%d:({0|3})0[ap]m} {#if (@minutes!=%1) {#VAR minutes {%1};#TS 41}} {GENERAL TRIGGERS} 519 |
|
|
_________________ Taz :) |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon May 19, 2008 4:47 pm |
It works just fine after Fang's suggestions. Thanks.
|
|
|
|
|
|