diff --git a/res/layouts/console.xml.lua b/res/layouts/console.xml.lua index e23ce357..819ac1fd 100644 --- a/res/layouts/console.xml.lua +++ b/res/layouts/console.xml.lua @@ -45,8 +45,8 @@ function submit(text) setup_variables() document.log.caret = -1 - local status, result = pcall(function() return console.execute(text) end) - if result ~= nil then + local status, result = pcall(console.execute, text) + if result then console.log(result) end document.prompt.text = "" diff --git a/res/scripts/stdcmd.lua b/res/scripts/stdcmd.lua index 18c010c3..95ba2639 100644 --- a/res/scripts/stdcmd.lua +++ b/res/scripts/stdcmd.lua @@ -69,6 +69,21 @@ console.add_command( 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", @@ -76,7 +91,7 @@ console.add_command( local uptime = time.uptime() local formatted_uptime = "" - local t = string.FormattedTime(uptime) + local t = FormattedTime(uptime) formatted_uptime = t.h .. "h " .. t.m .. "m " .. t.s .. "s" diff --git a/res/scripts/stdlib.lua b/res/scripts/stdlib.lua index ee2596c0..d634104d 100644 --- a/res/scripts/stdlib.lua +++ b/res/scripts/stdlib.lua @@ -21,7 +21,7 @@ function parse_path(path) end package = { - loaded = {} + loaded={} } local __cached_scripts = {} @@ -279,19 +279,13 @@ entities.get_all = function(uids) for k,v in pairs(stdcomp.get_all()) do values[k] = v end - return values + return values else return stdcomp.get_all(uids) end end ------------------- sekta helpers - -require("core:internal/math") -require("core:internal/string") -require("core:internal/table") - -math.randomseed(time.uptime() * 1536227939) +math.randomseed(time.uptime()*1536227939) -- --------- Deprecated functions ------ -- block_index = block.index