add file.name(), file.stem() & add 'path' to pack info & add start_coroutine()
This commit is contained in:
+42
-20
@@ -163,7 +163,7 @@ function Document.new(docname)
|
||||
end
|
||||
|
||||
local _RadioGroup = {}
|
||||
function _RadioGroup.set(self, key)
|
||||
function _RadioGroup:set(key)
|
||||
if type(self) ~= 'table' then
|
||||
error("called as non-OOP via '.', use radiogroup:set")
|
||||
end
|
||||
@@ -176,7 +176,7 @@ function _RadioGroup.set(self, key)
|
||||
self.callback(key)
|
||||
end
|
||||
end
|
||||
function _RadioGroup.__call(self, elements, onset, default)
|
||||
function _RadioGroup:__call(elements, onset, default)
|
||||
local group = setmetatable({
|
||||
elements=elements,
|
||||
callback=onset,
|
||||
@@ -192,24 +192,6 @@ _GUI_ROOT = Document.new("core:root")
|
||||
_MENU = _GUI_ROOT.menu
|
||||
menu = _MENU
|
||||
|
||||
local __post_runnables = {}
|
||||
|
||||
function __process_post_runnables()
|
||||
if #__post_runnables then
|
||||
for _, func in ipairs(__post_runnables) do
|
||||
local status, result = xpcall(func, __vc__error)
|
||||
if not status then
|
||||
debug.error("error in post_runnable: "..result)
|
||||
end
|
||||
end
|
||||
__post_runnables = {}
|
||||
end
|
||||
end
|
||||
|
||||
function time.post_runnable(runnable)
|
||||
table.insert(__post_runnables, runnable)
|
||||
end
|
||||
|
||||
--- Console library extension ---
|
||||
console.cheats = {}
|
||||
|
||||
@@ -409,6 +391,7 @@ function __vc_on_world_quit()
|
||||
end
|
||||
|
||||
local __vc_coroutines = {}
|
||||
local __vc_named_coroutines = {}
|
||||
local __vc_next_coroutine = 1
|
||||
local __vc_coroutine_error = nil
|
||||
|
||||
@@ -447,6 +430,45 @@ function __vc_stop_coroutine(id)
|
||||
end
|
||||
end
|
||||
|
||||
function start_coroutine(chunk, name)
|
||||
local co = coroutine.create(function()
|
||||
local status, error = xpcall(chunk, __vc__error)
|
||||
if not status then
|
||||
debug.error(error)
|
||||
end
|
||||
end)
|
||||
__vc_named_coroutines[name] = co
|
||||
end
|
||||
|
||||
local __post_runnables = {}
|
||||
|
||||
function __process_post_runnables()
|
||||
if #__post_runnables then
|
||||
for _, func in ipairs(__post_runnables) do
|
||||
local status, result = xpcall(func, __vc__error)
|
||||
if not status then
|
||||
debug.error("error in post_runnable: "..result)
|
||||
end
|
||||
end
|
||||
__post_runnables = {}
|
||||
end
|
||||
|
||||
local dead = {}
|
||||
for name, co in pairs(__vc_named_coroutines) do
|
||||
coroutine.resume(co)
|
||||
if coroutine.status(co) == "dead" then
|
||||
table.insert(dead, name)
|
||||
end
|
||||
end
|
||||
for _, name in ipairs(dead) do
|
||||
__vc_named_coroutines[name] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function time.post_runnable(runnable)
|
||||
table.insert(__post_runnables, runnable)
|
||||
end
|
||||
|
||||
assets = {}
|
||||
assets.load_texture = core.__load_texture
|
||||
|
||||
|
||||
Reference in New Issue
Block a user