add player.is_loading_chunks, .set_loading_chunks
This commit is contained in:
parent
0940e899cf
commit
e153e1fbd7
@ -70,6 +70,13 @@ player.set_instant_destruction(playerid: int, bool)
|
|||||||
|
|
||||||
Getter and setter for instant destruction of blocks when the `player.destroy` binding is activated.
|
Getter and setter for instant destruction of blocks when the `player.destroy` binding is activated.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
player.is_loading_chunks(playerid: int) -> bool
|
||||||
|
player.set_loading_chunks(playerid: int, bool)
|
||||||
|
```
|
||||||
|
|
||||||
|
Getter and setter of the property that determines whether the player is loading chunks.
|
||||||
|
|
||||||
``` lua
|
``` lua
|
||||||
player.set_spawnpoint(playerid: int, x: number, y: number, z: number)
|
player.set_spawnpoint(playerid: int, x: number, y: number, z: number)
|
||||||
player.get_spawnpoint(playerid: int) -> number, number, number
|
player.get_spawnpoint(playerid: int) -> number, number, number
|
||||||
|
|||||||
@ -70,6 +70,13 @@ player.set_instant_destruction(playerid: int, bool)
|
|||||||
|
|
||||||
Геттер и сеттер мнгновенного разрушения блоков при активации привязки `player.destroy`.
|
Геттер и сеттер мнгновенного разрушения блоков при активации привязки `player.destroy`.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
player.is_loading_chunks(playerid: int) -> bool
|
||||||
|
player.set_loading_chunks(playerid: int, bool)
|
||||||
|
```
|
||||||
|
|
||||||
|
Геттер и сеттер свойства, определяющего, прогружает ли игрок чанки вокруг.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
player.set_spawnpoint(playerid: int, x: number, y: number, z: number)
|
player.set_spawnpoint(playerid: int, x: number, y: number, z: number)
|
||||||
player.get_spawnpoint(playerid: int) -> number, number, number
|
player.get_spawnpoint(playerid: int) -> number, number, number
|
||||||
|
|||||||
@ -38,7 +38,9 @@ void ChunksController::update(
|
|||||||
int centerX = floordiv<CHUNK_W>(position.x);
|
int centerX = floordiv<CHUNK_W>(position.x);
|
||||||
int centerY = floordiv<CHUNK_D>(position.z);
|
int centerY = floordiv<CHUNK_D>(position.z);
|
||||||
|
|
||||||
generator->update(centerX, centerY, loadDistance);
|
if (player.isLoadingChunks()) {
|
||||||
|
generator->update(centerX, centerY, loadDistance);
|
||||||
|
}
|
||||||
|
|
||||||
int64_t mcstotal = 0;
|
int64_t mcstotal = 0;
|
||||||
|
|
||||||
@ -121,6 +123,12 @@ bool ChunksController::buildLights(const Player& player, const std::shared_ptr<C
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChunksController::createChunk(const Player& player, int x, int z) const {
|
void ChunksController::createChunk(const Player& player, int x, int z) const {
|
||||||
|
if (!player.isLoadingChunks()) {
|
||||||
|
if (auto chunk = level.chunks->fetch(x, z)) {
|
||||||
|
player.chunks->putChunk(chunk);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto chunk = level.chunks->create(x, z);
|
auto chunk = level.chunks->create(x, z);
|
||||||
player.chunks->putChunk(chunk);
|
player.chunks->putChunk(chunk);
|
||||||
auto& chunkFlags = chunk->flags;
|
auto& chunkFlags = chunk->flags;
|
||||||
|
|||||||
@ -164,6 +164,20 @@ static int l_set_instant_destruction(lua::State* L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_is_loading_chunks(lua::State* L) {
|
||||||
|
if (auto player = get_player(L, 1)) {
|
||||||
|
return lua::pushboolean(L, player->isLoadingChunks());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int l_set_loading_chunks(lua::State* L) {
|
||||||
|
if (auto player = get_player(L, 1)) {
|
||||||
|
player->setLoadingChunks(lua::toboolean(L, 2));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int l_get_selected_block(lua::State* L) {
|
static int l_get_selected_block(lua::State* L) {
|
||||||
if (auto player = get_player(L, 1)) {
|
if (auto player = get_player(L, 1)) {
|
||||||
if (player->selection.vox.id == BLOCK_VOID) {
|
if (player->selection.vox.id == BLOCK_VOID) {
|
||||||
@ -282,6 +296,8 @@ const luaL_Reg playerlib[] = {
|
|||||||
{"set_infinite_items", lua::wrap<l_set_infinite_items>},
|
{"set_infinite_items", lua::wrap<l_set_infinite_items>},
|
||||||
{"is_instant_destruction", lua::wrap<l_is_instant_destruction>},
|
{"is_instant_destruction", lua::wrap<l_is_instant_destruction>},
|
||||||
{"set_instant_destruction", lua::wrap<l_set_instant_destruction>},
|
{"set_instant_destruction", lua::wrap<l_set_instant_destruction>},
|
||||||
|
{"is_loading_chunks", lua::wrap<l_is_loading_chunks>},
|
||||||
|
{"set_loading_chunks", lua::wrap<l_set_loading_chunks>},
|
||||||
{"set_selected_slot", lua::wrap<l_set_selected_slot>},
|
{"set_selected_slot", lua::wrap<l_set_selected_slot>},
|
||||||
{"get_selected_block", lua::wrap<l_get_selected_block>},
|
{"get_selected_block", lua::wrap<l_get_selected_block>},
|
||||||
{"get_selected_entity", lua::wrap<l_get_selected_entity>},
|
{"get_selected_entity", lua::wrap<l_get_selected_entity>},
|
||||||
|
|||||||
@ -251,6 +251,14 @@ void Player::setInstantDestruction(bool flag) {
|
|||||||
instantDestruction = flag;
|
instantDestruction = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Player::isLoadingChunks() const {
|
||||||
|
return loadingChunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::setLoadingChunks(bool flag) {
|
||||||
|
loadingChunks = flag;
|
||||||
|
}
|
||||||
|
|
||||||
entityid_t Player::getEntity() const {
|
entityid_t Player::getEntity() const {
|
||||||
return eid;
|
return eid;
|
||||||
}
|
}
|
||||||
@ -297,6 +305,7 @@ dv::value Player::serialize() const {
|
|||||||
root["noclip"] = noclip;
|
root["noclip"] = noclip;
|
||||||
root["infinite-items"] = infiniteItems;
|
root["infinite-items"] = infiniteItems;
|
||||||
root["instant-destruction"] = instantDestruction;
|
root["instant-destruction"] = instantDestruction;
|
||||||
|
root["loading-chunks"] = loadingChunks;
|
||||||
root["chosen-slot"] = chosenSlot;
|
root["chosen-slot"] = chosenSlot;
|
||||||
root["entity"] = eid;
|
root["entity"] = eid;
|
||||||
root["inventory"] = inventory->serialize();
|
root["inventory"] = inventory->serialize();
|
||||||
@ -329,7 +338,8 @@ void Player::deserialize(const dv::value& src) {
|
|||||||
noclip = src["noclip"].asBoolean();
|
noclip = src["noclip"].asBoolean();
|
||||||
src.at("infinite-items").get(infiniteItems);
|
src.at("infinite-items").get(infiniteItems);
|
||||||
src.at("instant-destruction").get(instantDestruction);
|
src.at("instant-destruction").get(instantDestruction);
|
||||||
|
src.at("loading-chunks").get(loadingChunks);
|
||||||
|
|
||||||
setChosenSlot(src["chosen-slot"].asInteger());
|
setChosenSlot(src["chosen-slot"].asInteger());
|
||||||
eid = src["entity"].asNumber();
|
eid = src["entity"].asNumber();
|
||||||
|
|
||||||
|
|||||||
@ -51,6 +51,7 @@ class Player : public Serializable {
|
|||||||
bool noclip = false;
|
bool noclip = false;
|
||||||
bool infiniteItems = true;
|
bool infiniteItems = true;
|
||||||
bool instantDestruction = true;
|
bool instantDestruction = true;
|
||||||
|
bool loadingChunks = true;
|
||||||
entityid_t eid;
|
entityid_t eid;
|
||||||
entityid_t selectedEid = 0;
|
entityid_t selectedEid = 0;
|
||||||
public:
|
public:
|
||||||
@ -97,6 +98,9 @@ public:
|
|||||||
bool isInstantDestruction() const;
|
bool isInstantDestruction() const;
|
||||||
void setInstantDestruction(bool flag);
|
void setInstantDestruction(bool flag);
|
||||||
|
|
||||||
|
bool isLoadingChunks() const;
|
||||||
|
void setLoadingChunks(bool flag);
|
||||||
|
|
||||||
entityid_t getEntity() const;
|
entityid_t getEntity() const;
|
||||||
void setEntity(entityid_t eid);
|
void setEntity(entityid_t eid);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user