diff options
author | Pierre-Yves Rollo <dev@pyrollo.com> | 2020-10-04 15:24:29 +0200 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2020-10-04 15:24:34 +0200 |
commit | 81c66d6efb9fb0ab8a03b40e2bc22aa49eff9a04 (patch) | |
tree | 0f1c256eb6f24eb95df60804d9db82cead0f91e2 /src/script/lua_api/l_minimap.cpp | |
parent | 3068853e8a58ccc7370a5ce977c08223601c497a (diff) | |
download | minetest-81c66d6efb9fb0ab8a03b40e2bc22aa49eff9a04.tar.gz minetest-81c66d6efb9fb0ab8a03b40e2bc22aa49eff9a04.tar.bz2 minetest-81c66d6efb9fb0ab8a03b40e2bc22aa49eff9a04.zip |
Minimap as HUD element with API control
Features:
* Define Minimap available modes (surface/radar, scale) from Lua, using player:set_minimap_modes()
* New HUD elements for displaying minimap with custom size and placing
* New minimap mode for displaying a texture instead of the map
Diffstat (limited to 'src/script/lua_api/l_minimap.cpp')
-rw-r--r-- | src/script/lua_api/l_minimap.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/script/lua_api/l_minimap.cpp b/src/script/lua_api/l_minimap.cpp index 5fba76eb8..3bbb6e5e3 100644 --- a/src/script/lua_api/l_minimap.cpp +++ b/src/script/lua_api/l_minimap.cpp @@ -89,7 +89,7 @@ int LuaMinimap::l_get_mode(lua_State *L) LuaMinimap *ref = checkobject(L, 1); Minimap *m = getobject(ref); - lua_pushinteger(L, m->getMinimapMode()); + lua_pushinteger(L, m->getModeIndex()); return 1; } @@ -98,13 +98,11 @@ int LuaMinimap::l_set_mode(lua_State *L) LuaMinimap *ref = checkobject(L, 1); Minimap *m = getobject(ref); - s32 mode = lua_tointeger(L, 2); - if (mode < MINIMAP_MODE_OFF || - mode >= MINIMAP_MODE_COUNT) { + u32 mode = lua_tointeger(L, 2); + if (mode >= m->getMaxModeIndex()) return 0; - } - m->setMinimapMode((MinimapMode) mode); + m->setModeIndex(mode); return 1; } @@ -140,8 +138,11 @@ int LuaMinimap::l_show(lua_State *L) LuaMinimap *ref = checkobject(L, 1); Minimap *m = getobject(ref); - if (m->getMinimapMode() == MINIMAP_MODE_OFF) - m->setMinimapMode(MINIMAP_MODE_SURFACEx1); + // This is not very adapted to new minimap mode management. Btw, tried + // to do something compatible. + + if (m->getModeIndex() == 0 && m->getMaxModeIndex() > 0) + m->setModeIndex(1); client->showMinimap(true); return 1; @@ -155,8 +156,11 @@ int LuaMinimap::l_hide(lua_State *L) LuaMinimap *ref = checkobject(L, 1); Minimap *m = getobject(ref); - if (m->getMinimapMode() != MINIMAP_MODE_OFF) - m->setMinimapMode(MINIMAP_MODE_OFF); + // This is not very adapted to new minimap mode management. Btw, tried + // to do something compatible. + + if (m->getModeIndex() != 0) + m->setModeIndex(0); client->showMinimap(false); return 1; |