added block.caption(blockid) -> str
This commit is contained in:
@@ -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>},
|
||||||
|
|||||||
Reference in New Issue
Block a user