mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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
This commit is contained in:
parent
3068853e8a
commit
81c66d6efb
20 changed files with 470 additions and 144 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue