1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Allow specifying name for dynamic media files

This commit is contained in:
sfan5 2024-01-22 21:24:42 +01:00
parent af69d4f7a9
commit c90ebad46b
5 changed files with 15 additions and 9 deletions

View file

@ -548,11 +548,11 @@ int ModApiServer::l_dynamic_add_media(lua_State *L)
Server *server = getServer(L);
const bool at_startup = !getEnv(L);
std::string filepath;
std::string to_player;
std::string filename, filepath, to_player;
bool ephemeral = false;
if (lua_istable(L, 1)) {
getstringfield(L, 1, "filename", filename);
getstringfield(L, 1, "filepath", filepath);
getstringfield(L, 1, "to_player", to_player);
getboolfield(L, 1, "ephemeral", ephemeral);
@ -576,7 +576,7 @@ int ModApiServer::l_dynamic_add_media(lua_State *L)
u32 token = server->getScriptIface()->allocateDynamicMediaCallback(L, 2);
bool ok = server->dynamicAddMedia(filepath, token, to_player, ephemeral);
bool ok = server->dynamicAddMedia(filename, filepath, token, to_player, ephemeral);
if (!ok)
server->getScriptIface()->freeDynamicMediaCallback(token);
lua_pushboolean(L, ok);