summaryrefslogtreecommitdiff
path: root/world/map/npc/functions
diff options
context:
space:
mode:
authorWushin <pasekei@gmail.com>2015-01-07 21:29:13 -0600
committerWushin <pasekei@gmail.com>2015-01-07 21:29:13 -0600
commit82e6d9f8a5e7a94617b91c8b0caf64a2457339ab (patch)
tree10c1a464bd66b705b16d5b2a3331b9c63f534f15 /world/map/npc/functions
parent2b01da2c4fd2585be9487a8ff50028ac3c175f5e (diff)
parentc2e75cb4955b00474f275e3ef5d3494d9fd68274 (diff)
downloadserverdata-82e6d9f8a5e7a94617b91c8b0caf64a2457339ab.tar.gz
serverdata-82e6d9f8a5e7a94617b91c8b0caf64a2457339ab.tar.bz2
serverdata-82e6d9f8a5e7a94617b91c8b0caf64a2457339ab.tar.xz
serverdata-82e6d9f8a5e7a94617b91c8b0caf64a2457339ab.zip
Merge pull request #216 from mekolat/clearvars
fight club v0.5
Diffstat (limited to 'world/map/npc/functions')
-rw-r--r--world/map/npc/functions/time.txt71
1 files changed, 71 insertions, 0 deletions
diff --git a/world/map/npc/functions/time.txt b/world/map/npc/functions/time.txt
index 9f141d3e..695c4cec 100644
--- a/world/map/npc/functions/time.txt
+++ b/world/map/npc/functions/time.txt
@@ -55,3 +55,74 @@ function|script|time_stamp
return;
}
+
+
+
+// HumanTime - returns a human-readable time
+// author: meko
+
+// Variables:
+// input @ms integer
+// output @time$ string
+
+function|script|HumanTime
+{
+ set @time$, "now";
+ if(@ms < 1000) goto L_Millis; // under 1 second we have nothing to count
+ set @seconds, @ms / 1000;
+ set @ms, @ms % 1000;
+ if(@seconds < 60) goto L_Seconds;
+ set @minutes, @seconds / 60;
+ set @seconds, @seconds % 60;
+ if(@minutes < 60) goto L_Minutes;
+ set @hours, @minutes / 60;
+ set @minutes, @minutes % 60;
+ if(@hours < 60) goto L_Hours;
+ return;
+
+L_Millis:
+ set @time$, @ms + "ms";
+ return;
+
+L_Seconds:
+ set @unit$, "second";
+ if(@seconds > 1) set @unit$, "seconds";
+ set @unit2$, "millisecond";
+ if(@ms > 1) set @unit2$, "milliseconds";
+ set @time$, @seconds + " " + @unit$;
+ if(@ms) set @time$, @time$ + " and " + @ms + " " + @unit2$;
+ return;
+
+L_Minutes:
+ set @unit$, "minute";
+ if(@minutes > 1) set @unit$, "minutes";
+ set @unit2$, "second";
+ if(@seconds > 1) set @unit2$, "seconds";
+ set @unit3$, "millisecond";
+ if(@ms > 1) set @unit3$, "milliseconds";
+ set @time$, @minutes + " " + @unit$;
+ set @separator$, " and ";
+ if(@ms) set @separator$, ", ";
+ if(@seconds) set @time$, @time$ + @separator$ + @seconds + " " + @unit2$;
+ if(@ms) set @time$, @time$ + " and " + @ms + " " + @unit3$;
+ return;
+
+L_Hours:
+ set @unit$, "hour";
+ if(@hours > 1) set @unit$, "hours";
+ set @unit2$, "minute";
+ if(@minutes > 1) set @unit2$, "minutes";
+ set @unit3$, "second";
+ if(@seconds > 1) set @unit3$, "seconds";
+ set @unit4$, "millisecond";
+ if(@ms > 1) set @unit4$, "milliseconds";
+ set @time$, @hours + " " + @unit$;
+ set @separator$, " and ";
+ if(@seconds || @ms) set @separator$, ", ";
+ if(@minutes) set @time$, @time$ + @separator$ + @minutes + " " + @unit2$;
+ set @separator$, " and ";
+ if(@ms) set @separator$, ", ";
+ if(@seconds) set @time$, @time$ + @separator$ + @seconds + " " + @unit3$;
+ if(@ms) set @time$, @time$ + " and " + @ms + " " + @unit4$;
+ return;
+}