@@ -46,13 +46,22 @@ with this program; if not, write to the Free Software Foundation, Inc.,
46
46
#include " client/client.h"
47
47
#endif
48
48
49
- struct EnumString ModApiEnvMod::es_ClearObjectsMode[] =
49
+ const EnumString ModApiEnvMod::es_ClearObjectsMode[] =
50
50
{
51
51
{CLEAR_OBJECTS_MODE_FULL, " full" },
52
52
{CLEAR_OBJECTS_MODE_QUICK, " quick" },
53
53
{0 , NULL },
54
54
};
55
55
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
+
56
65
// /////////////////////////////////////////////////////////////////////////////
57
66
58
67
@@ -1389,6 +1398,24 @@ int ModApiEnvMod::l_forceload_block(lua_State *L)
1389
1398
return 0 ;
1390
1399
}
1391
1400
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
+
1392
1419
// forceload_free_block(blockpos)
1393
1420
// blockpos = {x=num, y=num, z=num}
1394
1421
int ModApiEnvMod::l_forceload_free_block (lua_State *L)
@@ -1462,6 +1489,7 @@ void ModApiEnvMod::Initialize(lua_State *L, int top)
1462
1489
API_FCT (transforming_liquid_add);
1463
1490
API_FCT (forceload_block);
1464
1491
API_FCT (forceload_free_block);
1492
+ API_FCT (compare_block_status);
1465
1493
API_FCT (get_translated_string);
1466
1494
}
1467
1495
0 commit comments