Total Miner Mods UI & Quality of Life

World Time HUD Element Script (LUA)

  • 194 views 0 today
  • save_alt 0 downloads
Progress
100% complete
  • 6
  • 4
Funiverse Minnesota
Lvl 8Cadet Goose
12
This is a simple script that prints out the world time in AM/PM format to the left side of the screen. Use the "While Loop" version if you plan to initialize the script yourself. Use the "World Update" version if you just want to drop it into your world update script.


Please credit me if you use this on your map


World Update Version:
wait(250)
local hour = get_hour()
local int,frac = math.modf(hour)
local hour24 = int
local hour12
local minute = string.format("%02d", math.floor(60*frac))
local dayhalf

if hour > 13 then
hour12 = int - 12
dayhalf = "PM"
else
hour12 = hour24
dayhalf = "AM"
end
if int == 0 then
hour12 = 12
end

if int == 5 then
color = color.new(171,111,46,255)
end
if int == 7 then
color = color.new(45,194,224,255)
end
if int == 12 then
color = color.new(51,90,196,255)
end
if int == 17 then
color = color.new(171,111,46,255)
end
if int == 19 then
color = color.new(255,255,255,255)
end


hud_text("Time", true, hour12..":"..minute.." "..dayhalf, udim2(0.01, 0, 0.5, 0), 3, color, 0, "")


While Loop Version:
local pos = udim2(0.01, 0, 0.5, 0)
local color = color(255,255,255,255)
print("World Clock Started")

while true do
wait(250)
local hour = get_hour()
local int,frac = math.modf(hour)
local hour24 = int
local hour12
local minute = string.format("%02d", math.floor(60*frac))
local dayhalf

if hour > 13 then
hour12 = int - 12
dayhalf = "PM"
else
hour12 = hour24
dayhalf = "AM"
end
if int == 0 then
hour12 = 12
end

if int == 5 then
color = color.new(171,111,46,255)
end
if int == 7 then
color = color.new(45,194,224,255)
end
if int == 12 then
color = color.new(51,90,196,255)
end
if int == 17 then
color = color.new(171,111,46,255)
end
if int == 19 then
color = color.new(255,255,255,255)
end


hud_text("Time", true, hour12..":"..minute.." "..dayhalf, pos, 3, color, 0, "")
end

More like this

  Have something to say?

Welcome