Merge branch 'MihailRis:main' into main

This commit is contained in:
Xertis 2025-01-27 16:35:11 +03:00 • committed by GitHub
commit bec7e59e33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
69 changed files with 639 additions and 285 deletions

View file

@ -0,0 +1,5 @@
{
"steps-sound": "steps/snow",
"place-sound": "blocks/snow_place",
"break-sound": "blocks/snow_break"
}

View file

@ -2,5 +2,6 @@
"texture": "lamp",
"emission": [15, 14, 13],
"shadeless": true,
"material": "base:glass",
"base:durability": 0.3
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -12,7 +12,7 @@
</container>
<container id="logContainer" pos="0,60"
size-func="unpack(vec2.add(gui.get_viewport(), {0,-100}))">
size-func="unpack(vec2.add(gui.get_viewport(), {-350,-100}))">
<textbox
id='log'
color='0'
@ -20,7 +20,7 @@
margin='0'
editable='false'
multiline='true'
size-func="gui.get_viewport()[1],40"
size-func="gui.get_viewport()[1]-350,40"
gravity="bottom-left"
markup="md"
></textbox>

View file

@ -97,11 +97,12 @@ end)
function setup_variables()
local pid = hud.get_player()
local x,y,z = player.get_pos(pid)
console.set("player", pid)
console.set('pos.x', x)
console.set('pos.y', y)
console.set('pos.z', z)
local pentity = player.get_entity(pid)
if pentity ~= 0 then
if pentity > 0 then
console.set('entity.id', pentity)
end
local sentity = player.get_selected_entity(pid)
@ -148,8 +149,6 @@ function submit(text)
text = text:sub(2)
end
end
setup_variables()
local name
for s in text:gmatch("%S+") do
@ -167,12 +166,19 @@ function submit(text)
end
document.log.caret = -1
local status, result = pcall(console.execute, text)
if result then
console.log(result)
end
document.prompt.text = ""
document.prompt.focused = true
setup_variables()
if console.submit then
console.submit(text)
else
local status, result = pcall(console.execute, text)
if result then
console.log(result)
end
end
end
function set_mode(mode)

View file

@ -7,16 +7,11 @@ local initialized = false
local max_lines = 15
local animation_fps = 30
local function remove_line(line)
document[line[1]]:destruct()
time.post_runnable(function() document.root:reposition() end)
end
local function update_line(line, uptime)
local diff = uptime - line[2]
if diff > timeout then
remove_line(line)
table.insert(dead_lines, i)
document[line[1]]:destruct()
table.insert(dead_lines, table.index(lines, line))
elseif diff > timeout-fadeout then
local opacity = (timeout - diff) / fadeout
document[line[1]].color = {0, 0, 0, opacity * 80}
@ -25,16 +20,16 @@ local function update_line(line, uptime)
end
events.on("core:chat", function(message)
while #lines >= max_lines do
document[lines[1][1]]:destruct()
table.remove(lines, 1)
end
local current_time = time.uptime()
local id = 'l'..tostring(nextid)
document.root:add(gui.template("chat_line", {id=id}))
document.root:reposition()
document[id.."L"].text = message
nextid = nextid + 1
if #lines == max_lines then
remove_line(lines[1])
table.remove(lines, 1)
end
table.insert(lines, {id, current_time})
end)

View file

@ -313,8 +313,8 @@ function bit_converter.bytes_to_uint16(bytes, order)
return
bit.bor(
bit.lshift(bytes[1], 8),
bytes[2], 0)
bit.lshift(bytes[2], 8),
bytes[1], 0)
end
function bit_converter.bytes_to_int64(bytes, order)

View file

