aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/video/iimage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/lua_api/video/iimage.cpp')
-rw-r--r--src/client/lua_api/video/iimage.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/client/lua_api/video/iimage.cpp b/src/client/lua_api/video/iimage.cpp
index aa51d29..9fb6ec2 100644
--- a/src/client/lua_api/video/iimage.cpp
+++ b/src/client/lua_api/video/iimage.cpp
@@ -47,7 +47,7 @@ int newiimagefromfile(lua_State* L){
img = loader->loadImage(f);
}
if(!hasloaded){
- lua_pushstring(L,"Failed to load file");
+ lua_pushstring(L,"Failed to load file, no image loader for this type.");
lua_error(L);
}
if(!img){
@@ -78,8 +78,20 @@ int setiimagepixel(lua_State* L){
return 0;
}
+//getpixel({self},{x,y})
+int getiimagepixel(lua_State* L){
+ long x,y;
+ popvector2i(L,&x,&y);
+ lua_getfield(L,-1,"image");
+ IImage* img = (IImage*)lua_touserdata(L,-1);
+ SColor color = img->getPixel(x,y);
+ pushvector4i(L,color.getRed(), color.getBlue(), color.getGreen(), color.getAlpha());
+ return 1;
+}
+
static const luaL_reg iimage_m[] = {
- {"setPixel", setiimagepixel},
+ {"setpixel", setiimagepixel},
+ {"getpixel", getiimagepixel},
{0,0},
};