Merge pull request #587 from MihailRis/block.model_name
block.model_name
This commit is contained in:
commit
0692d09560
@ -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
|
||||
|
||||
@ -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) -> таблица строк
|
||||
```
|
||||
|
||||
@ -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>},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user