[NEW] extended palette functions
[DEL] old palette functions [MODIF] mouse function names [MODIF] map function params now are ints [NEW] ascii function [NEW] strlen function
This commit is contained in:
77
lua.cpp
77
lua.cpp
@@ -52,7 +52,32 @@ extern "C" {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_pal(lua_State *L) {
|
||||
static int cpp_loadpal(lua_State *L) {
|
||||
const char* str = luaL_checkstring(L, 1);
|
||||
loadpal(str);
|
||||
return 0;
|
||||
}
|
||||
static int cpp_setpal(lua_State *L) {
|
||||
uint8_t index = luaL_checkinteger(L, 1);
|
||||
uint8_t color = luaL_checkinteger(L, 2);
|
||||
setpal(index, color);
|
||||
return 0;
|
||||
}
|
||||
static int cpp_getpal(lua_State *L) {
|
||||
uint8_t index = luaL_checkinteger(L, 1);
|
||||
lua_pushinteger(L, getpal(index));
|
||||
return 1;
|
||||
}
|
||||
static int cpp_settrans(lua_State *L) {
|
||||
uint8_t index = luaL_checkinteger(L, 1);
|
||||
settrans(index);
|
||||
return 0;
|
||||
}
|
||||
static int cpp_gettrans(lua_State *L) {
|
||||
lua_pushinteger(L, gettrans());
|
||||
return 1;
|
||||
}
|
||||
/* static int cpp_pal(lua_State *L) {
|
||||
int numargs = lua_gettop(L);
|
||||
switch (numargs) {
|
||||
case 0: pal(); return 0;
|
||||
@@ -75,7 +100,7 @@ extern "C" {
|
||||
bool t = lua_toboolean(L, 2);
|
||||
palt(col, t);
|
||||
return 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
static int cpp_pset(lua_State *L) {
|
||||
int x = luaL_checknumber(L, 1);
|
||||
@@ -376,24 +401,24 @@ extern "C" {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cpp_mouseX(lua_State *L) {
|
||||
lua_pushinteger(L, mouseX());
|
||||
static int cpp_mousex(lua_State *L) {
|
||||
lua_pushinteger(L, mousex());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cpp_mouseY(lua_State *L) {
|
||||
lua_pushinteger(L, mouseY());
|
||||
static int cpp_mousey(lua_State *L) {
|
||||
lua_pushinteger(L, mousey());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cpp_mouseWheel(lua_State *L) {
|
||||
lua_pushinteger(L, mouseWheel());
|
||||
static int cpp_mwheel(lua_State *L) {
|
||||
lua_pushinteger(L, mwheel());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cpp_mouseButton(lua_State *L) {
|
||||
static int cpp_mbtn(lua_State *L) {
|
||||
uint8_t i = luaL_checkinteger(L, 1);
|
||||
lua_pushboolean(L, mouseButton(i));
|
||||
lua_pushboolean(L, mbtn(i));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -477,6 +502,17 @@ extern "C" {
|
||||
lua_pushstring(L, tostr(val));
|
||||
return 1;
|
||||
}
|
||||
static int cpp_ascii(lua_State *L) {
|
||||
const char* str = luaL_checkstring(L, 1);
|
||||
int index = luaL_checkinteger(L, 2);
|
||||
lua_pushinteger(L, ascii(str, index));
|
||||
return 1;
|
||||
}
|
||||
static int cpp_strlen(lua_State *L) {
|
||||
const char* str = luaL_checkstring(L, 1);
|
||||
lua_pushinteger(L, strlen(str));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
lua_State *L;
|
||||
@@ -507,8 +543,15 @@ void lua_init() {
|
||||
|
||||
lua_pushcfunction(L,cpp_cls); lua_setglobal(L, "cls");
|
||||
lua_pushcfunction(L,cpp_color); lua_setglobal(L, "color");
|
||||
lua_pushcfunction(L,cpp_pal); lua_setglobal(L, "pal");
|
||||
lua_pushcfunction(L,cpp_palt); lua_setglobal(L, "palt");
|
||||
|
||||
lua_pushcfunction(L,cpp_loadpal); lua_setglobal(L, "loadpal");
|
||||
lua_pushcfunction(L,cpp_setpal); lua_setglobal(L, "setpal");
|
||||
lua_pushcfunction(L,cpp_getpal); lua_setglobal(L, "getpal");
|
||||
lua_pushcfunction(L,cpp_settrans); lua_setglobal(L, "settrans");
|
||||
lua_pushcfunction(L,cpp_gettrans); lua_setglobal(L, "gettrans");
|
||||
|
||||
/*lua_pushcfunction(L,cpp_pal); lua_setglobal(L, "pal");
|
||||
lua_pushcfunction(L,cpp_palt); lua_setglobal(L, "palt");*/
|
||||
lua_pushcfunction(L,cpp_pset); lua_setglobal(L, "pset");
|
||||
lua_pushcfunction(L,cpp_pget); lua_setglobal(L, "pget");
|
||||
lua_pushcfunction(L,cpp_line); lua_setglobal(L, "line");
|
||||
@@ -536,10 +579,10 @@ void lua_init() {
|
||||
lua_pushcfunction(L,cpp_map); lua_setglobal(L, "map");
|
||||
lua_pushcfunction(L,cpp_btn); lua_setglobal(L, "btn");
|
||||
lua_pushcfunction(L,cpp_btnp); lua_setglobal(L, "btnp");
|
||||
lua_pushcfunction(L,cpp_mouseX); lua_setglobal(L, "mouseX");
|
||||
lua_pushcfunction(L,cpp_mouseY); lua_setglobal(L, "mouseY");
|
||||
lua_pushcfunction(L,cpp_mouseWheel); lua_setglobal(L, "mouseWheel");
|
||||
lua_pushcfunction(L,cpp_mouseButton); lua_setglobal(L, "mouseButton");
|
||||
lua_pushcfunction(L,cpp_mousex); lua_setglobal(L, "mousex");
|
||||
lua_pushcfunction(L,cpp_mousey); lua_setglobal(L, "mousey");
|
||||
lua_pushcfunction(L,cpp_mwheel); lua_setglobal(L, "mwheel");
|
||||
lua_pushcfunction(L,cpp_mbtn); lua_setglobal(L, "mbtn");
|
||||
|
||||
lua_pushcfunction(L,cpp_time); lua_setglobal(L, "time");
|
||||
lua_pushcfunction(L,cpp_abs); lua_setglobal(L, "abs");
|
||||
@@ -556,6 +599,8 @@ void lua_init() {
|
||||
lua_pushcfunction(L,cpp_rnd); lua_setglobal(L, "rnd");
|
||||
lua_pushcfunction(L,cpp_srand); lua_setglobal(L, "srand");
|
||||
lua_pushcfunction(L,cpp_tostr); lua_setglobal(L, "tostr");
|
||||
lua_pushcfunction(L,cpp_ascii); lua_setglobal(L, "ascii");
|
||||
lua_pushcfunction(L,cpp_strlen); lua_setglobal(L, "strlen");
|
||||
|
||||
lua_pushinteger(L, 0); lua_setglobal(L, "KEY_UNKNOWN");
|
||||
lua_pushinteger(L, 4); lua_setglobal(L, "KEY_A");
|
||||
|
||||
Reference in New Issue
Block a user