boxmoe_header_banner_img

菜就多练喵

文章导读

[Unity]热更新08——Lua自带库


avatar
Ib_Mccf 2026年3月3日 12
--*******时间******
print(os.time()) --系统时间
print(os.time({year = 2014,month = 8,day = 14})) --传入参数的到时间

local nowTime = os.date("*t") --获取当前时间,是一个table
for k,v in pairs(nowTime) do
	print(k,v)
end
print(nowTime.year) --=> 2026
print(nowTime.month) --=> 3
print(nowTime.day) --=> 3

--*******数学******
print(math.abs(-11)) --绝对值
print(math.deg(math.pi)) --弧度转角度
print(math.cos(math.pi)) --cos,传入弧度
print(math.floor(2.5)) --向下取整
print(math.ceil(2.5)) --向下取整
print(math.max(1,2)) --取最大值
print(math.min(1,2)) --取最小值
print(math.modf(1.2)) --分离整数和小数部分
print(math.pow(2,5)) --幂运算
--随机数,使用前先设置随机数种子
math.randomseed(os.time())
print(math.random(100))
print(math.random(100))
print(math.sqrt(4)) --开方

--*******路径******
print(package.path) --打印lua脚本加载路径
package.path = package.path .. ";C:\\" --更新加载路径
print(package.path)



评论(0)

查看评论列表

暂无评论


发表评论

表情 颜文字

插入代码