82 lines
2.3 KiB
Diff
82 lines
2.3 KiB
Diff
diff --git a/src/game.cpp b/src/game.cpp
|
|
index 1735737d..1f1d8826 100644
|
|
--- a/src/game.cpp
|
|
+++ b/src/game.cpp
|
|
@@ -1876,6 +1876,9 @@ void Game::shutdown()
|
|
****************************************************************************/
|
|
/****************************************************************************/
|
|
|
|
+IWritableTextureSource *g_tsrc;
|
|
+video::IVideoDriver *g_driver;
|
|
+
|
|
bool Game::init(
|
|
const std::string &map_dir,
|
|
std::string *address,
|
|
@@ -1883,8 +1886,10 @@ bool Game::init(
|
|
const SubgameSpec &gamespec)
|
|
{
|
|
showOverlayMessage(wgettext("Loading..."), 0, 0);
|
|
+ g_driver = driver;
|
|
|
|
texture_src = createTextureSource(device);
|
|
+ g_tsrc = texture_src;
|
|
shader_src = createShaderSource(device);
|
|
|
|
itemdef_manager = createItemDefManager();
|
|
diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp
|
|
index c2679164..af3f145a 100644
|
|
--- a/src/script/lua_api/l_util.cpp
|
|
+++ b/src/script/lua_api/l_util.cpp
|
|
@@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|
#include "util/base64.h"
|
|
#include "config.h"
|
|
#include "version.h"
|
|
+#include "client/tile.h"
|
|
#include <algorithm>
|
|
|
|
|
|
@@ -486,6 +487,21 @@ int ModApiUtil::l_get_version(lua_State *L)
|
|
return 1;
|
|
}
|
|
|
|
+extern IWritableTextureSource *g_tsrc;
|
|
+extern irr::video::IVideoDriver *g_driver;
|
|
+
|
|
+// generateAndSaveTexture(texture_name, out_filename)
|
|
+int ModApiUtil::l_generateAndSaveTexture(lua_State *L)
|
|
+{
|
|
+ std::string texname = luaL_checkstring(L, 1);
|
|
+ std::string outfile = luaL_checkstring(L, 2);
|
|
+
|
|
+ irr::video::IImage *img = g_tsrc->generateImage(texname);
|
|
+ g_driver->writeImageToFile(img, outfile.c_str());
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
|
|
void ModApiUtil::Initialize(lua_State *L, int top)
|
|
{
|
|
@@ -524,6 +540,7 @@ void ModApiUtil::Initialize(lua_State *L, int top)
|
|
API_FCT(decode_base64);
|
|
|
|
API_FCT(get_version);
|
|
+ API_FCT(generateAndSaveTexture);
|
|
}
|
|
|
|
void ModApiUtil::InitializeAsync(AsyncEngine& engine)
|
|
diff --git a/src/script/lua_api/l_util.h b/src/script/lua_api/l_util.h
|
|
index 9910704b..8ac49848 100644
|
|
--- a/src/script/lua_api/l_util.h
|
|
+++ b/src/script/lua_api/l_util.h
|
|
@@ -107,6 +107,9 @@ class ModApiUtil : public ModApiBase {
|
|
// get_version()
|
|
static int l_get_version(lua_State *L);
|
|
|
|
+ // generateAndSaveTexture(texture_name, out_filename)
|
|
+ static int l_generateAndSaveTexture(lua_State *L);
|
|
+
|
|
public:
|
|
static void Initialize(lua_State *L, int top);
|
|
|