aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/gui/iguilabel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/lua_api/gui/iguilabel.cpp')
-rw-r--r--src/client/lua_api/gui/iguilabel.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/client/lua_api/gui/iguilabel.cpp b/src/client/lua_api/gui/iguilabel.cpp
index 92611b2..336f81c 100644
--- a/src/client/lua_api/gui/iguilabel.cpp
+++ b/src/client/lua_api/gui/iguilabel.cpp
@@ -17,12 +17,24 @@ extern "C" {
#include "../../callbackhandeler.hpp"
#include <shared/lua_api/common.hpp>
+/***
+@module gui
+*/
using namespace irr;
using namespace gui;
extern IrrlichtDevice* device;
-//gui.newguilabel({{sx,sy},{ex,ey}},"text"[,parent]) :: {guielement}
+/***
+@function newlabel()
+Creates a new label to display text.
+@tparam rect pos The position of the label, reletive to the upper-left of it's
+parent element, or the root window if parent is nil.
+@tparam string text The text to display on this label.
+@tparam ?iguielement parent The parent element of the button.
+@treturn iguilabel The label element
+*/
+//gui.newlabel({{sx,sy},{ex,ey}},"text"[,parent]) :: {guielement}
static int newiguilabel(lua_State* L){
printf("Createing label!\n");
int nargs = lua_gettop(L);
@@ -36,8 +48,9 @@ static int newiguilabel(lua_State* L){
const char* text = lua_tostring(L,-1);//{{sx,sy},{ex,ey}},"text"
int bls = strlen(text);
- wchar_t* text_w = (wchar_t*)malloc(sizeof(wchar_t)*bls);
+ wchar_t* text_w = (wchar_t*)malloc((sizeof(wchar_t)*bls) + 1);//+1 for null
mbstowcs(text_w,text,bls);
+ text_w[bls] = L'\0';
lua_pop(L,1);//{{sx,sy},{ex,ey}}
long sx, sy, ex, ey;