1st half
<script>
<![CDATA[
function TT()
-----------------------------------------------------------------------------
--REFERENCE FOR THRESHOLDRPG TIMING
--1 game hour - 5 REAL minutes
--1 game day - 2 REAL hours
--1 game month - 60 REAL hours
--1 game year - 30 REAL days
--Dawn - January
--Cuspis - February
--Thawing - March
--Renasci - April
--Tempest - May
--Serenus - June
--Solaria - July
--Torrid - August
--Sojourn - September
--Hoerfest - October
--Twilight - November
--Deepchill - December
--Winter Spring Summer Autumn
--Deepchill Thawing Serenus Sojourn
--Dawn Renasci Solaria Hoerfest
--Cuspis Tempest Torrid Twilight
-----------------------------------------------------------------------------
--Variables
real_time = os.date ("*t")
if ingame_hour == nil then ingame_hour = tonumber(GetVariable("T_Toll")) end --Toll
if ingame_date == nil then ingame_date = tonumber(GetVariable("T_Date")) end -- Date
if ingame_month == nil then ingame_month = GetVariable("T_Month") end -- Month (String)
if ingame_year == nil then ingame_year = tonumber(GetVariable("T_Year")) end -- Year
if ingame_season == nil then ingame_season = GetVariable("T_Season") end -- Season
if current_month == nil then current_month = GetVariable("current_month") end
if Bank_Status == nil then Bank_Status = "Banks are closed" end
months = {}
months = {
'Dawn',
'Cuspis',
'Thawing',
'Renasci',
'Tempest',
'Serenus',
'Solaria',
'Torrid',
'Sojourn',
'Hoerfest',
'Twilight',
'Deepchill'
}
real_time_sec = real_time.sec
real_time_min = real_time.min
real_time_hour = real_time.hour
-- Suffix changes
if(ingame_hour == 1 or ingame_hour == 21) then ingame_suffix = "st"
elseif ingame_hour == 2 or ingame_hour == 22 then ingame_suffix = "nd"
elseif ingame_hour == 3 or ingame_hour == 23 then ingame_suffix = "rd"
else ingame_suffix = "th" end
increase = 1
-- Every 5 minutes is 1 toll. Divide by %5
if real_time_min % 5 == 0 then
ingame_hour = ingame_hour + increase
SetVariable("T_Toll", ingame_hour)
if(ingame_hour >= 9 and ingame_hour < 11) then
ColourNote("yellow", "black", "****** It is "..ingame_hour..ingame_suffix.." Toll. Sable Bank is open! *******")
Bank_Status = "Sable Bank is open!"
elseif(ingame_hour >= 11 and ingame_hour <= 16) then
ColourNote("yellow", "green", "****** It is "..ingame_hour..ingame_suffix.." Toll. Both Banks are open! *******")
Bank_Status = "Both Banks are open!"
elseif(ingame_hour > 16 and ingame_hour <= 19) then
ColourNote("red", "green", "****** It is "..ingame_hour..ingame_suffix.." Toll. Thrace Bank is open! *******")
Bank_Status = "Thrace Bank is open!"
else
Bank_Status = "Banks are Closed"
end
else
ingame_hour = tonumber(GetVariable("T_Toll")) --Toll
end
--Find current month and index
for index, value in pairs(months) do
if value == ingame_month then
current_month = index;
end
end
--Checks time for timer
if(ingame_hour == 25) -- 0 - 24 tolls
then
ingame_hour = 0
SetVariable("T_Toll", ingame_hour)
ingame_date = ingame_date + increase
SetVariable("T_Date", ingame_date)
elseif(ingame_date > 30) -- 30 days in a month
then
ingame_date = 1
current_month = (current_month+1) -- Sets next month
ingame_month = months[current_month]
elseif(current_month > 12) -- Next year
then
ingame_year = ingame_year + 1
end -- 1st if
Display_Threshold_Time(ingame_season, ingame_year, ingame_month, ingame_suffix, ingame_date, ingame_hour, Bank_Status) -- Send to Window
end -- TT
function Display_Threshold_Time(Season, Year, Month, Suffix, Date, Hour, Bank)
THTime = "THTime_" .. GetPluginID () .. ":ThresholdTime" -- get a unique name, ensure not empty if outside plugin
local font = "f"
local font2 = "f2"
WindowCreate (THTime, 0, 0, 0, 0, 6, 0, 0) -- Create Window Placeholder
--creating Fonts
-- Trebuchet MS, 28 point, bold
WindowFont (THTime, font, "Trebuchet MS", 12, true, false, false, false)
WindowFont (THTime, font2, "Trebuchet MS", 10, true, false, false, false)
local max_width = WindowTextWidth(THTime, font, "The Time in Threshold")
local font_height = WindowFontInfo(THTime, font, 1)
local window_width = max_width + 40
local window_height = font_height * 4
--make window with size
WindowCreate(THTime, 0, 0, window_width, window_height, 6, 0, ColourNameToRGB("black"))
WindowRectOp(THTime, 5, 0, 0, 0, 0, 5, 15 + 0x1000) -- Border
-- Heading
WindowText(THTime, font, "The Time in Threshold", 25, 5, 0, 0, ColourNameToRGB("white"), false)
--Each line
local y = font_height + 2 --Font Y axis
local x = 5 -- Font X axis
--Time and Date
WindowText(THTime, font, Hour..Suffix.." Toll ", (x+2), (y+20), 0, 0, ColourNameToRGB("magenta"), false) -- Toll
WindowText(THTime, font, Month.." "..Date..", "..Year.."; "..Season, x, y, 0, 0, ColourNameToRGB("magenta"), false) -- Adds Month/date/year
if Bank_Status == "Thrace Bank is open!" or Bank_Status == "Sable Bank is open!" or Bank_Status == "Both Banks are open!" then
WindowText(THTime, font2, Bank, (x+75), (y+23), 0, 0, ColourNameToRGB("green"), false) -- Bank Hours open
else WindowText(THTime, font2, Bank, (x+75), (y+23), 0, 0, ColourNameToRGB("red"), false) end -- Bank Hours closed
--Real Time & Date
WindowText(THTime, font, (os.date("%I")..":"..os.date("%M").." "..os.date("%p").." "..os.date("%x")) , x+35, y+40, 0, 0, ColourNameToRGB("white"), false)
WindowShow(THTime, true) -- Show window
end -- Display_Threshold_Time
]]>
</script>
|