diff options
author | mekolat <mekolat@gmail.com> | 2014-11-19 17:21:24 -0500 |
---|---|---|
committer | mekolat <mekolat@gmail.com> | 2014-11-24 20:56:59 -0500 |
commit | c2e75cb4955b00474f275e3ef5d3494d9fd68274 (patch) | |
tree | 4424fdb2e8a7de5d187423686daefafefbcb7034 /world/map/npc/functions | |
parent | a23d11f9299e27899486439a0dcfb0711c6fad24 (diff) | |
download | serverdata-c2e75cb4955b00474f275e3ef5d3494d9fd68274.tar.gz serverdata-c2e75cb4955b00474f275e3ef5d3494d9fd68274.tar.bz2 serverdata-c2e75cb4955b00474f275e3ef5d3494d9fd68274.tar.xz serverdata-c2e75cb4955b00474f275e3ef5d3494d9fd68274.zip |
sanguine vault => v0.5
Diffstat (limited to 'world/map/npc/functions')
-rw-r--r-- | world/map/npc/functions/time.txt | 71 |
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; +} |