summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-11-16 03:25:55 (EST)
committer P. J. McDermott <pjm@nac.net>2013-11-16 03:25:55 (EST)
commitb0b53ee8fe5a6078dfaaf196dc3c1ad179f92eae (patch)
tree8b8ce98b59b9b8ab8b3a2febc9bc96c320049915
parent81e576ed00137543f89e1892f148f442c807fa40 (diff)
downloadoverworld-rpg-b0b53ee8fe5a6078dfaaf196dc3c1ad179f92eae.zip
overworld-rpg-b0b53ee8fe5a6078dfaaf196dc3c1ad179f92eae.tar.gz
overworld-rpg-b0b53ee8fe5a6078dfaaf196dc3c1ad179f92eae.tar.bz2
Expose init_viewport() to Lua scripts.
-rw-r--r--src/script.c3
-rw-r--r--src/viewport.c15
-rw-r--r--src/viewport.h2
3 files changed, 20 insertions, 0 deletions
diff --git a/src/script.c b/src/script.c
index cb1baf6..a4e5988 100644
--- a/src/script.c
+++ b/src/script.c
@@ -21,6 +21,7 @@
#include <lualib.h>
#include <lauxlib.h>
#include "logging.h"
+#include "viewport.h"
#include "script.h"
/* LUA_OK is defined in Lua 5.2 but not 5.1. */
@@ -53,6 +54,8 @@ script_load(const char *path)
lua_tostring(s->lua_state, -1));
}
+ lua_register(s->lua_state, "init_viewport", init_viewport_lua);
+
return s;
}
diff --git a/src/viewport.c b/src/viewport.c
index cff4732..e908268 100644
--- a/src/viewport.c
+++ b/src/viewport.c
@@ -17,6 +17,7 @@
*/
#include <SDL.h>
+#include <lua.h>
#include "viewport.h"
#include "logging.h"
@@ -44,3 +45,17 @@ init_viewport(Uint16 width, Uint16 height, int bpp)
return vp;
}
+
+int
+init_viewport_lua(lua_State *L)
+{
+ Uint16 width;
+ Uint16 height;
+
+ width = lua_tointeger(L, 1);
+ height = lua_tointeger(L, 2);
+
+ init_viewport(width, height, 8);
+
+ return 0;
+}
diff --git a/src/viewport.h b/src/viewport.h
index 7cdc729..19ae57e 100644
--- a/src/viewport.h
+++ b/src/viewport.h
@@ -20,6 +20,7 @@
#define VIEWPORT_H
#include <SDL.h>
+#include <lua.h>
struct viewport {
Sint16 x;
@@ -30,5 +31,6 @@ struct viewport {
};
struct viewport *init_viewport(Uint16 width, Uint16 height, int bpp);
+int init_viewport_lua(lua_State *L);
#endif