小编Pro*_*hod的帖子

如何将大纪元以来的秒数转换为当前日期和时间?

我知道我刚刚发布了这个,但我找到了解决方案.我为一款名为Roblox的游戏编写了这段代码,但我只是在这里发布代码,以防其他有同样问题的人需要解决方案.无论如何,这是代码:

outputTime = true -- true: will print the current time to output window. false: won't print time
createVariable = true -- true: creates variables under game.Lighting. false: won't create variables

-----------------------------------------------------------------------------------------------
--DO NOT EDIT BELOW----------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------

if(createVariable) then
    yearVar = Instance.new("IntValue", game.Lighting)
    yearVar.Name = "Year"
    yearVar.Value = 0
    monthVar = Instance.new("IntValue", game.Lighting)
    monthVar.Name = "Month"
    monthVar.Value = 0
    dayVar = Instance.new("IntValue", game.Lighting)
    dayVar.Name = "Day"
    dayVar.Value = 0
    hourVar = Instance.new("IntValue", game.Lighting)
    hourVar.Name = "Hour"
    hourVar.Value = 0
    minuteVar …
Run Code Online (Sandbox Code Playgroud)

time lua epoch

4
推荐指数
1
解决办法
1万
查看次数

Lua用两个值对表排序?

所以我有下表:

servers = {"ProtectedMethod" = {name = "ProtectedMethod", visits = 20, players = 2}, "InjecTive" = {name = "InjecTive", visits = 33, players = 1}};
Run Code Online (Sandbox Code Playgroud)

如何将服务器表中的子表排序为一个新的数组,该数组首先基于玩家,然后根据访问次数排序,这意味着除非两个表对玩家的值相同,否则您不会按访问次数进行排序。

例如,如果将排序代码放入名为tableSort的函数中,则我应该能够调用以下代码:

sorted = sort();
print(sorted[1].name .. ": " sorted[1].players .. ", " .. sorted[1].visits); --Should print "ProtectedMethod: 2, 20"
print(sorted[2].name .. ": " sorted[2].players .. ", " .. sorted[2].visits); --Should print "InjecTive: 1, 33"
Run Code Online (Sandbox Code Playgroud)

TIA

sorting lua lua-table

1
推荐指数
1
解决办法
1201
查看次数

标签 统计

lua ×2

epoch ×1

lua-table ×1

sorting ×1

time ×1