add player.create, test.set_setting, test.sleep_until, world.count_chunks
This commit is contained in:
@@ -250,6 +250,14 @@ static int l_set_name(lua::State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_create(lua::State* L) {
|
||||
auto player = level->players->create();
|
||||
if (lua::isstring(L, 1)) {
|
||||
player->setName(lua::require_string(L, 1));
|
||||
}
|
||||
return lua::pushinteger(L, player->getId());
|
||||
}
|
||||
|
||||
const luaL_Reg playerlib[] = {
|
||||
{"get_pos", lua::wrap<l_get_pos>},
|
||||
{"set_pos", lua::wrap<l_set_pos>},
|
||||
@@ -277,5 +285,6 @@ const luaL_Reg playerlib[] = {
|
||||
{"set_camera", lua::wrap<l_set_camera>},
|
||||
{"get_name", lua::wrap<l_get_name>},
|
||||
{"set_name", lua::wrap<l_set_name>},
|
||||
{"create", lua::wrap<l_create>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "lighting/Lighting.hpp"
|
||||
#include "voxels/Chunk.hpp"
|
||||
#include "voxels/Chunks.hpp"
|
||||
#include "voxels/ChunksStorage.hpp"
|
||||
#include "world/Level.hpp"
|
||||
#include "world/World.hpp"
|
||||
|
||||
@@ -231,6 +232,13 @@ static int l_set_chunk_data(lua::State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_count_chunks(lua::State* L) {
|
||||
if (level == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return lua::pushinteger(L, level->chunksStorage->size());
|
||||
}
|
||||
|
||||
const luaL_Reg worldlib[] = {
|
||||
{"is_open", lua::wrap<l_is_open>},
|
||||
{"get_list", lua::wrap<l_get_list>},
|
||||
@@ -246,5 +254,6 @@ const luaL_Reg worldlib[] = {
|
||||
{"exists", lua::wrap<l_exists>},
|
||||
{"get_chunk_data", lua::wrap<l_get_chunk_data>},
|
||||
{"set_chunk_data", lua::wrap<l_set_chunk_data>},
|
||||
{"count_chunks", lua::wrap<l_count_chunks>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user