VERSIÓ 1.0 RC2
- Nova i, espere, definitiva API
This commit is contained in:
403
lua.cpp
403
lua.cpp
@@ -60,14 +60,14 @@ extern "C" {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_surf_getSize(lua_State *L) {
|
||||
static int cpp_surf_size(lua_State *L) {
|
||||
uint8_t surface = luaL_checkinteger(L, 1);
|
||||
lua_pushinteger(L, surfw(surface));
|
||||
lua_pushinteger(L, surfh(surface));
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int cpp_surf_setTarget(lua_State *L) {
|
||||
static int cpp_surf_target(lua_State *L) {
|
||||
const int numargs = lua_gettop(L);
|
||||
switch (numargs) {
|
||||
case 0: {
|
||||
@@ -80,7 +80,24 @@ extern "C" {
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return luaL_error(L, "Function 'surface.setTarget' Unexpected number of parameters.");
|
||||
return luaL_error(L, "Function 'surface.target' Unexpected number of parameters.");
|
||||
};
|
||||
}
|
||||
|
||||
static int cpp_surf_source(lua_State *L) {
|
||||
const int numargs = lua_gettop(L);
|
||||
switch (numargs) {
|
||||
case 0: {
|
||||
setsource(0);
|
||||
return 0;
|
||||
}
|
||||
case 1: {
|
||||
uint8_t surface = luaL_checkinteger(L, 1);
|
||||
setsource(surface);
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return luaL_error(L, "Function 'surface.source' Unexpected number of parameters.");
|
||||
};
|
||||
}
|
||||
|
||||
@@ -90,52 +107,20 @@ extern "C" {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_surf_setPixel(lua_State *L) {
|
||||
const int numargs = lua_gettop(L);
|
||||
switch (numargs) {
|
||||
case 3: {
|
||||
static int cpp_surf_pixel(lua_State *L) {
|
||||
if (lua_gettop(L)==2) {
|
||||
int x = luaL_checknumber(L, 1);
|
||||
int y = luaL_checknumber(L, 2);
|
||||
lua_pushinteger(L, sget(x, y));
|
||||
return 1;
|
||||
} else {
|
||||
int x = luaL_checknumber(L, 1);
|
||||
int y = luaL_checknumber(L, 2);
|
||||
uint8_t color = luaL_checkinteger(L, 3);
|
||||
pset(x, y, color);
|
||||
return 0;
|
||||
}
|
||||
case 4: {
|
||||
uint8_t surface = luaL_checkinteger(L, 1);
|
||||
setsource(surface);
|
||||
int x = luaL_checknumber(L, 2);
|
||||
int y = luaL_checknumber(L, 3);
|
||||
uint8_t color = luaL_checkinteger(L, 4);
|
||||
sset(x, y, color);
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return luaL_error(L, "Function 'surface.setPixel' Unexpected number of parameters.");
|
||||
};
|
||||
}
|
||||
|
||||
static int cpp_surf_getPixel(lua_State *L) {
|
||||
const int numargs = lua_gettop(L);
|
||||
switch (numargs) {
|
||||
case 2: {
|
||||
int x = luaL_checknumber(L, 1);
|
||||
int y = luaL_checknumber(L, 2);
|
||||
lua_pushinteger(L, pget(x, y));
|
||||
return 1;
|
||||
}
|
||||
case 3: {
|
||||
uint8_t surface = luaL_checkinteger(L, 1);
|
||||
setsource(surface);
|
||||
int x = luaL_checknumber(L, 2);
|
||||
int y = luaL_checknumber(L, 3);
|
||||
lua_pushinteger(L, sget(x, y));
|
||||
return 1;
|
||||
}
|
||||
default:
|
||||
return luaL_error(L, "Function 'surface.getPixel' Unexpected number of parameters.");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// map
|
||||
// ===============================================
|
||||
@@ -184,20 +169,20 @@ extern "C" {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_map_getTile(lua_State *L) {
|
||||
static int cpp_map_tile(lua_State *L) {
|
||||
if (lua_gettop(L)==2) {
|
||||
int celx = luaL_checknumber(L, 1);
|
||||
int cely = luaL_checknumber(L, 2);
|
||||
lua_pushinteger(L, mget(celx, cely));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cpp_map_setTile(lua_State *L) {
|
||||
} else {
|
||||
int celx = luaL_checknumber(L, 1);
|
||||
int cely = luaL_checknumber(L, 2);
|
||||
uint8_t snum = luaL_checkinteger(L, 3);
|
||||
mset(celx, cely, snum);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// palette
|
||||
@@ -251,18 +236,16 @@ extern "C" {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_pal_getColor(lua_State *L) {
|
||||
if (lua_gettop(L) != 1) return luaL_error(L, "Function 'mini.palette.getColor' Unexpected number of parameters.");
|
||||
static int cpp_pal_color(lua_State *L) {
|
||||
//if (lua_gettop(L) != 1) return luaL_error(L, "Function 'mini.palette.getColor' Unexpected number of parameters.");
|
||||
if (lua_gettop(L) == 1) {
|
||||
uint8_t index = luaL_checkinteger(L, 1);
|
||||
uint32_t color = getcolor(index);
|
||||
lua_pushinteger(L, (color>>16)&0xff);
|
||||
lua_pushinteger(L, (color>>8)&0xff);
|
||||
lua_pushinteger(L, color&0xff);
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int cpp_pal_setColor(lua_State *L) {
|
||||
if (lua_gettop(L) != 4) return luaL_error(L, "Function 'mini.palette.setColor' Unexpected number of parameters.");
|
||||
} else {
|
||||
uint8_t index = luaL_checkinteger(L, 1);
|
||||
uint8_t r = luaL_checkinteger(L, 2);
|
||||
uint8_t g = luaL_optinteger(L, 3, 0);
|
||||
@@ -271,6 +254,7 @@ extern "C" {
|
||||
setcolor(index, color);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int cpp_pal_trans(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
@@ -283,56 +267,40 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// subpalette
|
||||
// ===============================================
|
||||
static int cpp_subpalette_resetAll(lua_State *L) {
|
||||
static int cpp_pal_subpal(lua_State *L) {
|
||||
const int num_params = lua_gettop(L);
|
||||
uint8_t index, index2, color;
|
||||
switch (num_params) {
|
||||
case 0:
|
||||
reset_subpal();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_subpalette_set(lua_State *L) {
|
||||
uint8_t index, color;
|
||||
break;
|
||||
case 1:
|
||||
index = luaL_checkinteger(L, 1);
|
||||
subpal(index,index);
|
||||
break;
|
||||
case 2:
|
||||
index = luaL_checkinteger(L, 1);
|
||||
color = luaL_checkinteger(L, 2);
|
||||
subpal(index, color);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_subpalette_reset(lua_State *L) {
|
||||
uint8_t index;
|
||||
index = luaL_checkinteger(L, 1);
|
||||
subpal(index,index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_subpalette_setRange(lua_State *L) {
|
||||
uint8_t index, index2, color;
|
||||
break;
|
||||
case 3:
|
||||
index = luaL_checkinteger(L, 1);
|
||||
index2 = luaL_checkinteger(L, 2);
|
||||
color = luaL_checkinteger(L, 3);
|
||||
for (int i=index;i<=index2;++i) subpal(i, color);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_subpalette_resetRange(lua_State *L) {
|
||||
uint8_t index, index2;
|
||||
index = luaL_checkinteger(L, 1);
|
||||
index2 = luaL_checkinteger(L, 2);
|
||||
for (int i=index;i<=index2;++i) subpal(i, i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// viewport
|
||||
// ===============================================
|
||||
|
||||
static int cpp_viewport_resetClipping(lua_State *L) {
|
||||
static int cpp_viewport_clip(lua_State *L) {
|
||||
if (lua_gettop(L)==0) {
|
||||
clip();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_viewport_setClipping(lua_State *L) {
|
||||
} else {
|
||||
int x = luaL_checknumber(L, 1);
|
||||
int y = luaL_checknumber(L, 2);
|
||||
int w = luaL_checknumber(L, 3);
|
||||
@@ -340,21 +308,22 @@ extern "C" {
|
||||
clip(x, y, w, h);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int cpp_viewport_setOrigin(lua_State *L) {
|
||||
static int cpp_viewport_origin(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
lua_pushinteger(L, camx());
|
||||
lua_pushinteger(L, camy());
|
||||
return 2;
|
||||
} else {
|
||||
int x = luaL_checknumber(L, 1);
|
||||
int y = luaL_checknumber(L, 2);
|
||||
origin(x, y);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_viewport_getOrigin(lua_State *L) {
|
||||
lua_pushinteger(L, camx());
|
||||
lua_pushinteger(L, camy());
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int cpp_viewport_tolocal(lua_State *L) {
|
||||
static int cpp_viewport_local(lua_State *L) {
|
||||
int x = luaL_checknumber(L, 1);
|
||||
int y = luaL_checknumber(L, 2);
|
||||
lua_pushinteger(L, x+camx());
|
||||
@@ -509,33 +478,29 @@ extern "C" {
|
||||
}*/
|
||||
|
||||
static int cpp_draw_surface(lua_State *L) {
|
||||
uint8_t surface = luaL_checkinteger(L, 1);
|
||||
setsource(surface);
|
||||
int sx = luaL_checknumber(L, 2);
|
||||
int sy = luaL_checknumber(L, 3);
|
||||
int sw = luaL_checknumber(L, 4);
|
||||
int sh = luaL_checknumber(L, 5);
|
||||
int dx = luaL_checknumber(L, 6);
|
||||
int dy = luaL_checknumber(L, 7);
|
||||
int dw = luaL_optnumber(L, 8, 0);
|
||||
int dh = luaL_optnumber(L, 9, 0);
|
||||
bool flip_x = lua_toboolean(L, 10);
|
||||
bool flip_y = lua_toboolean(L, 11);
|
||||
bool invert = lua_toboolean(L, 12);
|
||||
int sx = luaL_checknumber(L, 1);
|
||||
int sy = luaL_checknumber(L, 2);
|
||||
int sw = luaL_checknumber(L, 3);
|
||||
int sh = luaL_checknumber(L, 4);
|
||||
int dx = luaL_checknumber(L, 5);
|
||||
int dy = luaL_checknumber(L, 6);
|
||||
int dw = luaL_optnumber(L, 7, 0);
|
||||
int dh = luaL_optnumber(L, 8, 0);
|
||||
bool flip_x = lua_toboolean(L, 9);
|
||||
bool flip_y = lua_toboolean(L, 10);
|
||||
bool invert = lua_toboolean(L, 11);
|
||||
blit(sx, sy, sw, sh, dx, dy, dw, dh, flip_x, flip_y, invert);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_draw_surfaceRotated(lua_State *L) {
|
||||
uint8_t surface = luaL_checkinteger(L, 1);
|
||||
setsource(surface);
|
||||
int sx = luaL_checknumber(L, 2);
|
||||
int sy = luaL_checknumber(L, 3);
|
||||
int sw = luaL_checknumber(L, 4);
|
||||
int sh = luaL_checknumber(L, 5);
|
||||
int dx = luaL_checknumber(L, 6);
|
||||
int dy = luaL_checknumber(L, 7);
|
||||
float a = luaL_checknumber(L, 8);
|
||||
int sx = luaL_checknumber(L, 1);
|
||||
int sy = luaL_checknumber(L, 2);
|
||||
int sw = luaL_checknumber(L, 3);
|
||||
int sh = luaL_checknumber(L, 4);
|
||||
int dx = luaL_checknumber(L, 5);
|
||||
int dy = luaL_checknumber(L, 6);
|
||||
float a = luaL_checknumber(L, 7);
|
||||
blit_r(sx, sy, sw, sh, dx, dy, a);
|
||||
return 0;
|
||||
}
|
||||
@@ -580,14 +545,14 @@ extern "C" {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_music_setPosition(lua_State *L) {
|
||||
static int cpp_music_pos(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
lua_pushnumber(L, musicpos());
|
||||
return 1;
|
||||
} else {
|
||||
musicpos(luaL_checknumber(L, 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_music_getPosition(lua_State *L) {
|
||||
lua_pushnumber(L, musicpos());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -628,30 +593,27 @@ extern "C" {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cpp_sys_setBeat(lua_State *L) {
|
||||
static int cpp_sys_beat(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
lua_pushboolean(L, beat(-1));
|
||||
return 1;
|
||||
} else {
|
||||
int16_t beats = luaL_optnumber(L, 1, -1);
|
||||
beat(beats);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int cpp_sys_isBeat(lua_State *L) {
|
||||
lua_pushboolean(L, beat(-1));
|
||||
static int cpp_sys_update(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
lua_pushinteger(L, getupdatemode());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cpp_sys_updateFullSpeed(lua_State *L) {
|
||||
setupdatemode(UPDATE_ALWAYS);
|
||||
} else {
|
||||
int mode = luaL_checknumber(L, 1);
|
||||
int interval = luaL_optinteger(L, 2, 0);
|
||||
setupdatemode(mode, interval);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_sys_updateEvents(lua_State *L) {
|
||||
setupdatemode(UPDATE_WAIT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_sys_updateTimeout(lua_State *L) {
|
||||
setupdatemode(UPDATE_TIMEOUT, luaL_checknumber(L, 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_sys_dir(lua_State *L) {
|
||||
@@ -679,51 +641,60 @@ extern "C" {
|
||||
// win
|
||||
// ===============================================
|
||||
|
||||
static int cpp_win_getZoom(lua_State *L) {
|
||||
static int cpp_win_zoom(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
lua_pushinteger(L, getzoom());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cpp_win_setZoom(lua_State *L) {
|
||||
} else {
|
||||
const int value = luaL_optinteger(L, 1, 0);
|
||||
setzoom(value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_win_getFullscreen(lua_State *L) {
|
||||
lua_pushboolean(L, getfullscreen());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cpp_win_setFullscreen(lua_State *L) {
|
||||
static int cpp_win_fullscreen(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
lua_pushboolean(L, getfullscreen());
|
||||
return 1;
|
||||
} else {
|
||||
setfullscreen(lua_toboolean(L, 1));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int cpp_win_showCursor(lua_State *L) {
|
||||
static int cpp_win_cursor(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
lua_pushboolean(L, getcursor());
|
||||
return 1;
|
||||
} else {
|
||||
setcursor(lua_toboolean(L, 1));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int cpp_win_getResolution(lua_State *L) {
|
||||
static int cpp_win_res(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
lua_pushinteger(L, scrw());
|
||||
lua_pushinteger(L, scrh());
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int cpp_win_setResolution(lua_State *L) {
|
||||
} else {
|
||||
const int w = luaL_optinteger(L, 1, 160);
|
||||
const int h = luaL_optinteger(L, 2, 120);
|
||||
setres(w, h);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// conf
|
||||
// ===============================================
|
||||
|
||||
static int cpp_conf_getKey(lua_State *L) {
|
||||
static int cpp_conf_key(lua_State *L) {
|
||||
const char* key = luaL_checkstring(L, 1);
|
||||
if (lua_gettop(L) > 1) {
|
||||
const char* value = luaL_checkstring(L, 2);
|
||||
setconfig(key, value);
|
||||
return 0;
|
||||
} else {
|
||||
const char* value = getconfig(key);
|
||||
if (value==NULL) {
|
||||
lua_pushnil(L);
|
||||
@@ -732,12 +703,6 @@ extern "C" {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cpp_conf_setKey(lua_State *L) {
|
||||
const char* key = luaL_checkstring(L, 1);
|
||||
const char* value = luaL_checkstring(L, 2);
|
||||
setconfig(key, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_conf_folder(lua_State *L) {
|
||||
@@ -842,12 +807,12 @@ void push_lua_funcs() {
|
||||
lua_pushcfunction(L,cpp_surf_load); lua_setfield(L, -2, "load");
|
||||
lua_pushcfunction(L,cpp_surf_save); lua_setfield(L, -2, "save");
|
||||
lua_pushcfunction(L,cpp_surf_free); lua_setfield(L, -2, "free");
|
||||
lua_pushcfunction(L,cpp_surf_getSize); lua_setfield(L, -2, "getSize");
|
||||
lua_pushcfunction(L,cpp_surf_setTarget); lua_setfield(L, -2, "setTarget");
|
||||
lua_pushcfunction(L,cpp_surf_size); lua_setfield(L, -2, "size");
|
||||
lua_pushcfunction(L,cpp_surf_target); lua_setfield(L, -2, "target");
|
||||
lua_pushcfunction(L,cpp_surf_source); lua_setfield(L, -2, "source");
|
||||
lua_pushcfunction(L,cpp_surf_cls); lua_setfield(L, -2, "cls");
|
||||
lua_pushcfunction(L,cpp_surf_setPixel); lua_setfield(L, -2, "setPixel");
|
||||
lua_pushcfunction(L,cpp_surf_getPixel); lua_setfield(L, -2, "getPixel");
|
||||
lua_setglobal(L, "surface");
|
||||
lua_pushcfunction(L,cpp_surf_pixel); lua_setfield(L, -2, "pixel");
|
||||
lua_setglobal(L, "surf");
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_map_new); lua_setfield(L, -2, "new");
|
||||
@@ -855,50 +820,39 @@ void push_lua_funcs() {
|
||||
lua_pushcfunction(L,cpp_map_save); lua_setfield(L, -2, "save");
|
||||
lua_pushcfunction(L,cpp_map_set); lua_setfield(L, -2, "set");
|
||||
lua_pushcfunction(L,cpp_map_draw); lua_setfield(L, -2, "draw");
|
||||
lua_pushcfunction(L,cpp_map_getTile); lua_setfield(L, -2, "getTile");
|
||||
lua_pushcfunction(L,cpp_map_setTile); lua_setfield(L, -2, "setTile");
|
||||
lua_setglobal(L, "tilemap");
|
||||
lua_pushcfunction(L,cpp_map_tile); lua_setfield(L, -2, "tile");
|
||||
lua_setglobal(L, "map");
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_pal_load); lua_setfield(L, -2, "load");
|
||||
lua_pushcfunction(L,cpp_pal_set); lua_setfield(L, -2, "set");
|
||||
lua_pushcfunction(L,cpp_pal_getColor); lua_setfield(L, -2, "getColor");
|
||||
lua_pushcfunction(L,cpp_pal_setColor); lua_setfield(L, -2, "setColor");
|
||||
lua_pushcfunction(L,cpp_pal_trans); lua_setfield(L, -2, "setTransparent");
|
||||
lua_setglobal(L, "palette");
|
||||
lua_pushcfunction(L,cpp_pal_color); lua_setfield(L, -2, "color");
|
||||
lua_pushcfunction(L,cpp_pal_trans); lua_setfield(L, -2, "trans");
|
||||
lua_pushcfunction(L,cpp_pal_subpal); lua_setfield(L, -2, "subpal");
|
||||
lua_setglobal(L, "pal");
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_subpalette_resetAll); lua_setfield(L, -2, "resetAll");
|
||||
lua_pushcfunction(L,cpp_subpalette_set); lua_setfield(L, -2, "set");
|
||||
lua_pushcfunction(L,cpp_subpalette_reset); lua_setfield(L, -2, "reset");
|
||||
lua_pushcfunction(L,cpp_subpalette_setRange); lua_setfield(L, -2, "setRange");
|
||||
lua_pushcfunction(L,cpp_subpalette_resetRange); lua_setfield(L, -2, "resetRange");
|
||||
lua_setglobal(L, "subpalette");
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_viewport_resetClipping);lua_setfield(L, -2, "resetClipping");
|
||||
lua_pushcfunction(L,cpp_viewport_setClipping); lua_setfield(L, -2, "setClipping");
|
||||
lua_pushcfunction(L,cpp_viewport_setOrigin); lua_setfield(L, -2, "setOrigin");
|
||||
lua_pushcfunction(L,cpp_viewport_getOrigin); lua_setfield(L, -2, "getOrigin");
|
||||
lua_pushcfunction(L,cpp_viewport_tolocal); lua_setfield(L, -2, "tolocal");
|
||||
lua_setglobal(L, "viewport");
|
||||
lua_pushcfunction(L,cpp_viewport_clip); lua_setfield(L, -2, "clip");
|
||||
lua_pushcfunction(L,cpp_viewport_origin); lua_setfield(L, -2, "origin");
|
||||
lua_pushcfunction(L,cpp_viewport_local); lua_setfield(L, -2, "local");
|
||||
lua_setglobal(L, "view");
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_draw_line); lua_setfield(L, -2, "line");
|
||||
lua_pushcfunction(L,cpp_draw_hline); lua_setfield(L, -2, "hline");
|
||||
lua_pushcfunction(L,cpp_draw_vline); lua_setfield(L, -2, "vline");
|
||||
lua_pushcfunction(L,cpp_draw_rect); lua_setfield(L, -2, "rect");
|
||||
lua_pushcfunction(L,cpp_draw_rectfill); lua_setfield(L, -2, "rectFill");
|
||||
lua_pushcfunction(L,cpp_draw_rectfill); lua_setfield(L, -2, "rectf");
|
||||
lua_pushcfunction(L,cpp_draw_circ); lua_setfield(L, -2, "circ");
|
||||
lua_pushcfunction(L,cpp_draw_circfill); lua_setfield(L, -2, "circFill");
|
||||
lua_pushcfunction(L,cpp_draw_circfill); lua_setfield(L, -2, "circf");
|
||||
lua_pushcfunction(L,cpp_draw_oval); lua_setfield(L, -2, "oval");
|
||||
lua_pushcfunction(L,cpp_draw_ovalfill); lua_setfield(L, -2, "ovalFill");
|
||||
lua_pushcfunction(L,cpp_draw_pattern); lua_setfield(L, -2, "setPattern");
|
||||
lua_pushcfunction(L,cpp_draw_ovalfill); lua_setfield(L, -2, "ovalf");
|
||||
lua_pushcfunction(L,cpp_draw_pattern); lua_setfield(L, -2, "pattern");
|
||||
//lua_pushcfunction(L,cpp_draw_tline); lua_setfield(L, -2, "tline");
|
||||
//lua_pushcfunction(L,cpp_draw_thline); lua_setfield(L, -2, "thline");
|
||||
//lua_pushcfunction(L,cpp_draw_tvline); lua_setfield(L, -2, "tvline");
|
||||
lua_pushcfunction(L,cpp_draw_surface); lua_setfield(L, -2, "surface");
|
||||
lua_pushcfunction(L,cpp_draw_surfaceRotated); lua_setfield(L, -2, "surfaceRotated");
|
||||
lua_pushcfunction(L,cpp_draw_surface); lua_setfield(L, -2, "surf");
|
||||
lua_pushcfunction(L,cpp_draw_surfaceRotated); lua_setfield(L, -2, "surfrot");
|
||||
lua_pushcfunction(L,cpp_draw_text); lua_setfield(L, -2, "text");
|
||||
lua_setglobal(L, "draw");
|
||||
|
||||
@@ -907,8 +861,7 @@ void push_lua_funcs() {
|
||||
lua_pushcfunction(L,cpp_music_pause); lua_setfield(L, -2, "pause");
|
||||
lua_pushcfunction(L,cpp_music_resume); lua_setfield(L, -2, "resume");
|
||||
lua_pushcfunction(L,cpp_music_stop); lua_setfield(L, -2, "stop");
|
||||
lua_pushcfunction(L,cpp_music_setPosition); lua_setfield(L, -2, "setPosition");
|
||||
lua_pushcfunction(L,cpp_music_getPosition); lua_setfield(L, -2, "getPosition");
|
||||
lua_pushcfunction(L,cpp_music_pos); lua_setfield(L, -2, "pos");
|
||||
lua_setglobal(L, "music");
|
||||
|
||||
lua_newtable(L);
|
||||
@@ -919,47 +872,45 @@ void push_lua_funcs() {
|
||||
lua_setglobal(L, "sound");
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_sys_time); lua_setfield(L, -2, "getTime");
|
||||
lua_pushcfunction(L,cpp_sys_setBeat); lua_setfield(L, -2, "setBeat");
|
||||
lua_pushcfunction(L,cpp_sys_isBeat); lua_setfield(L, -2, "isBeat");
|
||||
lua_pushcfunction(L,cpp_sys_updateFullSpeed); lua_setfield(L, -2, "updateAtFullSpeed");
|
||||
lua_pushcfunction(L,cpp_sys_updateEvents); lua_setfield(L, -2, "updateOnlyOnEvents");
|
||||
lua_pushcfunction(L,cpp_sys_updateTimeout); lua_setfield(L, -2, "updateOnEventsAndTimeout");
|
||||
lua_pushcfunction(L,cpp_sys_dir); lua_setfield(L, -2, "getFilesInDataDirectory");
|
||||
lua_pushcfunction(L,cpp_sys_time); lua_setfield(L, -2, "time");
|
||||
lua_pushcfunction(L,cpp_sys_beat); lua_setfield(L, -2, "beat");
|
||||
lua_pushcfunction(L,cpp_sys_update); lua_setfield(L, -2, "update");
|
||||
lua_pushcfunction(L,cpp_sys_dir); lua_setfield(L, -2, "dir");
|
||||
lua_pushcfunction(L,cpp_sys_exit); lua_setfield(L, -2, "quit");
|
||||
lua_pushcfunction(L,cpp_sys_fps); lua_setfield(L, -2, "fps");
|
||||
lua_setglobal(L, "system");
|
||||
|
||||
lua_pushinteger(L, 0); lua_setfield(L, -2, "UPDATE_ALWAYS");
|
||||
lua_pushinteger(L, 1); lua_setfield(L, -2, "UPDATE_WAIT");
|
||||
lua_pushinteger(L, 2); lua_setfield(L, -2, "UPDATE_TIMEOUT");
|
||||
|
||||
lua_setglobal(L, "sys");
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_win_setZoom); lua_setfield(L, -2, "setZoom");
|
||||
lua_pushcfunction(L,cpp_win_getZoom); lua_setfield(L, -2, "getZoom");
|
||||
lua_pushcfunction(L,cpp_win_setFullscreen); lua_setfield(L, -2, "setFullscreen");
|
||||
lua_pushcfunction(L,cpp_win_getFullscreen); lua_setfield(L, -2, "getFullscreen");
|
||||
lua_pushcfunction(L,cpp_win_showCursor); lua_setfield(L, -2, "showCursor");
|
||||
lua_pushcfunction(L,cpp_win_getResolution); lua_setfield(L, -2, "getResolution");
|
||||
lua_pushcfunction(L,cpp_win_setResolution); lua_setfield(L, -2, "setResolution");
|
||||
lua_setglobal(L, "window");
|
||||
lua_pushcfunction(L,cpp_win_zoom); lua_setfield(L, -2, "zoom");
|
||||
lua_pushcfunction(L,cpp_win_fullscreen); lua_setfield(L, -2, "fullscreen");
|
||||
lua_pushcfunction(L,cpp_win_cursor); lua_setfield(L, -2, "cursor");
|
||||
lua_pushcfunction(L,cpp_win_res); lua_setfield(L, -2, "res");
|
||||
lua_setglobal(L, "win");
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_conf_setKey); lua_setfield(L, -2, "setKey");
|
||||
lua_pushcfunction(L,cpp_conf_getKey); lua_setfield(L, -2, "getKey");
|
||||
lua_pushcfunction(L,cpp_conf_folder); lua_setfield(L, -2, "getConfigFolder");
|
||||
lua_pushcfunction(L,cpp_conf_key); lua_setfield(L, -2, "key");
|
||||
lua_pushcfunction(L,cpp_conf_folder); lua_setfield(L, -2, "folder");
|
||||
lua_setglobal(L, "config");
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_mouse_pos); lua_setfield(L, -2, "getPos");
|
||||
lua_pushcfunction(L,cpp_mouse_wheel); lua_setfield(L, -2, "getWheel");
|
||||
lua_pushcfunction(L,cpp_mouse_down); lua_setfield(L, -2, "buttonDown");
|
||||
lua_pushcfunction(L,cpp_mouse_press); lua_setfield(L, -2, "buttonPressed");
|
||||
lua_pushcfunction(L,cpp_mouse_pos); lua_setfield(L, -2, "pos");
|
||||
lua_pushcfunction(L,cpp_mouse_wheel); lua_setfield(L, -2, "wheel");
|
||||
lua_pushcfunction(L,cpp_mouse_down); lua_setfield(L, -2, "down");
|
||||
lua_pushcfunction(L,cpp_mouse_press); lua_setfield(L, -2, "press");
|
||||
lua_setglobal(L, "mouse");
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_key_down); lua_setfield(L, -2, "keyDown");
|
||||
lua_pushcfunction(L,cpp_key_press); lua_setfield(L, -2, "keyPressed");
|
||||
lua_pushcfunction(L,cpp_key_any); lua_setfield(L, -2, "anyKeyPressed");
|
||||
lua_setglobal(L, "keyboard");
|
||||
lua_pushcfunction(L,cpp_key_down); lua_setfield(L, -2, "down");
|
||||
lua_pushcfunction(L,cpp_key_press); lua_setfield(L, -2, "press");
|
||||
lua_pushcfunction(L,cpp_key_any); lua_setfield(L, -2, "any");
|
||||
//lua_setglobal(L, "key");
|
||||
|
||||
lua_newtable(L);
|
||||
//lua_newtable(L);
|
||||
lua_pushinteger(L, 0); lua_setfield(L, -2, "UNKNOWN");
|
||||
lua_pushinteger(L, 4); lua_setfield(L, -2, "A");
|
||||
lua_pushinteger(L, 5); lua_setfield(L, -2, "B");
|
||||
@@ -1071,12 +1022,12 @@ void push_lua_funcs() {
|
||||
lua_setglobal(L, "key");
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_pad_down); lua_setfield(L, -2, "buttonDown");
|
||||
lua_pushcfunction(L,cpp_pad_press); lua_setfield(L, -2, "buttonPressed");
|
||||
lua_pushcfunction(L,cpp_pad_any); lua_setfield(L, -2, "anyButtonPressed");
|
||||
lua_setglobal(L, "gamepad");
|
||||
lua_pushcfunction(L,cpp_pad_down); lua_setfield(L, -2, "down");
|
||||
lua_pushcfunction(L,cpp_pad_press); lua_setfield(L, -2, "press");
|
||||
lua_pushcfunction(L,cpp_pad_any); lua_setfield(L, -2, "any");
|
||||
//lua_setglobal(L, "gamepad");
|
||||
|
||||
lua_newtable(L);
|
||||
//lua_newtable(L);
|
||||
lua_pushinteger(L, -1); lua_setfield(L, -2, "INVALID");
|
||||
lua_pushinteger(L, 0); lua_setfield(L, -2, "A");
|
||||
lua_pushinteger(L, 1); lua_setfield(L, -2, "B");
|
||||
@@ -1100,7 +1051,7 @@ void push_lua_funcs() {
|
||||
lua_pushinteger(L, 19); lua_setfield(L, -2, "PADDLE4");
|
||||
lua_pushinteger(L, 20); lua_setfield(L, -2, "TOUCHPAD");
|
||||
|
||||
lua_setglobal(L, "button");
|
||||
lua_setglobal(L, "pad");
|
||||
|
||||
}
|
||||
|
||||
|
||||
4
mini.cpp
4
mini.cpp
@@ -1271,6 +1271,10 @@ void setupdatemode(const int value, const int t) {
|
||||
timeout = t;
|
||||
}
|
||||
|
||||
int getupdatemode() {
|
||||
return update_mode;
|
||||
}
|
||||
|
||||
void exit() {
|
||||
should_exit = true;
|
||||
should_quit = true;
|
||||
|
||||
1
mini.h
1
mini.h
@@ -252,5 +252,6 @@ const char *configfolder();
|
||||
#define UPDATE_WAIT 1
|
||||
#define UPDATE_TIMEOUT 2
|
||||
void setupdatemode(const int value, const int t=0);
|
||||
int getupdatemode();
|
||||
|
||||
void exit();
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
surf.new
|
||||
surf.load
|
||||
surf.save
|
||||
surf.free
|
||||
surf.size
|
||||
surf.target
|
||||
surf.source
|
||||
surf.map
|
||||
|
||||
pal.load
|
||||
pal.set
|
||||
pal.color
|
||||
pal.trans
|
||||
|
||||
subpal.set
|
||||
subpal.reset
|
||||
|
||||
draw.pset
|
||||
draw.pget
|
||||
draw.cls
|
||||
draw.line
|
||||
draw.hline
|
||||
draw.vline
|
||||
draw.rect
|
||||
draw.rectf
|
||||
draw.circ
|
||||
draw.circf
|
||||
draw.oval
|
||||
draw.ovalf
|
||||
draw.color
|
||||
draw.pattern
|
||||
draw.surface
|
||||
draw.text
|
||||
draw.map
|
||||
|
||||
music.play
|
||||
music.pause
|
||||
music.resume
|
||||
music.stop
|
||||
music.pos
|
||||
|
||||
sound.load
|
||||
sound.free
|
||||
sound.play
|
||||
sound.stop
|
||||
|
||||
sys.time
|
||||
sys.beat
|
||||
sys.update
|
||||
sys.dir
|
||||
sys.quit
|
||||
|
||||
win.zoom
|
||||
win.fullscreen
|
||||
win.cursor
|
||||
win.res
|
||||
|
||||
config.key
|
||||
config.folder
|
||||
|
||||
mouse.pos
|
||||
mouse.wheel
|
||||
mouse.down
|
||||
mouse.press
|
||||
|
||||
key.down
|
||||
key.press
|
||||
key.any
|
||||
|
||||
pad.down
|
||||
pad.press
|
||||
pad.any
|
||||
Reference in New Issue
Block a user