add world.is_open()

This commit is contained in:
MihailRis 2024-11-05 14:05:32 +03:00
parent f6f82644d4
commit d4f0c906d2
3 changed files with 11 additions and 0 deletions

View File

@ -1,6 +1,9 @@
# *world* library # *world* library
```lua ```lua
-- Checks if world is open
world.is_open() -> bool
-- Returns worlds information. -- Returns worlds information.
world.get_list() -> tables array { world.get_list() -> tables array {
-- world name -- world name

View File

@ -1,6 +1,9 @@
# Библиотека *world* # Библиотека *world*
```lua ```lua
-- Проверяет, открыт ли мир
world.is_open() -> bool
-- Возвращает информацию о мирах. -- Возвращает информацию о мирах.
world.get_list() -> массив таблиц { world.get_list() -> массив таблиц {
-- название мира -- название мира

View File

@ -20,6 +20,10 @@ static WorldInfo& require_world_info() {
return level->getWorld()->getInfo(); return level->getWorld()->getInfo();
} }
static int l_is_open(lua::State* L) {
return lua::pushboolean(L, level != nullptr);
}
static int l_get_list(lua::State* L) { static int l_get_list(lua::State* L) {
auto paths = engine->getPaths(); auto paths = engine->getPaths();
auto worlds = paths->scanForWorlds(); auto worlds = paths->scanForWorlds();
@ -98,6 +102,7 @@ static int l_get_generator(lua::State* L) {
} }
const luaL_Reg worldlib[] = { const luaL_Reg worldlib[] = {
{"is_open", lua::wrap<l_is_open>},
{"get_list", lua::wrap<l_get_list>}, {"get_list", lua::wrap<l_get_list>},
{"get_total_time", lua::wrap<l_get_total_time>}, {"get_total_time", lua::wrap<l_get_total_time>},
{"get_day_time", lua::wrap<l_get_day_time>}, {"get_day_time", lua::wrap<l_get_day_time>},