时间罗盘小界面模组

--星空露珠工作室制作

--时间罗盘

--作者韩永旗

--作者迷你号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_OC4 小时前
从一次栈溢出报错说起,我把递归彻底扒明白了
javascript·算法·程序员
千纸鹤安安9 小时前
千问Qwen-AgentWorld来了:一个语言模型搞定七大Agent场景,GPT-5.4都输了
算法
七牛开发者11 小时前
MCP 到底是什么?为什么 Agent 都想接上它
算法·aigc·agent
北域码匠15 小时前
冒泡排序太慢?鸡尾酒排序双向优化,原生 C# 零第三方库完整代码
数据结构·排序算法·泛型·c# 算法·鸡尾酒排序·原生 c# 开发·冒泡排序优化·嵌入式算法
kisshyshy18 小时前
从递归到迭代,一文吃透二叉树的核心知识与 JavaScript 实现
javascript·算法·代码规范
To_OC1 天前
LC 49 字母异位词分组:想到哈希表很简单,选对 key 才是精髓
javascript·算法·leetcode
用户938515635071 天前
从 O(n²) 到 O(nlogn):一文读懂快速排序的“快”与“妙”
javascript·算法
To_OC1 天前
手写快排次次翻车?别死背快排模板了,这才是面试官想听的底层逻辑
javascript·算法·排序算法