mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 22:41:49 +00:00
Merge branch 'main' into volume-renderer
This commit is contained in:
commit
305f44d1c6
70 changed files with 802 additions and 580 deletions
|
|
@ -15,7 +15,7 @@
|
|||
<textbox id='search_textbox' multiline='false' size='440,25' sub-consumer='function(x) refresh_search() end'></textbox>
|
||||
</panel>
|
||||
|
||||
<image onclick='core.open_folder("user:content")' interactive='true' src='gui/folder_icon'
|
||||
<image onclick='app.open_folder("user:content")' interactive='true' src='gui/folder_icon'
|
||||
size='32' margin='0,0,18,66' gravity='bottom-right'
|
||||
color='#FFFFFF50' hover-color='#FFFFFF10'/>
|
||||
|
||||
|
|
@ -38,4 +38,4 @@
|
|||
<panel id='packs_cur' pos='15,34' size='440,455' color='0' max-length='455' scrollable='true'>
|
||||
<!-- content is generated in script -->
|
||||
</panel>
|
||||
</container>
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<textbox id='search_textbox' multiline='false' size='440,25' sub-consumer='function(x) refresh_search() end'></textbox>
|
||||
</panel>
|
||||
|
||||
<image onclick='core.open_folder("user:content")' interactive='true' src='gui/folder_icon'
|
||||
<image onclick='app.open_folder("user:content")' interactive='true' src='gui/folder_icon'
|
||||
size='32' margin='0,0,10,15' gravity='bottom-right'
|
||||
color='#FFFFFF50' hover-color='#FFFFFF10'/>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
<button onclick='menu.page="scripts"'>@Scripts</button>
|
||||
<button onclick='menu.page="settings"'>@Settings</button>
|
||||
<button onclick='menu.page="content_menu"'>@Content</button>
|
||||
<button onclick='core.quit()'>@Quit</button>
|
||||
<button onclick='app.quit(true)'>@Quit</button>
|
||||
</panel>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ function create_world()
|
|||
local seed = document.seed_box.text
|
||||
local generator = settings.generator
|
||||
session.reset_entry('new_world')
|
||||
core.new_world(name, seed, generator)
|
||||
app.new_world(name, seed, generator)
|
||||
end
|
||||
|
||||
function world_name_placeholder()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<button onclick='menu:reset()'>@Continue</button>
|
||||
<button onclick='menu.page="content?mode=world"'>@Content</button>
|
||||
<button onclick='menu.page="settings"'>@Settings</button>
|
||||
<button onclick='core.close_world(true)'>
|
||||
<button onclick='app.close_world(true)'>
|
||||
@Save and Quit to Menu
|
||||
</button>
|
||||
</panel>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<panel margin='6' gravity='bottom-left' size='250' color='0' interval='1'>
|
||||
<button onclick='menu.page="languages"' id='langs_btn'>-</button>
|
||||
<button onclick='core.open_folder("user:")'>@Open data folder</button>
|
||||
<button onclick='app.open_folder("user:")'>@Open data folder</button>
|
||||
<button id='s_rst' onclick='sections:set("reset")'>@Reset settings</button>
|
||||
<button onclick='menu:back()'>@Back</button>
|
||||
</panel>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
function on_open()
|
||||
document.langs_btn.text = string.format(
|
||||
"%s: %s", gui.str("Language", "settings"),
|
||||
gui.get_locales_info()[core.get_setting("ui.language")].name
|
||||
gui.get_locales_info()[app.get_setting("ui.language")].name
|
||||
)
|
||||
sections = RadioGroup({
|
||||
audio=document.s_aud,
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
function create_setting(id, name, step, postfix)
|
||||
local info = core.get_setting_info(id)
|
||||
local info = app.get_setting_info(id)
|
||||
postfix = postfix or ""
|
||||
document.root:add(gui.template("track_setting", {
|
||||
id=id,
|
||||
name=gui.str(name, "settings"),
|
||||
value=core.get_setting(id),
|
||||
value=app.get_setting(id),
|
||||
min=info.min,
|
||||
max=info.max,
|
||||
step=step,
|
||||
postfix=postfix
|
||||
}))
|
||||
update_setting(core.get_setting(id), id, name, postfix)
|
||||
update_setting(app.get_setting(id), id, name, postfix)
|
||||
end
|
||||
|
||||
function update_setting(x, id, name, postfix)
|
||||
core.set_setting(id, x)
|
||||
app.set_setting(id, x)
|
||||
-- updating label
|
||||
document[id..".L"].text = string.format(
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
core.str_setting(id),
|
||||
gui.str(name, "settings"),
|
||||
app.str_setting(id),
|
||||
postfix
|
||||
)
|
||||
end
|
||||
|
|
@ -54,7 +54,7 @@ function on_open()
|
|||
create_setting("audio.volume-music", "Music", 0.01)
|
||||
document.root:add("<label context='settings'>@Microphone</label>")
|
||||
document.root:add("<select id='input_device_select' "..
|
||||
"onselect='function(opt) core.set_setting(\"audio.input-device\", opt) end'/>")
|
||||
"onselect='function(opt) app.set_setting(\"audio.input-device\", opt) end'/>")
|
||||
document.root:add("<container id='input_volume_outer' color='#000000' size='4'>"
|
||||
.."<container id='input_volume_inner' color='#00FF00FF' pos='1' size='2'/>"
|
||||
.."</container>")
|
||||
|
|
@ -67,5 +67,8 @@ function on_open()
|
|||
table.insert(devices, {value=name, text=name})
|
||||
end
|
||||
selectbox.options = devices
|
||||
selectbox.value = audio.__get_input_info().device_specifier
|
||||
local info = audio.__get_input_info()
|
||||
if info then
|
||||
selectbox.value = info.device_specifier
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ function refresh_sensitivity()
|
|||
document.sensitivity_label.text = string.format(
|
||||
"%s: %s",
|
||||
gui.str("Mouse Sensitivity", "settings"),
|
||||
core.str_setting("camera.sensitivity")
|
||||
app.str_setting("camera.sensitivity")
|
||||
)
|
||||
end
|
||||
|
||||
function change_sensitivity(val)
|
||||
core.set_setting("camera.sensitivity", val)
|
||||
app.set_setting("camera.sensitivity", val)
|
||||
refresh_sensitivity()
|
||||
end
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ function refresh_binding_marks()
|
|||
end
|
||||
|
||||
function on_open()
|
||||
document.sensitivity_track.value = core.get_setting("camera.sensitivity")
|
||||
document.sensitivity_track.value = app.get_setting("camera.sensitivity")
|
||||
refresh_sensitivity()
|
||||
|
||||
local panel = document.bindings_panel
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ tostring_overrides["display.framerate"] = function(x)
|
|||
end
|
||||
|
||||
function create_setting(id, name, step, postfix, tooltip, changeonrelease)
|
||||
local info = core.get_setting_info(id)
|
||||
local info = app.get_setting_info(id)
|
||||
postfix = postfix or ""
|
||||
tooltip = tooltip or ""
|
||||
changeonrelease = changeonrelease or ""
|
||||
document.root:add(gui.template("track_setting", {
|
||||
id=id,
|
||||
name=gui.str(name, "settings"),
|
||||
value=core.get_setting(id),
|
||||
value=app.get_setting(id),
|
||||
min=info.min,
|
||||
max=info.max,
|
||||
step=step,
|
||||
|
|
@ -25,7 +25,7 @@ function create_setting(id, name, step, postfix, tooltip, changeonrelease)
|
|||
tooltip=tooltip,
|
||||
changeonrelease=changeonrelease
|
||||
}))
|
||||
update_setting(core.get_setting(id), id, name, postfix)
|
||||
update_setting(app.get_setting(id), id, name, postfix)
|
||||
end
|
||||
|
||||
function update_setting(x, id, name, postfix)
|
||||
|
|
@ -34,13 +34,13 @@ function update_setting(x, id, name, postfix)
|
|||
if func then
|
||||
str = func(x)
|
||||
else
|
||||
str = core.str_setting(id)
|
||||
str = app.str_setting(id)
|
||||
end
|
||||
-- updating label
|
||||
document[id..".L"].text = string.format(
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
str,
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
str,
|
||||
postfix
|
||||
)
|
||||
end
|
||||
|
|
@ -48,8 +48,8 @@ end
|
|||
function create_checkbox(id, name, tooltip)
|
||||
tooltip = tooltip or ''
|
||||
document.root:add(string.format(
|
||||
"<checkbox consumer='function(x) core.set_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
|
||||
id, core.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
|
||||
"<checkbox consumer='function(x) app.set_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
|
||||
id, app.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
|
||||
))
|
||||
end
|
||||
|
||||
|
|
@ -59,11 +59,11 @@ function on_open()
|
|||
create_setting("display.framerate", "Framerate", 1, "", "", true)
|
||||
|
||||
document.root:add(string.format(
|
||||
"<select context='settings' onselect='function(opt) core.set_setting(\"display.window-mode\", tonumber(opt)) end' selected='%s'>"..
|
||||
"<select context='settings' onselect='function(opt) app.set_setting(\"display.window-mode\", tonumber(opt)) end' selected='%s'>"..
|
||||
"<option value='0'>@Windowed</option>"..
|
||||
"<option value='1'>@Fullscreen</option>"..
|
||||
"<option value='2'>@Borderless</option>"..
|
||||
"</select>", core.get_setting("display.window-mode"))
|
||||
"</select>", app.get_setting("display.window-mode"))
|
||||
)
|
||||
|
||||
create_checkbox("camera.shaking", "Camera Shaking")
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
function create_setting(id, name, step, postfix, tooltip, changeonrelease)
|
||||
local info = core.get_setting_info(id)
|
||||
local info = app.get_setting_info(id)
|
||||
postfix = postfix or ""
|
||||
tooltip = tooltip or ""
|
||||
changeonrelease = changeonrelease or ""
|
||||
document.root:add(gui.template("track_setting", {
|
||||
id=id,
|
||||
name=gui.str(name, "settings"),
|
||||
value=core.get_setting(id),
|
||||
value=app.get_setting(id),
|
||||
min=info.min,
|
||||
max=info.max,
|
||||
step=step,
|
||||
|
|
@ -14,15 +14,15 @@ function create_setting(id, name, step, postfix, tooltip, changeonrelease)
|
|||
tooltip=tooltip,
|
||||
changeonrelease=changeonrelease
|
||||
}))
|
||||
update_setting(core.get_setting(id), id, name, postfix)
|
||||
update_setting(app.get_setting(id), id, name, postfix)
|
||||
end
|
||||
|
||||
function update_setting(x, id, name, postfix)
|
||||
-- updating label
|
||||
document[id..".L"].text = string.format(
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
core.str_setting(id),
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
app.str_setting(id),
|
||||
postfix
|
||||
)
|
||||
end
|
||||
|
|
@ -30,8 +30,8 @@ end
|
|||
function create_checkbox(id, name, tooltip)
|
||||
tooltip = tooltip or ''
|
||||
document.root:add(string.format(
|
||||
"<checkbox consumer='function(x) core.set_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
|
||||
id, core.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
|
||||
"<checkbox consumer='function(x) app.set_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
|
||||
id, app.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
|
||||
))
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ function reset(category)
|
|||
end
|
||||
|
||||
function reset_setting(name)
|
||||
core.set_setting(name, core.get_setting_info(name).def)
|
||||
app.set_setting(name, app.get_setting_info(name).def)
|
||||
end
|
||||
|
||||
function reset_audio()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
<panel id='worlds' size='390,1' padding='5' color='#FFFFFF11' max-length='400'>
|
||||
</panel>
|
||||
<button pos='485,525' size='500,40' onclick='core.open_folder("user:worlds")'>@Open worlds folder</button>
|
||||
<button pos='485,525' size='500,40' onclick='app.open_folder("user:worlds")'>@Open worlds folder</button>
|
||||
<button onclick='menu:back()'>@Back</button>
|
||||
</panel>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
function on_open()
|
||||
local worlds = world.get_list()
|
||||
for _, info in ipairs(worlds) do
|
||||
local major, minor = core.get_version()
|
||||
local major, minor = app.get_version()
|
||||
if info.version[1] > major or info.version[2] > minor then
|
||||
info.versionColor = "#A02010"
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<button
|
||||
onclick='core.set_setting("ui.language", "%{id}") menu:back()'>
|
||||
onclick='app.set_setting("ui.language", "%{id}") menu:back()'>
|
||||
%{name}
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
<label id='%{id}.L' margin='0,3,0,0'>%{name}: %{value}%{postfix}</label>
|
||||
<trackbar
|
||||
value='%{value}' min='%{min}' max='%{max}' step='%{step}' tooltip='%{tooltip}'
|
||||
consumer='function(x) core.set_setting("%{id}", x) end' change-on-release='%{changeonrelease}'
|
||||
consumer='function(x) app.set_setting("%{id}", x) end' change-on-release='%{changeonrelease}'
|
||||
sub-consumer='function(x) update_setting(x, "%{id}", "%{name}", "%{postfix}") end'/>
|
||||
</panel>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
size='380,66'
|
||||
color='#0F1E2DB2'
|
||||
hover-color='#162B3399'
|
||||
onclick='core.open_world("%{name}")'
|
||||
onclick='app.open_world("%{name}")'
|
||||
>
|
||||
<image pos='1' src='%{icon}' size='96,64'></image>
|
||||
<label pos='104,8'>%{name}</label>
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
color='#00000000'
|
||||
hover-color='#FFFFFF2B'
|
||||
padding='0'
|
||||
onclick='core.delete_world("%{name}")'>
|
||||
onclick='app.delete_world("%{name}")'>
|
||||
<image src='gui/delete_icon' size='32,32' color='#FFFFFF50'/>
|
||||
</button>
|
||||
<label color='%{versionColor}' pos='317,44'>%{versionString}</label>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ function gui_util.load_page(query)
|
|||
local filename = file.find(string.format("layouts/pages/%s.xml", name))
|
||||
if filename then
|
||||
name = file.prefix(filename)..":pages/"..name
|
||||
gui.load_document(filename, name, args)
|
||||
gui.load_document(filename, name, args, { app = __vc_app })
|
||||
return name
|
||||
end
|
||||
end
|
||||
|
|
@ -52,19 +52,21 @@ end
|
|||
|
||||
-- class designed for simple UI-nodes access via properties syntax
|
||||
local Element = {}
|
||||
local __gui_getattr = gui.getattr
|
||||
local __gui_setattr = gui.setattr
|
||||
function Element.new(docname, name)
|
||||
return setmetatable({docname=docname, name=name}, {
|
||||
__index=function(self, k)
|
||||
return gui.getattr(self.docname, self.name, k)
|
||||
return __gui_getattr(self.docname, self.name, k)
|
||||
end,
|
||||
__newindex=function(self, k, v)
|
||||
gui.setattr(self.docname, self.name, k, v)
|
||||
__gui_setattr(self.docname, self.name, k, v)
|
||||
end,
|
||||
__ipairs=function(self)
|
||||
local i = 0
|
||||
return function()
|
||||
i = i + 1
|
||||
local elem = gui.getattr(self.docname, self.name, i)
|
||||
local elem = __gui_getattr(self.docname, self.name, i)
|
||||
if elem == nil then
|
||||
return
|
||||
end
|
||||
|
|
@ -102,8 +104,8 @@ function RadioGroup:set(key)
|
|||
end
|
||||
function RadioGroup:__call(elements, onset, default)
|
||||
local group = setmetatable({
|
||||
elements=elements,
|
||||
callback=onset,
|
||||
elements=elements,
|
||||
callback=onset,
|
||||
current=nil
|
||||
}, {__index=self})
|
||||
group:set(default)
|
||||
|
|
@ -161,7 +163,7 @@ function gui.show_input_dialog(text, actual_callback, validator, confirm_text)
|
|||
callback=callback,
|
||||
validator=validator or function() return #text > 0 end
|
||||
})
|
||||
input.add_callback("key:escape", callback, gui.root[id])
|
||||
input.add_callback("key:escape", function() gui.root[id]:destruct() end, gui.root[id])
|
||||
input.add_callback("key:enter", callback, gui.root[id])
|
||||
gui.root[id.."_input"].focused = true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,5 +2,6 @@
|
|||
name = "default"
|
||||
base_packs = ["base"]
|
||||
permissions = [
|
||||
"network"
|
||||
"network",
|
||||
"record-audio"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -58,7 +58,15 @@ local function process_player_inputs(pid, rot, delta)
|
|||
end
|
||||
end
|
||||
|
||||
local prepared = false
|
||||
body:set_enabled(false)
|
||||
|
||||
function on_physics_update(delta)
|
||||
if not prepared then
|
||||
prepared = true
|
||||
body:set_enabled(true)
|
||||
end
|
||||
|
||||
local pid = entity:get_player()
|
||||
if pid == -1 then
|
||||
return
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ local function configure_SSAO()
|
|||
end
|
||||
events.on("core:setting.graphics.ssao.set", update_ssao_quality)
|
||||
|
||||
update_ssao_quality(core.get_setting("graphics.ssao"))
|
||||
update_ssao_quality(__vc_app.get_setting("graphics.ssao"))
|
||||
end
|
||||
|
||||
local function update_hand()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ local names = {
|
|||
"hidden", "draw-group", "picking-item", "surface-replacement", "script-name",
|
||||
"ui-layout", "inventory-size", "tick-interval", "overlay-texture",
|
||||
"translucent", "fields", "particles", "icon-type", "icon", "placing-block",
|
||||
"stack-size", "name", "script-file", "culling"
|
||||
"stack-size", "name", "script-file", "culling", "solid"
|
||||
}
|
||||
for name, _ in pairs(user_props) do
|
||||
table.insert(names, name)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
local enable_experimental = core.get_setting("debug.enable-experimental")
|
||||
local enable_experimental = __vc_app.get_setting("debug.enable-experimental")
|
||||
|
||||
------------------------------------------------
|
||||
------ Extended kit of standard functions ------
|
||||
|
|
@ -24,41 +24,48 @@ function tb_frame_tostring(frame)
|
|||
return s
|
||||
end
|
||||
|
||||
local core_set_setting = core.set_setting
|
||||
function core.set_setting(name, value, ...)
|
||||
core_set_setting(name, value, ...)
|
||||
events.emit("core:setting."..name..".set", value)
|
||||
end
|
||||
local __vc__app_script_coroutine
|
||||
|
||||
local function complete_app_lib(app)
|
||||
local __app_load_content = app.load_content
|
||||
local __app_reset_content = app.reset_content
|
||||
local __app_reconfig_packs = app.reconfig_packs
|
||||
local __app_tick = coroutine.yield
|
||||
local __app_set_setting = app.set_setting
|
||||
local __app_quit = app.quit
|
||||
|
||||
app.sleep = sleep
|
||||
app.script = __VC_SCRIPT_NAME
|
||||
app.new_world = core.new_world
|
||||
app.open_world = core.open_world
|
||||
app.save_world = core.save_world
|
||||
app.close_world = core.close_world
|
||||
app.reopen_world = core.reopen_world
|
||||
app.delete_world = core.delete_world
|
||||
app.reconfig_packs = core.reconfig_packs
|
||||
app.get_setting = core.get_setting
|
||||
app.set_setting = core.set_setting
|
||||
app.tick = function()
|
||||
coroutine.yield()
|
||||
|
||||
app.set_setting = function(name, value, ...)
|
||||
__app_set_setting(name, value, ...)
|
||||
events.emit("core:setting."..name..".set", value)
|
||||
end
|
||||
app.get_version = core.get_version
|
||||
app.get_setting_info = core.get_setting_info
|
||||
app.load_content = function()
|
||||
core.load_content()
|
||||
app.tick()
|
||||
app.tick = __app_tick
|
||||
|
||||
local function call_in_app_script_co(func, ...)
|
||||
local running = coroutine.running()
|
||||
if not running or running ~= __vc__app_script_coroutine then
|
||||
error("content must be reload in application script coroutine")
|
||||
end
|
||||
func(...)
|
||||
__app_tick()
|
||||
end
|
||||
app.reset_content = core.reset_content
|
||||
app.is_content_loaded = core.is_content_loaded
|
||||
app.set_title = core.set_title
|
||||
|
||||
|
||||
app.reconfig_packs = function(...)
|
||||
call_in_app_script_co(__app_reconfig_packs, ...)
|
||||
end
|
||||
app.load_content = function(...)
|
||||
call_in_app_script_co(__app_load_content, ...)
|
||||
end
|
||||
app.reset_content = function(...)
|
||||
call_in_app_script_co(__app_reset_content, ...)
|
||||
end
|
||||
|
||||
function app.config_packs(packs_list)
|
||||
-- Check if packs are valid and add dependencies to the configuration
|
||||
packs_list = pack.assemble(packs_list)
|
||||
|
||||
|
||||
local installed = pack.get_installed()
|
||||
local toremove = {}
|
||||
for _, packid in ipairs(installed) do
|
||||
|
|
@ -75,15 +82,16 @@ local function complete_app_lib(app)
|
|||
app.reconfig_packs(toadd, toremove)
|
||||
end
|
||||
|
||||
function app.quit()
|
||||
local tb = debug.get_traceback(1)
|
||||
local s = "app.quit() traceback:"
|
||||
for i, frame in ipairs(tb) do
|
||||
s = s .. "\n\t"..tb_frame_tostring(frame)
|
||||
function app.quit(silent)
|
||||
if not silent then
|
||||
local tb = debug.get_traceback(1)
|
||||
local s = "app.quit() traceback:"
|
||||
for i, frame in ipairs(tb) do
|
||||
s = s .. "\n\t"..tb_frame_tostring(frame)
|
||||
end
|
||||
debug.log(s)
|
||||
end
|
||||
debug.log(s)
|
||||
core.quit()
|
||||
coroutine.yield()
|
||||
__app_quit()
|
||||
end
|
||||
|
||||
function app.sleep_until(predicate, max_ticks, max_time)
|
||||
|
|
@ -123,6 +131,66 @@ function pack.unload(prefix)
|
|||
events.remove_by_prefix(prefix)
|
||||
end
|
||||
|
||||
local __vc_coroutines = {}
|
||||
local __vc_named_coroutines = {}
|
||||
local __vc_next_coroutine = 1
|
||||
|
||||
function __vc_start_coroutine(chunk)
|
||||
local co = coroutine.create(chunk)
|
||||
local id = __vc_next_coroutine
|
||||
__vc_next_coroutine = __vc_next_coroutine + 1
|
||||
__vc_coroutines[id] = co
|
||||
return id
|
||||
end
|
||||
|
||||
function __vc_resume_coroutine(id)
|
||||
local co = __vc_coroutines[id]
|
||||
if co then
|
||||
local success, err = coroutine.resume(co)
|
||||
if not success then
|
||||
debug.error(err)
|
||||
error(err)
|
||||
end
|
||||
return coroutine.status(co) ~= "dead"
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function __vc_stop_coroutine(id)
|
||||
local co = __vc_coroutines[id]
|
||||
if co then
|
||||
if coroutine.close then
|
||||
coroutine.close(co)
|
||||
end
|
||||
__vc_coroutines[id] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function start_coroutine(chunk, name)
|
||||
local co = coroutine.create(function()
|
||||
local status, error = xpcall(chunk, function(err)
|
||||
local fullmsg = "error: "..string.match(err, ": (.+)").."\n"..debug.traceback()
|
||||
|
||||
if hud then
|
||||
gui.alert(fullmsg, function()
|
||||
if world.is_open() then
|
||||
__vc_app.close_world()
|
||||
else
|
||||
__vc_app.reset_content()
|
||||
menu:reset()
|
||||
menu.page = "main"
|
||||
end
|
||||
end)
|
||||
end
|
||||
return fullmsg
|
||||
end)
|
||||
if not status then
|
||||
debug.error(error)
|
||||
end
|
||||
end)
|
||||
__vc_named_coroutines[name] = co
|
||||
end
|
||||
|
||||
function __vc_start_app_script(path, name)
|
||||
debug.log("starting application script "..path)
|
||||
|
||||
|
|
@ -134,9 +202,13 @@ function __vc_start_app_script(path, name)
|
|||
local script_env = setmetatable({app = app or __vc_app}, {__index=_G})
|
||||
chunk = setfenv(chunk, script_env)
|
||||
if name then
|
||||
return start_coroutine(chunk, name)
|
||||
start_coroutine(chunk, name)
|
||||
__vc__app_script_coroutine = __vc_named_coroutines[name]
|
||||
return
|
||||
else
|
||||
return __vc_start_coroutine(chunk)
|
||||
local id = __vc_start_coroutine(chunk)
|
||||
__vc__app_script_coroutine = __vc_coroutines[id]
|
||||
return id
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -435,66 +507,6 @@ function __vc_on_world_quit()
|
|||
file.__close_all_descriptors()
|
||||
end
|
||||
|
||||
local __vc_coroutines = {}
|
||||
local __vc_named_coroutines = {}
|
||||
local __vc_next_coroutine = 1
|
||||
|
||||
function __vc_start_coroutine(chunk)
|
||||
local co = coroutine.create(chunk)
|
||||
local id = __vc_next_coroutine
|
||||
__vc_next_coroutine = __vc_next_coroutine + 1
|
||||
__vc_coroutines[id] = co
|
||||
return id
|
||||
end
|
||||
|
||||
function __vc_resume_coroutine(id)
|
||||
local co = __vc_coroutines[id]
|
||||
if co then
|
||||
local success, err = coroutine.resume(co)
|
||||
if not success then
|
||||
debug.error(err)
|
||||
error(err)
|
||||
end
|
||||
return coroutine.status(co) ~= "dead"
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function __vc_stop_coroutine(id)
|
||||
local co = __vc_coroutines[id]
|
||||
if co then
|
||||
if coroutine.close then
|
||||
coroutine.close(co)
|
||||
end
|
||||
__vc_coroutines[id] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function start_coroutine(chunk, name)
|
||||
local co = coroutine.create(function()
|
||||
local status, error = xpcall(chunk, function(err)
|
||||
local fullmsg = "error: "..string.match(err, ": (.+)").."\n"..debug.traceback()
|
||||
|
||||
if hud then
|
||||
gui.alert(fullmsg, function()
|
||||
if world.is_open() then
|
||||
__vc_app.close_world()
|
||||
else
|
||||
__vc_app.reset_content()
|
||||
menu:reset()
|
||||
menu.page = "main"
|
||||
end
|
||||
end)
|
||||
end
|
||||
return fullmsg
|
||||
end)
|
||||
if not status then
|
||||
debug.error(error)
|
||||
end
|
||||
end)
|
||||
__vc_named_coroutines[name] = co
|
||||
end
|
||||
|
||||
local __post_runnables = {}
|
||||
|
||||
local fn_audio_reset_fetch_buffer = audio.__reset_fetch_buffer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue