Fleshed out the pager's API

This commit is contained in:
Kayne Ruse
2014-06-10 00:20:45 +10:00
parent 2d27399fd1
commit b7c12ba106
4 changed files with 135 additions and 29 deletions
+47 -18
View File
@@ -24,55 +24,84 @@
#include "region.hpp"
static int setTile(lua_State* L) {
//operating on a region
Region* ptr = (Region*)lua_touserdata(L, 1);
ptr->SetTile(lua_tointeger(L, 2)-1, lua_tointeger(L, 3)-1, lua_tointeger(L, 4)-1, lua_tointeger(L, 5));
return 0;
Region* region = reinterpret_cast<Region*>(lua_touserdata(L, 1));
int ret = region->SetTile(lua_tointeger(L, 2)-1, lua_tointeger(L, 3)-1, lua_tointeger(L, 4)-1, lua_tointeger(L, 5));
lua_pop(L, 5);
lua_pushinteger(L, ret);
return 1;
}
static int getTile(lua_State* L) {
//operating on a region
Region* ptr = (Region*)lua_touserdata(L, 1);
int ret = ptr->GetTile(lua_tointeger(L, 2)-1, lua_tointeger(L, 3)-1, lua_tointeger(L, 4)-1);
lua_pushnumber(L, ret);
Region* region = reinterpret_cast<Region*>(lua_touserdata(L, 1));
int ret = region->GetTile(lua_tointeger(L, 2)-1, lua_tointeger(L, 3)-1, lua_tointeger(L, 4)-1);
lua_pop(L, 4);
lua_pushinteger(L, ret);
return 1;
}
static int getX(lua_State* L) {
Region* ptr = (Region*)lua_touserdata(L, 1);
lua_pushinteger(L, ptr->GetX());
Region* region = reinterpret_cast<Region*>(lua_touserdata(L, 1));
int ret = region->GetX();
lua_pop(L, 1);
lua_pushinteger(L, ret);
return 1;
}
static int getY(lua_State* L) {
Region* ptr = (Region*)lua_touserdata(L, 1);
lua_pushinteger(L, ptr->GetY());
Region* region = reinterpret_cast<Region*>(lua_touserdata(L, 1));
int ret = region->GetY();
lua_pop(L, 1);
lua_pushinteger(L, ret);
return 1;
}
static int getRegionWidth(lua_State* L) {
static int getWidth(lua_State* L) {
lua_pushinteger(L, REGION_WIDTH);
return 1;
}
static int getRegionHeight(lua_State* L) {
static int getHeight(lua_State* L) {
lua_pushinteger(L, REGION_HEIGHT);
return 1;
}
static int getRegionDepth(lua_State* L) {
static int getDepth(lua_State* L) {
lua_pushinteger(L, REGION_DEPTH);
return 1;
}
static int load(lua_State* L) {
//TODO: fill this
return 0;
}
static int save(lua_State* L) {
//TODO: fill this
return 0;
}
static int create(lua_State* L) {
//TODO: fill this
return 0;
}
static int unload(lua_State* L) {
//TODO: fill this
return 0;
}
static const luaL_Reg regionlib[] = {
{"settile",setTile},
{"gettile",getTile},
{"getx",getX},
{"gety",getY},
{"getregionwidth",getRegionWidth},
{"getregionheight",getRegionHeight},
{"getregiondepth",getRegionDepth},
{"getwidth",getWidth},
{"getheight",getHeight},
{"getdepth",getDepth},
{"load",load},
{"save",save},
{"create",create},
{"unload",unload},
{nullptr, nullptr}
};