时间罗盘小界面模组

--星空露珠工作室制作

--时间罗盘

--作者韩永旗

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

elseif num>=10 then

if num==10 then return '十' end

if num%10==0 then return zhCharmath.floor(num/10)..'十'

elseif num>10 and num<20 then return '十'..zhCharnum%10

else return zhCharmath.floor(num/10)..'十'..zhCharnum%10

end

end

end

--设置元件图片

function Script:setgip(p,id,url) CustomUI:SetTexture(p,ui1,ui2..id,url) end

--设置元件大小

function Script:setsize(p,id,d,h) CustomUI:SetSize(p,ui1,ui2..id,d,h) end

--设置元件位置

function Script:setpos(p,id,x,y) CustomUI:SetPosition(p,ui1,ui2..id,x,y) end

--设置元件颜色

function Script:setcolor(p,id,color) CustomUI:SetColor(p,ui1,ui2..id,color) end

--显示元件

function Script:show(p,id) CustomUI:ShowElement(p,ui1,ui2..id) end

--隐藏元件

function Script:hide(p,id) CustomUI:HideElement(p,ui1,ui2..id) end

--设置文字框

function Script:setstr(p,id,str) CustomUI:SetText(p,ui1,ui2..id,str) end

--设置元件文字大小

function Script:setfontsize(p,id,size) CustomUI:SetFontSize(p, ui1,ui2..id,size) end

--旋转元件

function Script:rotate(p,pi) CustomUI:RotateElement(p,ui1,ui2..button.rotate1,pi) Trigger.UI:setText(p,ui1,ui2..button.rotate2,pi) end

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

function Script:smoothrotateto(p,id,time,angle) CustomUI:SmoothRotateTo(p,ui1,ui2..id,time,angle) end

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

function Script:smoothrotateby(p,id,time,angle) CustomUI:SmoothRotateBy(p,ui1,ui2..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=ui0k

self:show(p,id)

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

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

local str=''

for i=v2,v3 do if v1=='星期' then if i==1 then str=v1..'日' elseif i==6 then str='星期伍' else str=v1..self:formatNumber(i-1) end else str=self:formatNumber(i)..v1 end

local id=ui0k+i+v5

--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+v5-1)*v4

self:show(p,id)

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

self:setsize(p,id,v6,20)

self:setstr(p,id,str)

self:setcolor(p,id,color)

self:setfontsize(p,id,v7)

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=ui0k

local angle=(timek+v5-1)*v4

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

相关推荐
To_OC7 小时前
LC 131 分割回文串:刚学回溯时,我连怎么切字符串都想不明白
javascript·算法·leetcode
旖-旎8 小时前
LeetCode 518:零钱兑换||(完全背包)—— 题解
c++·算法·leetcode·动态规划·背包问题
灯澜忆梦8 小时前
GO_并发编程---定时器
开发语言·后端·golang
-银雾鸢尾-8 小时前
C#中的StringBuilder相关方法
开发语言·c#
To_OC8 小时前
LC 42 接雨水:暴力超时卡半天?前后缀数组一用就通了
javascript·算法·leetcode
-银雾鸢尾-9 小时前
C#中结构体与类的区别;抽象类与接口的区别
开发语言·c#
delishcomcn9 小时前
AI视觉识别+分切算法:电化铝缺陷检测与裁切一体化解锁
人工智能·算法
触底反弹9 小时前
深入理解大模型采样:Temperature、Top-K、Top-P 的原理与实战
人工智能·算法·面试
大模型码小白10 小时前
【Python零基础教程】继承、多态与魔法函数:面向对象编程三大核心特性详解
java·大数据·开发语言·人工智能·python·ai编程
雪碧聊技术10 小时前
力扣 LCR 091. 粉刷房子 —— 动态规划入门详解
算法·动态规划