mirror of
https://gitlab.com/lunovox/computing.git
synced 2025-03-15 14:41:20 +00:00
88 lines
2.6 KiB
Lua
88 lines
2.6 KiB
Lua
|
|
modComputing.getTextNowWeekDay3S = function()
|
|
local txtWeekDays3S = {
|
|
"Sun", --Sunday
|
|
"Mon", --Monday
|
|
"Tue", --Tuesday
|
|
"Wed", --Wednesday
|
|
"Thu", --Thursday
|
|
"Fri", --Friday
|
|
"Sat", --Saturday
|
|
}
|
|
local totalDays = core.get_day_count()
|
|
local nowRow = math.floor((totalDays-1)/7)+1
|
|
local nowCol = totalDays - ((nowRow-1)*7)
|
|
return txtWeekDays3S[nowCol]
|
|
|
|
end
|
|
|
|
modComputing.getTextNowTime = function()
|
|
local current_time = math.floor(core.get_timeofday() * 1440)
|
|
local minutes = current_time % 60
|
|
local hour = (current_time - minutes) / 60
|
|
return ("%02d:%02d"):format(hour, minutes)
|
|
end
|
|
|
|
modComputing.getTextNowDate = function()
|
|
local totalDays = core.get_day_count()
|
|
local nowYear = totalDays/(28*4)
|
|
local nowMount = (math.floor(totalDays/28)%4)+1
|
|
local txtMounts3S = {"SPR", "SUM", "AUT", "WIN"} --SPRING, SUMMER, AUTUMN, WINTER
|
|
local nowDay = math.floor(totalDays%28)+1
|
|
local nowDate = ("%04d-%3s-%02d"):format((nowYear+1), txtMounts3S[nowMount], nowDay)
|
|
return nowDate
|
|
end
|
|
|
|
modComputing.getTextClockBar = function()
|
|
return modComputing.getTextNowWeekDay3S()..", "..modComputing.getTextNowDate().." "..modComputing.getTextNowTime()
|
|
end
|
|
|
|
modComputing.getFormSmartphone = function(player)
|
|
local formspec = ""
|
|
.."formspec_version[6]"
|
|
.."size["..(10*271/484)..",10.0,true]"
|
|
.."no_prepend[]"
|
|
.."bgcolor[#08080844;true]" --Padrão: #080808BB | true = 100% transparente
|
|
--.."background[-0.75,-2.00;"..(10*271/484)..",10.0;text_smartphone_271x484.png;true]"
|
|
.."image[0,0;"..(10*271/484)..",10.0;text_smartphone_271x484.png;true]"
|
|
.."style_type[label;font=mono;font_size=11;textcolor=#FFFFFF]"
|
|
.."label[0.75,1.975;"..core.formspec_escape(modComputing.getTextClockBar()).."]"
|
|
.."button_exit[0.75,2.50;1.5,1.5;btnClose;"..core.formspec_escape("Banana\nPhone").."]"
|
|
|
|
return formspec
|
|
end
|
|
|
|
modComputing.show_smartphone = function(player)
|
|
local playername = player:get_player_name()
|
|
core.show_formspec(playername, "frmSmartphone", modComputing.getFormSmartphone(player))
|
|
end
|
|
|
|
|
|
core.register_craftitem("computing:smartphone", {
|
|
description = "SMARTPHONE",
|
|
inventory_image = "icon_smartphone_128x128.png",
|
|
on_use = function(itemstack, player, pointed_thing)
|
|
modComputing.show_smartphone(player)
|
|
end,
|
|
})
|
|
|
|
core.register_craft({
|
|
output = 'computing:smartphone',
|
|
recipe = {
|
|
{"default:paper" ,"" ,""},
|
|
{"" ,"" ,""},
|
|
{"" ,"" ,""},
|
|
}
|
|
})
|
|
|
|
core.register_alias("smartphone", "computing:smartphone")
|
|
|
|
|
|
|
|
--[[
|
|
modComputing.add_app("lib_computing:smartphone", {
|
|
iconname = "SMARTPHONE",
|
|
iconimage = "icon_smartphone.png",
|
|
on_iconclick = modComputing.show_smartphone_config,
|
|
})
|
|
--]]
|