summaryrefslogtreecommitdiff
path: root/src/cat
diff options
context:
space:
mode:
Diffstat (limited to 'src/cat')
-rw-r--r--src/cat/LegacyLuaAPI.cpp6
-rw-r--r--src/cat/LuaScriptHelper.h1
-rw-r--r--src/cat/LuaScriptInterface.cpp24
3 files changed, 23 insertions, 8 deletions
diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp
index 9a478e7..80a7f82 100644
--- a/src/cat/LegacyLuaAPI.cpp
+++ b/src/cat/LegacyLuaAPI.cpp
@@ -648,13 +648,17 @@ int luatpt_element_func(lua_State *l)
if(lua_isfunction(l, 1))
{
int element = luaL_optint(l, 2, 0);
+ int replace = luaL_optint(l, 3, 0);
int function;
lua_pushvalue(l, 1);
function = luaL_ref(l, LUA_REGISTRYINDEX);
if(element > 0 && element < PT_NUM)
{
lua_el_func[element] = function;
- luacon_sim->elements[element].Update = &luacon_elementReplacement;
+ if(replace)
+ lua_el_mode[element] = 2;
+ else
+ lua_el_mode[element] = 1;
return 0;
}
else
diff --git a/src/cat/LuaScriptHelper.h b/src/cat/LuaScriptHelper.h
index 37920b5..17678d5 100644
--- a/src/cat/LuaScriptHelper.h
+++ b/src/cat/LuaScriptHelper.h
@@ -35,7 +35,6 @@ int luacon_step(int mx, int my, int selectl, int selectr, int bsx, int bsy);
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_eval(char *command);
-int luacon_part_update(int t, int i, int x, int y, int surround_space, int nt);
char *luacon_geterror();
void luacon_close();
int luacon_partsread(lua_State* l);
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp
index 869d717..5954c4b 100644
--- a/src/cat/LuaScriptInterface.cpp
+++ b/src/cat/LuaScriptInterface.cpp
@@ -913,11 +913,12 @@ int LuaScriptInterface::elements_element(lua_State * l)
if(lua_type(l, -1) == LUA_TFUNCTION)
{
lua_el_func[id] = luaL_ref(l, LUA_REGISTRYINDEX);
- luacon_sim->elements[id].Update = &luacon_elementReplacement;
+ lua_el_mode[id] = 1;
}
else if(lua_type(l, -1) == LUA_TBOOLEAN && !lua_toboolean(l, -1))
{
lua_el_func[id] = 0;
+ lua_el_mode[id] = 0;
luacon_sim->elements[id].Update = NULL;
}
else
@@ -926,12 +927,12 @@ int LuaScriptInterface::elements_element(lua_State * l)
lua_getfield(l, -1, "Graphics");
if(lua_type(l, -1) == LUA_TFUNCTION)
{
- lua_el_func[id] = luaL_ref(l, LUA_REGISTRYINDEX);
+ lua_gr_func[id] = luaL_ref(l, LUA_REGISTRYINDEX);
luacon_sim->elements[id].Graphics = &luacon_graphicsReplacement;
}
else if(lua_type(l, -1) == LUA_TBOOLEAN && !lua_toboolean(l, -1))
{
- lua_el_func[id] = 0;
+ lua_gr_func[id] = 0;
luacon_sim->elements[id].Graphics = NULL;
}
else
@@ -1068,7 +1069,17 @@ int LuaScriptInterface::elements_property(lua_State * l)
{
lua_pushvalue(l, 3);
lua_el_func[id] = luaL_ref(l, LUA_REGISTRYINDEX);
- luacon_sim->elements[id].Update = &luacon_elementReplacement;
+ if (args > 3)
+ {
+ luaL_checktype(l, 4, LUA_TNUMBER);
+ int replace = lua_tointeger(l, 4);
+ if (replace == 1)
+ lua_el_mode[id] = 2;
+ else
+ lua_el_mode[id] = 1;
+ }
+ else
+ lua_el_mode[id] = 1;
}
else if(lua_type(l, 3) == LUA_TLIGHTUSERDATA)
{
@@ -1078,6 +1089,7 @@ int LuaScriptInterface::elements_property(lua_State * l)
else if(lua_type(l, 3) == LUA_TBOOLEAN && !lua_toboolean(l, 3))
{
lua_el_func[id] = 0;
+ lua_el_mode[id] = 0;
luacon_sim->elements[id].Update = NULL;
}
}
@@ -1086,12 +1098,12 @@ int LuaScriptInterface::elements_property(lua_State * l)
if(lua_type(l, 3) == LUA_TFUNCTION)
{
lua_pushvalue(l, 3);
- lua_el_func[id] = luaL_ref(l, LUA_REGISTRYINDEX);
+ lua_gr_func[id] = luaL_ref(l, LUA_REGISTRYINDEX);
luacon_sim->elements[id].Graphics = &luacon_graphicsReplacement;
}
else if(lua_type(l, 3) == LUA_TBOOLEAN && !lua_toboolean(l, -1))
{
- lua_el_func[id] = 0;
+ lua_gr_func[id] = 0;
luacon_sim->elements[id].Graphics = NULL;
}
std::fill(luacon_ren->graphicscache, luacon_ren->graphicscache+PT_NUM, gcache_item());