@ -144,31 +144,31 @@ function data_buffer:put_number(num)
if math.floor(num) ~= num then
type = TYPE_FLOAT64
bytes = bit_converter.float64_to_bytes(num)
bytes = bit_converter.float64_to_bytes(num, self.order)
elseif num == 0 then
type = TYPE_ZERO
bytes = { }
elseif num > 0 then
if num <= MAX_UINT16 then
type = TYPE_UINT16
bytes = bit_converter.uint16_to_bytes(num)
bytes = bit_converter.uint16_to_bytes(num, self.order)
elseif num <= MAX_UINT32 then
type = TYPE_UINT32
bytes = bit_converter.uint32_to_bytes(num)
bytes = bit_converter.uint32_to_bytes(num, self.order)
elseif num <= MAX_INT64 then
type = TYPE_INT64
bytes = bit_converter.int64_to_bytes(num)
bytes = bit_converter.int64_to_bytes(num, self.order)
end
elseif num < 0 then
if num >= MIN_INT16 then
type = TYPE_SINT16
bytes = bit_converter.sint16_to_bytes(num)
bytes = bit_converter.sint16_to_bytes(num, self.order)
elseif num >= MIN_INT32 then
type = TYPE_SINT32
bytes = bit_converter.sint32_to_bytes(num)
bytes = bit_converter.sint32_to_bytes(num, self.order)
elseif num >= MIN_INT64 then
type = TYPE_INT64
bytes = bit_converter.int64_to_bytes(num)
bytes = bit_converter.int64_to_bytes(num, self.order)
end
end

View file

@ -47,7 +47,7 @@ function gui_util.add_page_dispatcher(dispatcher)
table.insert(gui_util.local_dispatchers, dispatcher)
end
function gui_util.reset_local()
function gui_util.__reset_local()
gui_util.local_dispatchers = {}
end

View file

@ -68,6 +68,22 @@ local Entity = {__index={
def_index=function(self) return entities.get_def(self.eid) end,
def_name=function(self) return entities.def_name(entities.get_def(self.eid)) end,
get_player=function(self) return entities.get_player(self.eid) end,
set_enabled=function(self, name, flag)
local comp = self.components[name]
if comp then
if flag then
if comp.__disabled and comp.on_enable then
comp.on_enable()
end
comp.__disabled = nil
else
if not comp.__disabled and comp.on_disable then
comp.on_disable()
end
comp.__disabled = true
end
end
end,
}}
local entities = {}
@ -99,7 +115,7 @@ return {
end
for _, component in pairs(entity.components) do
local callback = component.on_update
if callback then
if not component.__disabled and callback then
local result, err = pcall(callback, tps)
if err then
debug.error(err)
@ -113,7 +129,7 @@ return {
for _,entity in pairs(entities) do
for _, component in pairs(entity.components) do
local callback = component.on_render
if callback then
if not component.__disabled and callback then
local result, err = pcall(callback, delta)
if err then
debug.error(err)
@ -132,5 +148,8 @@ return {
end
return values
end
end,
__reset = function()
entities = {}
end
}

View file

@ -37,7 +37,10 @@ local function complete_app_lib(app)
app.tick = coroutine.yield
app.get_version = core.get_version
app.get_setting_info = core.get_setting_info
app.load_content = core.load_content
app.load_content = function()
core.load_content()
app.tick()
end
app.reset_content = core.reset_content
app.is_content_loaded = core.is_content_loaded
@ -191,8 +194,8 @@ function gui.template(name, params)
text = text:gsub("if%s*=%s*'%%{%w+}'", "if=''")
text = text:gsub("if%s*=%s*\"%%{%w+}\"", "if=\"\"")
-- remove unsolved properties: attr='%{var}'
text = text:gsub("%w+%s*=%s*'%%{%w+}'%s?", "")
text = text:gsub("%w+%s*=%s*\"%%{%w+}\"%s?", "")
text = text:gsub("%s*%S+='%%{[^}]+}'%s*", " ")
text = text:gsub('%s*%S+="%%{[^}]+}"%s*', " ")
return text
end
@ -343,8 +346,8 @@ function __vc_on_hud_open()
end)
end)
input.add_callback("key:escape", function()
if hud.is_paused() then
hud.resume()
if menu.page ~= "" then
menu:reset()
elseif hud.is_inventory_open() then
hud.close_inventory()
else
@ -375,7 +378,8 @@ end
function __vc_on_world_quit()
_rules.clear()
gui_util:reset_local()
gui_util:__reset_local()
stdcomp.__reset()
end
local __vc_coroutines = {}
@ -415,7 +419,18 @@ end
function start_coroutine(chunk, name)
local co = coroutine.create(function()
local status, error = xpcall(chunk, __vc__error)
local status, error = xpcall(chunk, function(...)
gui.alert(debug.traceback(), function()
if world.is_open() then
__vc_app.close_world()
else
__vc_app.reset_content()
menu:reset()
menu.page = "main"
end
end)
return ...
end)
if not status then
debug.error(error)
end