时间罗盘小界面模组

--星空露珠工作室制作

--时间罗盘

--作者韩永旗

--作者迷你号247312290

--罗盘时钟

--星空露珠工作室制作

--数字换中文

local Script = {}

local ui={"7578885190391279522-144925","7578885190391279522-144925_"}

--显示框 2 年份228 节日158

local ui0={3,64,125,150,183,215}

local data={{'秒',0,59,6,1,370, 15},{'分',0,59,6,1,300, 14},{'时',0,23,15,1,235, 13},{'星期',1,7,45,0,185, 13},{'号',1,31,11.25,0,135, 12},{'月',1,12,30,0,75, 13},}

-- 组件启动时调用

function Script:OnStart()

-- self:AddTriggerEvent(TriggerEvent.UIButtonClick, self:OnUIButtonClick, "元件id")

self:AddTriggerEvent(TriggerEvent.GameAnyPlayerEnterGame, self.uiplayer)

end

local zhChar = {'一','二','三','四','五','六','七','八','九'}

function Script:formatNumber(num)

if type(num)~='number' then return num..'is not a num' end

if num>99 then return num..'不是两位数' end

if num==0 then return '零'

elseif num>0 and num<10 then return zhChar[num]

elseif num>=10 then

if num==10 then return '十' end

if num%10==0 then return zhChar[math.floor(num/10)]..'十'

elseif num>10 and num<20 then return '十'..zhChar[num%10]

else return zhChar[math.floor(num/10)]..'十'..zhChar[num%10]

end

end

end

--设置元件图片

function Script:setgip(p,id,url) CustomUI:SetTexture(p,ui[1],ui[2]..id,url) end

--设置元件大小

function Script:setsize(p,id,d,h) CustomUI:SetSize(p,ui[1],ui[2]..id,d,h) end

--设置元件位置

function Script:setpos(p,id,x,y) CustomUI:SetPosition(p,ui[1],ui[2]..id,x,y) end

--设置元件颜色

function Script:setcolor(p,id,color) CustomUI:SetColor(p,ui[1],ui[2]..id,color) end

--显示元件

function Script:show(p,id) CustomUI:ShowElement(p,ui[1],ui[2]..id) end

--隐藏元件

function Script:hide(p,id) CustomUI:HideElement(p,ui[1],ui[2]..id) end

--设置文字框

function Script:setstr(p,id,str) CustomUI:SetText(p,ui[1],ui[2]..id,str) end

--设置元件文字大小

function Script:setfontsize(p,id,size) CustomUI:SetFontSize(p, ui[1],ui[2]..id,size) end

--旋转元件

function Script:rotate(p,pi) CustomUI:RotateElement(p,ui[1],ui[2]..button.rotate1,pi) Trigger.UI:setText(p,ui[1],ui[2]..button.rotate2,pi) end

--元件平滑旋转到指定角度

function Script:smoothrotateto(p,id,time,angle) CustomUI:SmoothRotateTo(p,ui[1],ui[2]..id,time,angle) end

--元件平滑旋转到相对角度

function Script:smoothrotateby(p,id,time,angle) CustomUI:SmoothRotateBy(p,ui[1],ui[2]..id,time,angle) end

--播放声音

function Script:music(p) Actor:PlaySoundEffectById(p,10948,15,1,false) end

--绘画界面

function Script:upui(p)

self:show(p,1)

--self:setpos(p,1,0,0)

self:setsize(p,1,0,0)

self:show(p,2)

self:setpos(p,2,-20,0)

self:setsize(p,2,400,25)

self:show(p,228)

self:setpos(p,228,-15,0)

self:setsize(p,228,70,20)

local t=os.date("*t",timeInterval)

self:setstr(p,228,t.year.."年")

self:setfontsize(p,228,15)

for k,v in pairs(data) do

local id=ui0[k]

self:show(p,id)

self:setpos(p,id,0,0)

self:setsize(p,id,0,0)

local str=''

for i=v[2],v[3] do if v[1]=='星期' then if i==1 then str=v[1]..'日' elseif i==6 then str='星期伍' else str=v[1]..self:formatNumber(i-1) end else str=self:formatNumber(i)..v[1] end

local id=ui0[k]+i+v[5]

--local color=Graphics:getRandomColor()

local color=string.format("0x%x",math.random(0,255))..string.format("%x",math.random(0,255))..string.format("%x",math.random(0,255))

local angle=-(i+v[5]-1)*v[4]

self:show(p,id)

self:setpos(p,id,0,0)

self:setsize(p,id,v[6],20)

self:setstr(p,id,str)

self:setcolor(p,id,color)

self:setfontsize(p,id,v[7])

self:smoothrotateto(p,id,4,angle)

end

self:ThreadWait(3)

end

self:ThreadWait(1)

self:uptime(p)

end

function Script:uptime(p)

threadpool:work(function()

local t=os.date("*t",timeInterval)

--print('当前时间:'..t.year.."年"..t.month.."月"..t.day.."日"..t.wday..t.hour..":"..t.min ..":"..t.sec)

local time={t.sec,t.min,t.hour,t.wday,t.day,t.month,t.year}

for k,v in pairs(data) do

local id=ui0[k]

local angle=(time[k]+v[5]-1)*v[4]

threadpool:work(function() self:smoothrotateto(p,id,0.5,angle) end)

end

end)

self:music(p)

self:ThreadWait(1)

self:uptime(p)

end

function Script:uiplayer(e)

local p=e.CurEventParam.TriggerByPlayer

threadpool:work(function() self:upui(p) end)

end

--print(string.format("0x%x",math.random(0,255))..string.format("%x",math.random(0,255))..string.format("%x",math.random(0,255)))

return Script

相关推荐
claem12 小时前
Mac端 Python脚本创建与理解
开发语言·python·macos
CoderCodingNo12 小时前
【GESP】C++五级练习题 luogu-B3628 机器猫斗恶龙
开发语言·c++·算法
what丶k12 小时前
你应该更新的 Java 知识:Record 特性深度解析
java·开发语言
橘颂TA13 小时前
【剑斩OFFER】算法的暴力美学——力扣 1020 题:飞地的数量
数据结构·c++·算法·leetcode·职场和发展·结构与算法
mango_mangojuice13 小时前
C++ 学习笔记(string类)
开发语言·c++·笔记·学习
hetao173383713 小时前
2026-01-27~28 hetao1733837 的刷题记录
c++·笔记·算法
2301_8223663513 小时前
C++中的智能指针详解
开发语言·c++·算法
探序基因13 小时前
查看bam文件指定位点的基因测序情况计算基因型
数据结构·学习方法
kdniao113 小时前
PHP 页面中如何实现根据快递单号查询物流轨迹?对接快递鸟在途监控 API 实操
android·开发语言·php
郑州光合科技余经理13 小时前
同城配送调度系统实战:JAVA微服务
java·开发语言·前端·后端·微服务·中间件·php