lots of random fixes to the legacy lua api

This commit is contained in:
jacob1 2014-03-04 20:44:25 -05:00
parent a5ea6555f1
commit 21854df9f3
3 changed files with 309 additions and 306 deletions

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ int luacon_step(int mx, int my, std::string , std::string selectr, std::string s
int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel); int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel);
int luacon_keyevent(int key, int modifier, int event); int luacon_keyevent(int key, int modifier, int event);
int luacon_eval(const char *command); int luacon_eval(const char *command);
char *luacon_geterror(); const char *luacon_geterror();
void luacon_close(); void luacon_close();
int luacon_partsread(lua_State* l); int luacon_partsread(lua_State* l);
int luacon_partswrite(lua_State* l); int luacon_partswrite(lua_State* l);
@ -35,9 +35,9 @@ int luacon_elementread(lua_State* l);
int luacon_elementwrite(lua_State* l); int luacon_elementwrite(lua_State* l);
int luacon_transitionread(lua_State* l); int luacon_transitionread(lua_State* l);
int luacon_transitionwrite(lua_State* l); int luacon_transitionwrite(lua_State* l);
int luacon_particle_getproperty(char * key, int * format); int luacon_particle_getproperty(const char * key, int * format);
int luacon_transition_getproperty(char * key, int * format); int luacon_transition_getproperty(const char * key, int * format);
int luacon_element_getproperty(char * key, int * format, unsigned int * modified_stuff); int luacon_element_getproperty(const char * key, int * format, unsigned int * modified_stuff);
//int process_command_lua(pixel *vid_buf, char *console, char *console_error); //int process_command_lua(pixel *vid_buf, char *console, char *console_error);
//Interface //Interface

View File

@ -1364,7 +1364,7 @@ int LuaScriptInterface::simulation_loadStamp(lua_State * l)
y = luaL_optint(l,3,0); y = luaL_optint(l,3,0);
if (lua_isstring(l, 1)) //Load from 10 char name, or full filename if (lua_isstring(l, 1)) //Load from 10 char name, or full filename
{ {
char * filename = (char*)luaL_optstring(l, 1, ""); const char * filename = luaL_optstring(l, 1, "");
tempfile = Client::Ref().GetStamp(filename); tempfile = Client::Ref().GetStamp(filename);
} }
if (!tempfile && lua_isnumber(l, 1)) //Load from stamp ID if (!tempfile && lua_isnumber(l, 1)) //Load from stamp ID
@ -1399,7 +1399,7 @@ int LuaScriptInterface::simulation_deleteStamp(lua_State * l)
if (lua_isstring(l, 1)) //note: lua_isstring returns true on numbers too if (lua_isstring(l, 1)) //note: lua_isstring returns true on numbers too
{ {
char * filename = (char*)luaL_optstring(l, 1, ""); const char * filename = luaL_optstring(l, 1, "");
for (std::vector<std::string>::const_iterator iterator = stamps.begin(), end = stamps.end(); iterator != end; ++iterator) for (std::vector<std::string>::const_iterator iterator = stamps.begin(), end = stamps.end(); iterator != end; ++iterator)
{ {
if (*iterator == filename) if (*iterator == filename)
@ -2391,9 +2391,8 @@ void LuaScriptInterface::initGraphicsAPI()
int LuaScriptInterface::graphics_textSize(lua_State * l) int LuaScriptInterface::graphics_textSize(lua_State * l)
{ {
char * text;
int width, height; int width, height;
text = (char*)luaL_optstring(l, 1, ""); const char* text = luaL_optstring(l, 1, "");
Graphics::textsize(text, width, height); Graphics::textsize(text, width, height);
lua_pushinteger(l, width); lua_pushinteger(l, width);
@ -2405,7 +2404,7 @@ int LuaScriptInterface::graphics_drawText(lua_State * l)
{ {
int x = lua_tointeger(l, 1); int x = lua_tointeger(l, 1);
int y = lua_tointeger(l, 2); int y = lua_tointeger(l, 2);
char * text = (char*)luaL_optstring(l, 3, ""); const char * text = luaL_optstring(l, 3, "");
int r = luaL_optint(l, 4, 255); int r = luaL_optint(l, 4, 255);
int g = luaL_optint(l, 5, 255); int g = luaL_optint(l, 5, 255);
int b = luaL_optint(l, 6, 255); int b = luaL_optint(l, 6, 255);
@ -2818,6 +2817,7 @@ bool LuaScriptInterface::OnMouseUp(int x, int y, unsigned button)
if (button == 3) if (button == 3)
button = 4; button = 4;
luacon_mousedown = false; luacon_mousedown = false;
luacon_mousebutton = 0;
return luacon_mouseevent(x, y, button, LUACON_MUP, 0); return luacon_mouseevent(x, y, button, LUACON_MUP, 0);
} }