Mudlet Scripts

From LSWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 19:30, 20 January 2021 (edit)
Esmene (Talk | contribs)

← Previous diff
Revision as of 21:58, 20 January 2021 (edit)
Esmene (Talk | contribs)

Next diff →
Line 25: Line 25:
if inmonnm == "Nov" then inmon = 11 end if inmonnm == "Nov" then inmon = 11 end
if inmonnm == "Dec" then inmon = 12 end if inmonnm == "Dec" then inmon = 12 end
- systime = os.time()+ timestamp = os.time{day=inday, year=inyear, month=inmon, hour=inhr, min=inmin}
- offset = (os.time{day=1, year=1970, month=1})+
- basetime = os.time{day=inday, year=inyear, month=inmon, hour=inhr, min=inmin}+
- utctime = basetime + offset+
- timestamp = os.difftime(utctime, reference)+
year = math.floor(timestamp/16200000)+480 year = math.floor(timestamp/16200000)+480
month = math.floor(timestamp/1620000)%10+1 month = math.floor(timestamp/1620000)%10+1

Revision as of 21:58, 20 January 2021

This is a place for mudlet scripts that may be of interest to others.

Datetime conversion

This script converts datetimes (for example, from channel histories) into the corresponding date and time from the in-game calendar:

Trigger:

(\d+) (\w+) (\d+) (\d+):(\d+)

Script:

inyear = matches[2]
inmonnm = matches[3]
inday = matches[4]
inhr = matches[5]-3 -- This includes a manual offset for the difference between the system time in EST and my local time in PST.
inmin = matches[6]
if inmonnm == "Jan" then inmon = 1 end
if inmonnm == "Feb" then inmon = 2 end
if inmonnm == "Mar" then inmon = 3 end
if inmonnm == "Apr" then inmon = 4 end
if inmonnm == "May" then inmon = 5 end
if inmonnm == "Jun" then inmon = 6 end
if inmonnm == "Jul" then inmon = 7 end
if inmonnm == "Aug" then inmon = 8 end
if inmonnm == "Sep" then inmon = 9 end
if inmonnm == "Oct" then inmon = 10 end
if inmonnm == "Nov" then inmon = 11 end
if inmonnm == "Dec" then inmon = 12 end
timestamp = os.time{day=inday, year=inyear, month=inmon, hour=inhr, min=inmin}
year = math.floor(timestamp/16200000)+480
month = math.floor(timestamp/1620000)%10+1
day = math.floor(timestamp/54000)%30+1
hour = math.floor(timestamp/1800)%30
hour = string.format("%02i",hour)
minute = math.floor(timestamp/30)%60
minute = string.format("%02i",minute)
selectCaptureGroup(2)
replace(year)
selectCaptureGroup(3)
replace(month)
selectCaptureGroup(4)
replace(day)
selectCaptureGroup(5)
replace(hour)
selectCaptureGroup(6)
replace(minute)
Personal tools