@@ -46,13 +46,22 @@ with this program; if not, write to the Free Software Foundation, Inc.,
4646#include " client/client.h"
4747#endif
4848
49- struct EnumString ModApiEnvMod::es_ClearObjectsMode[] =
49+ const EnumString ModApiEnvMod::es_ClearObjectsMode[] =
5050{
5151 {CLEAR_OBJECTS_MODE_FULL, " full" },
5252 {CLEAR_OBJECTS_MODE_QUICK, " quick" },
5353 {0 , NULL },
5454};
5555
56+ const EnumString ModApiEnvMod::es_BlockStatusType[] =
57+ {
58+ {ServerEnvironment::BS_UNKNOWN, " unknown" },
59+ {ServerEnvironment::BS_EMERGING, " emerging" },
60+ {ServerEnvironment::BS_LOADED, " loaded" },
61+ {ServerEnvironment::BS_ACTIVE, " active" },
62+ {0 , NULL },
63+ };
64+
5665// /////////////////////////////////////////////////////////////////////////////
5766
5867
@@ -1389,6 +1398,24 @@ int ModApiEnvMod::l_forceload_block(lua_State *L)
13891398 return 0 ;
13901399}
13911400
1401+ // compare_block_status(nodepos)
1402+ int ModApiEnvMod::l_compare_block_status (lua_State *L)
1403+ {
1404+ GET_ENV_PTR;
1405+
1406+ v3s16 nodepos = check_v3s16 (L, 1 );
1407+ std::string condition_s = luaL_checkstring (L, 2 );
1408+ auto status = env->getBlockStatus (getNodeBlockPos (nodepos));
1409+
1410+ int condition_i = -1 ;
1411+ if (!string_to_enum (es_BlockStatusType, condition_i, condition_s))
1412+ return 0 ; // Unsupported
1413+
1414+ lua_pushboolean (L, status >= condition_i);
1415+ return 1 ;
1416+ }
1417+
1418+
13921419// forceload_free_block(blockpos)
13931420// blockpos = {x=num, y=num, z=num}
13941421int ModApiEnvMod::l_forceload_free_block (lua_State *L)
@@ -1462,6 +1489,7 @@ void ModApiEnvMod::Initialize(lua_State *L, int top)
14621489 API_FCT (transforming_liquid_add);
14631490 API_FCT (forceload_block);
14641491 API_FCT (forceload_free_block);
1492+ API_FCT (compare_block_status);
14651493 API_FCT (get_translated_string);
14661494}
14671495
0 commit comments