summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-08-05 13:54:24 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-08-05 13:54:24 (GMT)
commit4ebe56f65c44fb64f023d624a3f62c87fc2d749c (patch)
treead134722825c479d83c775251182bd6cb7b4050b /src/main.c
parent98b6c4b0016c4116834bd023e45b2ef0f447218a (diff)
downloadpowder-4ebe56f65c44fb64f023d624a3f62c87fc2d749c.zip
powder-4ebe56f65c44fb64f023d624a3f62c87fc2d749c.tar.gz
Mouse and keyboard events, replace luaL_openlib() with luaL_register() and move mousex and mousey out of the global table and into the 'tpt' table
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index e1d2d7e..f3da87c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2083,7 +2083,12 @@ int main(int argc, char *argv[])
}
do_s_check = (do_s_check+1) & 15;
}
-
+#ifdef LUACONSOLE
+ if(sdl_key){
+ if(!luacon_keypress(sdl_key, sdl_mod))
+ sdl_key = 0;
+ }
+#endif
if (sys_shortcuts==1)//all shortcuts can be disabled by python scripts
{
if (sdl_key=='q' || sdl_key==SDLK_ESCAPE)
@@ -2511,9 +2516,6 @@ int main(int argc, char *argv[])
}
}
}
-//#ifdef LUACONSOLE
- //luacon_keypress(sdl_key);
-//#endif
#ifdef PYCONSOLE
if (pyready==1 && pygood==1)
if (pkey!=NULL && sdl_key!=NULL)
@@ -2606,8 +2608,12 @@ int main(int argc, char *argv[])
b = SDL_GetMouseState(&x, &y); // b is current mouse state
#ifdef LUACONSOLE
- if(luacon_step(x/sdl_scale, y/sdl_scale, b, bq, sdl_key))
- b = 0; //Mouse click was handled by Lua step
+ if(b){
+ if(!luacon_mouseclick(x/sdl_scale, y/sdl_scale, b, bq)){
+ b = 0;
+ }
+ }
+ luacon_step(x/sdl_scale, y/sdl_scale);
#endif
for (i=0; i<SC_TOTAL; i++)//draw all the menu sections