aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/video
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/lua_api/video')
-rw-r--r--src/client/lua_api/video/draw.cpp29
-rw-r--r--src/client/lua_api/video/draw.hpp8
-rw-r--r--src/client/lua_api/video/smaterial.cpp14
3 files changed, 51 insertions, 0 deletions
diff --git a/src/client/lua_api/video/draw.cpp b/src/client/lua_api/video/draw.cpp
new file mode 100644
index 0000000..1f38f34
--- /dev/null
+++ b/src/client/lua_api/video/draw.cpp
@@ -0,0 +1,29 @@
+
+#include <irrlicht.h>
+#include <shared/lua_api/common.hpp>
+#include "draw.hpp"
+
+using namespace irr;
+using namespace video;
+using namespace core;
+
+extern IrrlichtDevice* device;
+extern IVideoDriver* driver;
+//drawline2d {startx,starty},{endx,endy},{r,g,b,a}
+int drawline2d(lua_State *L){
+ long r,g,b,a;
+ popvector4i(L, &r, &g, &b, &a);
+ long endx, endy;
+ popvector2i(L, &endx, &endy);
+ long startx, starty;
+ popvector2i(L, &startx, &starty);
+ driver->draw2DLine(position2d<s32>(startx, starty), position2d<s32>(endx,endy), SColor(r,g,b,a));
+ return 0;
+}
+
+void draw_register(lua_State *L){
+ lua_getglobal(L,"video");//{video}
+ lua_pushcfunction(L,drawline2d);//{video},drawline2d()
+ lua_setfield(L,-2,"drawline2d");//{video}
+ lua_pop(L,1);//
+}
diff --git a/src/client/lua_api/video/draw.hpp b/src/client/lua_api/video/draw.hpp
new file mode 100644
index 0000000..eb5a9a7
--- /dev/null
+++ b/src/client/lua_api/video/draw.hpp
@@ -0,0 +1,8 @@
+
+extern "C" {
+ #include <lua.h>
+ #include <lauxlib.h>
+ #include <lualib.h>
+}
+
+void draw_register(lua_State* L);
diff --git a/src/client/lua_api/video/smaterial.cpp b/src/client/lua_api/video/smaterial.cpp
index 2ef7053..510748c 100644
--- a/src/client/lua_api/video/smaterial.cpp
+++ b/src/client/lua_api/video/smaterial.cpp
@@ -38,8 +38,22 @@ int setTexture(lua_State* L){
return 0;
}
+//{Material},flag,state
+int setFlag(lua_State* L){
+ int b = lua_toboolean(L,-1);//{material},flag,state
+ lua_pop(L,1);//{material},flag
+ int flag = lua_tonumber(L,-1);//{material},flag
+ lua_pop(L,1);//{material}
+ lua_getfield(L,-1,"smaterial");//{material},ud_material
+ SMaterial* mat = (SMaterial*)lua_touserdata(L,-1);
+ lua_pop(L,2);
+ mat->setFlag((E_MATERIAL_FLAG)flag,b == 1 ? true : false);
+ return 0;
+}
+
static const luaL_reg smaterial_m[] = {
{"setTexture", setTexture},
+ {"setFlag", setFlag},
{0,0},
};