mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Add forceloading
This commit is contained in:
parent
e21b29f422
commit
84b94eb198
9 changed files with 136 additions and 1 deletions
|
@ -258,7 +258,7 @@ void ActiveBlockList::update(std::list<v3s16> &active_positions,
|
|||
/*
|
||||
Create the new list
|
||||
*/
|
||||
std::set<v3s16> newlist;
|
||||
std::set<v3s16> newlist = m_forceloaded_list;
|
||||
for(std::list<v3s16>::iterator i = active_positions.begin();
|
||||
i != active_positions.end(); ++i)
|
||||
{
|
||||
|
|
|
@ -170,6 +170,7 @@ public:
|
|||
}
|
||||
|
||||
std::set<v3s16> m_list;
|
||||
std::set<v3s16> m_forceloaded_list;
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -305,6 +306,8 @@ public:
|
|||
// is weather active in this environment?
|
||||
bool m_use_weather;
|
||||
|
||||
std::set<v3s16>* getForceloadedBlocks() { return &m_active_blocks.m_forceloaded_list; };
|
||||
|
||||
private:
|
||||
|
||||
/*
|
||||
|
|
|
@ -798,6 +798,27 @@ int ModApiEnvMod::l_get_humidity(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
// minetest.forceload_block(blockpos)
|
||||
// blockpos = {x=num, y=num, z=num}
|
||||
int ModApiEnvMod::l_forceload_block(lua_State *L)
|
||||
{
|
||||
GET_ENV_PTR;
|
||||
|
||||
v3s16 blockpos = read_v3s16(L, 1);
|
||||
env->getForceloadedBlocks()->insert(blockpos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// minetest.forceload_free_block(blockpos)
|
||||
// blockpos = {x=num, y=num, z=num}
|
||||
int ModApiEnvMod::l_forceload_free_block(lua_State *L)
|
||||
{
|
||||
GET_ENV_PTR;
|
||||
|
||||
v3s16 blockpos = read_v3s16(L, 1);
|
||||
env->getForceloadedBlocks()->erase(blockpos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ModApiEnvMod::Initialize(lua_State *L, int top)
|
||||
{
|
||||
|
@ -836,4 +857,6 @@ void ModApiEnvMod::Initialize(lua_State *L, int top)
|
|||
API_FCT(transforming_liquid_add);
|
||||
API_FCT(get_heat);
|
||||
API_FCT(get_humidity);
|
||||
API_FCT(forceload_block);
|
||||
API_FCT(forceload_free_block);
|
||||
}
|
||||
|
|
|
@ -151,6 +151,14 @@ private:
|
|||
static int l_get_heat(lua_State *L);
|
||||
static int l_get_humidity(lua_State *L);
|
||||
|
||||
// minetest.forceload_block(blockpos)
|
||||
// forceloads a block
|
||||
static int l_forceload_block(lua_State *L);
|
||||
|
||||
// minetest.forceload_free_block(blockpos)
|
||||
// stops forceloading a position
|
||||
static int l_forceload_free_block(lua_State *L);
|
||||
|
||||
public:
|
||||
static void Initialize(lua_State *L, int top);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue