mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 13:31:49 +00:00
added block.caption(blockid) -> str
This commit is contained in:
parent
64f8d842af
commit
e8982353cc
1 changed files with 16 additions and 4 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
int l_block_name(lua_State* L) {
|
int l_block_name(lua_State* L) {
|
||||||
auto indices = scripting::content->getIndices();
|
auto indices = scripting::content->getIndices();
|
||||||
lua_Integer id = lua_tointeger(L, 1);
|
lua_Integer id = lua_tointeger(L, 1);
|
||||||
if (id < 0 || size_t(id) >= indices->countBlockDefs()) {
|
if (static_cast<size_t>(id) >= indices->countBlockDefs()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
auto def = indices->getBlockDef(id);
|
auto def = indices->getBlockDef(id);
|
||||||
|
|
@ -27,7 +27,7 @@ int l_block_name(lua_State* L) {
|
||||||
int l_block_material(lua_State* L) {
|
int l_block_material(lua_State* L) {
|
||||||
auto indices = scripting::content->getIndices();
|
auto indices = scripting::content->getIndices();
|
||||||
lua_Integer id = lua_tointeger(L, 1);
|
lua_Integer id = lua_tointeger(L, 1);
|
||||||
if (id < 0 || size_t(id) >= indices->countBlockDefs()) {
|
if (static_cast<size_t>(id) >= indices->countBlockDefs()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
auto def = indices->getBlockDef(id);
|
auto def = indices->getBlockDef(id);
|
||||||
|
|
@ -62,7 +62,7 @@ int l_set_block(lua_State* L) {
|
||||||
lua_Integer id = lua_tointeger(L, 4);
|
lua_Integer id = lua_tointeger(L, 4);
|
||||||
lua_Integer state = lua_tointeger(L, 5);
|
lua_Integer state = lua_tointeger(L, 5);
|
||||||
bool noupdate = lua_toboolean(L, 6);
|
bool noupdate = lua_toboolean(L, 6);
|
||||||
if (id < 0 || size_t(id) >= scripting::indices->countBlockDefs()) {
|
if (static_cast<size_t>(id) >= scripting::indices->countBlockDefs()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!scripting::level->chunks->get(x, y, z)) {
|
if (!scripting::level->chunks->get(x, y, z)) {
|
||||||
|
|
@ -70,8 +70,9 @@ int l_set_block(lua_State* L) {
|
||||||
}
|
}
|
||||||
scripting::level->chunks->set(x, y, z, id, int2blockstate(state));
|
scripting::level->chunks->set(x, y, z, id, int2blockstate(state));
|
||||||
scripting::level->lighting->onBlockSet(x,y,z, id);
|
scripting::level->lighting->onBlockSet(x,y,z, id);
|
||||||
if (!noupdate)
|
if (!noupdate) {
|
||||||
scripting::blocks->updateSides(x, y, z);
|
scripting::blocks->updateSides(x, y, z);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -236,6 +237,17 @@ int l_is_replaceable_at(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int l_get_caption(lua_State* L) {
|
||||||
|
auto indices = scripting::content->getIndices();
|
||||||
|
lua_Integer id = lua_tointeger(L, 1);
|
||||||
|
if (static_cast<size_t>(id) >= indices->countBlockDefs()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
auto def = indices->getBlockDef(id);
|
||||||
|
lua_pushstring(L, def->caption.c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg blocklib [] = {
|
const luaL_Reg blocklib [] = {
|
||||||
{"index", lua_wrap_errors<l_block_index>},
|
{"index", lua_wrap_errors<l_block_index>},
|
||||||
{"name", lua_wrap_errors<l_block_name>},
|
{"name", lua_wrap_errors<l_block_name>},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue