时间罗盘小界面模组

--星空露珠工作室制作

--时间罗盘

--作者韩永旗

--作者迷你号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

相关推荐
Klong.k8 分钟前
判断是不是素数题目
数据结构·算法
QQsuccess9 分钟前
AI全体系保姆级详讲——第一部分:了解AI基本定义
人工智能·算法
_日拱一卒12 分钟前
LeetCode:移动零
算法·leetcode·职场和发展
沉沙丶14 分钟前
关于matlab分析电流THD的一些探究和记录
开发语言·matlab·电机控制·foc·永磁同步电机·模型预测·预测控制
chase。16 分钟前
Python包构建工具完全指南:python -m build 使用详解
开发语言·chrome·python
SuperEugene20 分钟前
前端 utils 工具函数规范:拆分 / 命名 / 复用全指南,避开全局污染等高频坑|编码语法规范篇
开发语言·前端·javascript
A923A26 分钟前
【洛谷刷题 | 第四天】
算法·前缀和·贪心·洛谷·差分
古城小栈28 分钟前
Go 底层代码的完整分类
开发语言·后端·golang
耳冉鹅33 分钟前
Go无锁共享内存环形缓冲区设计
开发语言·golang
bai_lan_ya38 分钟前
使用linux的io文件操作综合实验_处理表格
linux·服务器·算法