summaryrefslogtreecommitdiff
path: root/doc/woe_time_explanation.txt
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-11-15 00:54:33 +0100
committerHaru <haru@dotalux.com>2015-11-15 00:57:00 +0100
commit34037c40d28c9fe179d930949320090448b249e9 (patch)
tree3fe4d79c6185df4f165beae47cc3e7a286ce5af8 /doc/woe_time_explanation.txt
parent8ee5eafc741d581579efd696765fb0646b72a553 (diff)
downloadhercules-34037c40d28c9fe179d930949320090448b249e9.tar.gz
hercules-34037c40d28c9fe179d930949320090448b249e9.tar.bz2
hercules-34037c40d28c9fe179d930949320090448b249e9.tar.xz
hercules-34037c40d28c9fe179d930949320090448b249e9.zip
Fixed too-generic constant names of gettime() types
- Follow-up to 3bd77ffc0daca508352834add828766490075aee - The names were too generic (not namespaced), and were easily clashing with custom (and potential future official) constants or variables. - Constants are now prefixed with a 'GETTIME_' namespace: - GETTIME_SECOND - GETTIME_MINUTE - GETTIME_HOUR - GETTIME_WEEKDAY - GETTIME_DAYOFMONTH - GETTIME_MONTH - GETTIME_YEAR - GETTIME_DAYOFYEAR - Fixed some excessive (and some times incorrect) parentheses in various scripts using gettime(). - Updated documentation. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'doc/woe_time_explanation.txt')
-rw-r--r--doc/woe_time_explanation.txt77
1 files changed, 36 insertions, 41 deletions
diff --git a/doc/woe_time_explanation.txt b/doc/woe_time_explanation.txt
index 9f288eae7..d030355f8 100644
--- a/doc/woe_time_explanation.txt
+++ b/doc/woe_time_explanation.txt
@@ -3,7 +3,7 @@
//===== By: ==================================================
//= erKURITA
//===== Current Version: =====================================
-//= 20120717
+//= 20151115
//===== Description: =========================================
//= Details on the behavior of the default WoE controller.
//============================================================
@@ -15,19 +15,8 @@ OnClock<time> triggers when <time> is reached.
The format is HHMM, where H = hour, M = minute.
OnClock2350: would run at 23:50, server time.
-gettime(<type>) is a function that checks for certain
-information regarding time. The types are:
-
- 1 - Seconds (of a minute)
- 2 - Minutes (of an hour)
- 3 - Hour (of a day), ranging from 0 to 23
- 4 - Weekday, ranging from 0 (Sunday) to 6 (Saturday)
- 5 - Day of the month
- 6 - Number of the month
- 7 - Year
- 8 - Day of the year
-
-This way, we can check for a desired minute, hour, day, month, etc.
+gettime(<type>) is a function that checks for certain information regarding
+time. For more information about it, see script_commands.txt.
-------------------------------------------------------------------------------
@@ -40,45 +29,36 @@ Now the structure:
These 4 labels will run one after the other, reaching the next check:
- if((gettime(4)==2) && (gettime(3)>=21 && gettime(3)<23)) goto L_Start;
- if((gettime(4)==4) && (gettime(3)>=21 && gettime(3)<23)) goto L_Start;
- if((gettime(4)==6) && (gettime(3)>=16 && gettime(3)<18)) goto L_Start;
+ if ((gettime(GETTIME_WEEKDAY) == TUESDAY && gettime(GETTIME_HOUR) >= 21 && gettime(GETTIME_HOUR) < 23) ||
+ (gettime(GETTIME_WEEKDAY) == THURSDAY && gettime(GETTIME_HOUR) >= 21 && gettime(GETTIME_HOUR) < 23) ||
+ (gettime(GETTIME_WEEKDAY) == SATURDAY && gettime(GETTIME_HOUR) >= 16 && gettime(GETTIME_HOUR) < 18)) {
+ agitstart();
+ }
This part will check for the times. Since both Start and End times run
through the same chain of commands, these are important checks to ensure
it's the right time. Let's take the following example:
- if((gettime(4)==2) && (gettime(3)>=21 && gettime(3)<23))
+ if (gettime(GETTIME_WEEKDAY) == TUESDAY && gettime(GETTIME_HOUR) >= 21 && gettime(GETTIME_HOUR) < 23)
-The first gettime() is checking for a type 4, the day of the week, and it's
-comparing it to the one desired, which is 2 (Tuesday). The function will
+The first gettime() is checking for type GETTIME_WEEKDAY, the day of the week,
+and it's comparing it to the one desired, which is TUESDAY. The function will
return either 1 (true) or 0 (false).
-The second gettime is checking type 3, the hour, and it's comparing
+The second gettime is checking type GETTIME_HOUR, the hour, and it's comparing
it to 21. If the first part is greater than or equal to (>=) the second part,
the comparison will return 1.
The third and last gettime is checking again for the hour, but the time has to be less
than the specified time (in this case, 23).
-Now, look at the parentheses. Parentheses are very important when making comparisons
-and conditions. Check the order of these. I'll place dummy characters for this example:
-
- if ((X && (Y && Z)) goto L_Start;
-
-It's saying, if Y and Z are true, the condition is met. Now let's use another set
-of dummy characters. We're checking if (Y && Z) = G:
-
- if (X && G) goto L_Start;
-
-It's saying that if X and G are true, the condition is met, thus proceeding to L_Start.
-
Now, the last part of the script, regarding the end of WoE time:
- if((gettime(4)==2) && (gettime(3)==23)) goto L_End;
- if((gettime(4)==4) && (gettime(3)==23)) goto L_End;
- if((gettime(4)==6) && (gettime(3)==18)) goto L_End;
- end;
+ if ((gettime(GETTIME_WEEKDAY) == TUESDAY && gettime(GETTIME_HOUR) == 23) ||
+ (gettime(GETTIME_WEEKDAY) == THURSDAY && gettime(GETTIME_HOUR) == 23) ||
+ (gettime(GETTIME_WEEKDAY) == SATURDAY && gettime(GETTIME_HOUR) == 18)) {
+ agitend();
+ }
This is the same as before, but it's checking for the day in the first gettime() and
the hour on the second. If both conditions are true, WoE will end. We're checking
@@ -95,8 +75,23 @@ An example of how to set the WoE so it starts on Monday, at 4 pm and ends up at
OnClock1600: // 16:00 = 4 pm
OnClock2200: // 22:00 = 10 pm
- OnAgitInit: // This can only be written once: put OnClock above and the checks below.
-
- if ((gettime(4)==1) && (gettime(3)>=16 && gettime(3)<22)) goto L_Start;
- if ((gettime(4)==1) && (gettime(3)==22) goto L_End;
+ OnAgitInit: // This label should appear once and only once in the script
+
+ // starting time checks
+ if (gettime(GETTIME_WEEKDAY) == MONDAY && gettime(GETTIME_HOUR) >= 16 && gettime(GETTIME_HOUR) < 22) {
+ if (!agitcheck()) {
+ agitstart;
+ callsub S_DisplayOwners;
+ }
+ end;
+ }
+
+ // end time checks
+ if (gettime(GETTIME_WEEKDAY) == MONDAY && gettime(GETTIME_HOUR) == 22) {
+ if (agitcheck()) {
+ agitend;
+ callsub S_DisplayOwners;
+ }
+ end;
+ }
end; // Don't forget this!