summaryrefslogtreecommitdiff
path: root/src/cat/LuaScriptInterface.cpp
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-01-06 17:25:13 (GMT)
committer jacob1 <jfu614@gmail.com>2013-01-06 17:25:13 (GMT)
commit8e09651990d45d8b25b8795cbd1cfffeecfd3f5f (patch)
tree97bb518a834b3b78e2b995a04eccee6c9fe98f37 /src/cat/LuaScriptInterface.cpp
parent15040b32b0a829a020118561d5da9d01eb1484ab (diff)
downloadpowder-8e09651990d45d8b25b8795cbd1cfffeecfd3f5f.zip
powder-8e09651990d45d8b25b8795cbd1cfffeecfd3f5f.tar.gz
fix element function replacement option
Diffstat (limited to 'src/cat/LuaScriptInterface.cpp')
-rw-r--r--src/cat/LuaScriptInterface.cpp24
1 files changed, 18 insertions, 6 deletions
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());