mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 13:01:49 +00:00
minor refactor
This commit is contained in:
parent
90f7fce2b1
commit
ca6096c397
5 changed files with 29 additions and 14 deletions
|
|
@ -1,18 +1,10 @@
|
|||
function run_script(path)
|
||||
debug.log("starting application script "..path)
|
||||
|
||||
local code = file.read(path)
|
||||
local chunk, err = loadstring(code, path)
|
||||
if chunk == nil then
|
||||
error(err)
|
||||
end
|
||||
setfenv(chunk, setmetatable({app=__vc_app}, {__index=_G}))
|
||||
start_coroutine(chunk, path)
|
||||
__vc_start_app_script(path)
|
||||
end
|
||||
|
||||
function refresh()
|
||||
document.list:clear()
|
||||
|
||||
|
||||
local allpacks = table.merge(pack.get_available(), pack.get_installed())
|
||||
local infos = pack.get_info(allpacks)
|
||||
for _, name in ipairs(allpacks) do
|
||||
|
|
|
|||
|
|
@ -186,6 +186,20 @@ events = require "core:internal/events"
|
|||
|
||||
function pack.unload(prefix)
|
||||
events.remove_by_prefix(prefix)
|
||||
__vc__pack_envs[prefix] = nil
|
||||
end
|
||||
|
||||
function __vc_start_app_script(path)
|
||||
debug.log("starting application script "..path)
|
||||
|
||||
local code = file.read(path)
|
||||
local chunk, err = loadstring(code, path)
|
||||
if chunk == nil then
|
||||
error(err)
|
||||
end
|
||||
local script_env = setmetatable({app = app or __vc_app}, {__index=_G})
|
||||
setfenv(chunk, script_env)
|
||||
return start_coroutine(chunk, path)
|
||||
end
|
||||
|
||||
gui_util = require "core:internal/gui_util"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue