a lot stuff changed

This commit is contained in:
Mihail 2024-07-31 15:25:58 +04:00 committed by GitHub
parent 8e789affcb
commit f4f8caec43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,7 +26,6 @@ console.add_command(
"help name:str=''",
"Show help infomation for the specified command",
function(args, kwargs)
local name = args[1]
if #name == 0 then
@ -67,41 +66,36 @@ console.add_command(
end
return str .. "\n" .. SEPARATOR
end
)
local function FormattedTime(seconds, format ) -- from gmod
if not seconds then seconds = 0 end
local hours = math.floor(seconds / 3600)
local minutes = math.floor((seconds / 60) % 60)
local millisecs = (seconds - math.floor(seconds)) * 100
seconds = math.floor(seconds % 60)
if format then
return string.format(format, minutes, seconds, millisecs)
else
return {h = hours, m = minutes, s = seconds, ms = millisecs}
end
end
console.add_command(
"time.uptime",
"Get time elapsed since the engine started",
function()
local uptime = time.uptime()
local years = math.floor(uptime / 31536000)
local days = math.floor((uptime % 31536000) / 86400) % 365
local hours = math.floor((uptime % 86400) / 3600) % 24
local minutes = math.floor((uptime % 3600) / 60) % 60
local seconds = math.floor(uptime % 60)
local formatted_uptime = ""
if years > 0 then
formatted_uptime = formatted_uptime .. years .. "y "
end
if days > 0 or years > 0 then
formatted_uptime = formatted_uptime .. days .. "d "
end
if hours > 0 or days > 0 or years > 0 then
formatted_uptime = formatted_uptime .. hours .. "h "
end
if minutes > 0 or hours > 0 or days > 0 or years > 0 then
formatted_uptime = formatted_uptime .. minutes .. "m "
end
if seconds > 0 or minutes > 0 or hours > 0 or days > 0 or years > 0 then
formatted_uptime = formatted_uptime .. seconds .. "s"
end
local t = FormattedTime(uptime)
return uptime .. " (" .. formatted_uptime .. ")"
formatted_uptime = t.h .. "h " .. t.m .. "m " .. t.s .. "s"
return formatted_uptime .. " (" .. uptime .. "s)"
end
)
@ -111,7 +105,7 @@ console.add_command(
function(args, kwargs)
local eid, x, y, z = unpack(args)
local entity = entities.get(eid)
if entity ~= nil then
if entity then
entity.transform:set_pos({x, y, z})
end
end
@ -127,7 +121,8 @@ console.add_command(
"time.set value:num",
"Set day time [0..1] where 0 is midnight, 0.5 is noon",
function(args, kwargs)
return world.set_day_time(args[1])
world.set_day_time(args[1])
return "Time set to " .. args[1]
end
)
console.add_command(