150

回帖

1万

金币

7114

积分

积分
7114
发表于 2023-8-25 20:10:12 | 显示全部楼层 |阅读模式

马上注册,下载996引擎,与更多游戏开发者交流。

您需要 登录 才可以下载或查看,没有账号?注册

×
引擎版本:3.4
问题描述:正计时的情况用个人定时器有没有办法实现图中的格式呢?或者有没有其他什么方法可以实现?

QQ截图20230825200830.png

最后回复时间:2023-08-28 14:23:51官方回复了此贴
回复

使用道具 举报

175

回帖

1万

金币

8228

积分

积分
8228
发表于 2023-8-25 22:02:41 | 显示全部楼层
function secondsToTime(ts)

    local seconds = math.mod(ts, 60)
    local min = math.floor(ts/60)
    local hour = math.floor(min/60)
    local day = math.floor(hour/24)
   
    local str = ""
        
    if tonumber(seconds) > 0 and tonumber(seconds) < 60 then
        str = ""..seconds.."秒" ..str
    end

    if tonumber(min - hour*60)>0 and tonumber(min - hour*60)<60 then
        str = ""..(min - hour*60).."分"..str
    end

    if tonumber(hour - day*24)>0 and tonumber(hour - day*60)<24 then
        str = (hour - day*24).."时"..str
    end
   
    if tonumber(day) > 0 then
        str = day.."天"..str
    end

    return str
end
回复

使用道具 举报

150

回帖

1万

金币

7114

积分

积分
7114
 楼主| 发表于 2023-8-27 16:16:25 | 显示全部楼层
iflyw 发表于 2023-8-25 22:02
function secondsToTime(ts)

    local seconds = math.mod(ts, 60)

有点屌,但是大佬,我不会lua,怎么破
回复

使用道具 举报

175

回帖

1万

金币

8228

积分

积分
8228
发表于 2023-8-27 20:54:03 | 显示全部楼层
ating995 发表于 2023-8-27 16:16
有点屌,但是大佬,我不会lua,怎么破

拷贝到luafunc-0.txt文件里,然后就可以调用了。secondstotime 时间,注意改成小写。
其他看帮助
回复

使用道具 举报

95

回帖

2582

金币

1593

积分

积分
1593
发表于 2023-8-27 23:06:08 | 显示全部楼层
iflyw 发表于 2023-8-27 20:54
拷贝到luafunc-0.txt文件里,然后就可以调用了。secondstotime 时间,注意改成小写。
其他看帮助 ...

调用了 我咋读出是0 跪求高手解答下,
回复

使用道具 举报

175

回帖

1万

金币

8228

积分

积分
8228
发表于 2023-8-28 08:58:11 | 显示全部楼层
返回读取的是<$luaresult>,把secondstotime 加入到LuaFuncList.txt里
回复

使用道具 举报

95

回帖

2582

金币

1593

积分

积分
1593
发表于 2023-8-28 11:12:56 | 显示全部楼层
iflyw 发表于 2023-8-28 08:58
返回读取的是,把secondstotime 加入到LuaFuncList.txt里

对我是怎么调用的 ,但读出来是0的参数,
回复

使用道具 举报

9466

回帖

1万

金币

1万

积分

积分
14852
发表于 2023-8-28 14:23:51 | 显示全部楼层
LUA 都写好了 自己封装下就可以了

检查文本的格式看
回复

使用道具 举报