Merge branch 'dev' into pathfinding

This commit is contained in:
MihailRis 2025-08-10 17:31:10 +03:00
commit 67ef84d6b0
9 changed files with 97 additions and 5 deletions

View File

@ -119,13 +119,13 @@ block.seek_origin(x: int, y: int, z: int) -> int, int, int
Part of a voxel data used for scripting. Size: 8 bit.
```python
```lua
block.get_user_bits(x: int, y: int, z: int, offset: int, bits: int) -> int
```
Get specified bits as an unsigned integer.
```python
```lua
block.set_user_bits(x: int, y: int, z: int, offset: int, bits: int, value: int) -> int
```
Set specified bits.
@ -151,6 +151,21 @@ The function returns a table with the results or nil if the ray does not hit any
The result will use the destination table instead of creating a new one if the optional argument specified.
## Model
Block model information.
```lua
-- returns block model type (block/aabb/custom/...)
block.get_model(id: int) -> str
-- returns block model name
block.model_name(id: int) -> str
-- returns array of 6 textures assigned to sides of block
block.get_textures(id: int) -> string table
```
## Data fields
```lua

View File

@ -171,6 +171,9 @@ block.get_hitbox(id: int, rotation_index: int) -> {vec3, vec3}
-- возвращает тип модели блока (block/aabb/custom/...)
block.get_model(id: int) -> str
-- возвращает имя модели блока
block.model_name(id: int) -> str
-- возвращает массив из 6 текстур, назначенных на стороны блока
block.get_textures(id: int) -> таблица строк
```

View File

@ -1,3 +1,12 @@
local WARNING_COLORS = {
{208, 104, 107, 255},
{250, 75, 139, 255},
{250, 151, 75, 255},
{246, 233, 44, 255},
{252, 200, 149, 255}
}
local GENERAL_WARNING_COLOR = {208, 138, 0, 255}
function refresh_search()
local search_text = document.search_textbox.text
@ -40,6 +49,49 @@ function change_sensitivity(val)
refresh_sensitivity()
end
function refresh_binding_marks()
local prev_bindings = {}
local conflicts_colors = {}
local available_colors = table.copy(WARNING_COLORS)
local bindings = input.get_bindings()
table.sort(bindings, function(a, b) return a > b end)
for _, bind_name in ipairs(bindings) do
local key = input.get_binding_text(bind_name)
local prev = prev_bindings[key]
if prev then
local color = GENERAL_WARNING_COLOR
local conflict_color = conflicts_colors[key]
local available_colors_len = #available_colors
if conflict_color then
color = conflict_color
elseif available_colors_len > 0 then
color = available_colors[available_colors_len]
conflicts_colors[key] = color
table.remove(available_colors, available_colors_len)
end
local tooltip = gui.str("settings.Conflict", "settings")
local prev_bindmark = "bindmark_" .. prev
local cur_bindmark = "bindmark_" .. bind_name
document[prev_bindmark].visible = true
document[cur_bindmark].visible = true
document[prev_bindmark].color = color
document[cur_bindmark].color = color
document["bind_" .. prev].tooltip = tooltip
document["bind_" .. bind_name].tooltip = tooltip
else
document["bindmark_" .. bind_name].visible = false
document["bind_" .. bind_name].tooltip = ''
prev_bindings[key] = bind_name
end
end
end
function on_open()
document.sensitivity_track.value = core.get_setting("camera.sensitivity")
refresh_sensitivity()
@ -52,4 +104,8 @@ function on_open()
id=name, name=gui.str(name)
}))
end
document.bindings_panel:setInterval(100, function ()
refresh_binding_marks()
end)
end

View File

@ -1,4 +1,5 @@
<panel size='400,40' padding='4' color='0' orientation='horizontal'>
<panel id='bind_%{id}' size='400,40' padding='4' color='0' orientation='horizontal'>
<bindbox binding='%{id}'/>
<label margin='6'>%{name}</label>
<image id="bindmark_%{id}"src='gui/left_half_block' size='4,28' visible="false"/>
<label id='bindlabel_%{id}' color="#ffffffff" margin='6'>%{name}</label>
</panel>

View File

@ -47,7 +47,8 @@
"gui/info",
"gui/world",
"gui/hud",
"gui/entity"
"gui/entity",
"gui/half_block"
],
"fonts": [
{

View File

@ -22,6 +22,7 @@ graphics.dense-render.tooltip=Enables transparency in blocks like leaves
# settings
settings.Controls Search Mode=Search by attached button name
settings.Conflict=Possible conflicts found
# Bindings
chunks.reload=Reload Chunks

View File

@ -100,6 +100,7 @@ settings.Controls Search Mode=Поиск по привязанной кнопк
settings.Limit Background FPS=Ограничить фоновую частоту кадров
settings.Advanced render=Продвинутый рендер
settings.Shadows quality=Качество теней
settings.Conflict=Найдены возможные конфликты
# Управление
chunks.reload=Перезагрузить Чанки

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

View File

@ -364,6 +364,19 @@ static int l_get_textures(lua::State* L) {
return 0;
}
static int l_model_name(lua::State* L) {
if (auto def = require_block(L)) {
// TODO: variant argument
const auto& modelName = def->defaults.model.name;
if (modelName.empty()) {
return lua::pushlstring(L, def->name + ".model");
}
return lua::pushlstring(L, modelName);
}
return 0;
}
static int l_get_model(lua::State* L) {
if (auto def = require_block(L)) {
// TODO: variant argument
@ -713,6 +726,7 @@ const luaL_Reg blocklib[] = {
{"get_size", lua::wrap<l_get_size>},
{"is_segment", lua::wrap<l_is_segment>},
{"seek_origin", lua::wrap<l_seek_origin>},
{"model_name", lua::wrap<l_model_name>},
{"get_textures", lua::wrap<l_get_textures>},
{"get_model", lua::wrap<l_get_model>},
{"get_hitbox", lua::wrap<l_get_hitbox>},