| 263 | |
| 264 | |
| 265 | void Script::ClearCollectionParameters(lua_State* pState, const char* field,const Parameters& parameters) { |
| 266 | // index -1 must be the collection |
| 267 | if (!lua_getmetatable(pState, -1)) |
| 268 | return; |
| 269 | string buffer; |
| 270 | |
| 271 | lua_getfield(pState, -1, String::Format(buffer,"|",field,"OnChange").c_str()); |
| 272 | Parameters::OnChange::Type* pOnChange((Parameters::OnChange::Type*)lua_touserdata(pState, -1)); |
| 273 | lua_pop(pState, 1); |
| 274 | lua_pushnil(pState); |
| 275 | lua_setfield(pState, -2, buffer.c_str()); |
| 276 | |
| 277 | lua_getfield(pState, -1, String::Format(buffer,"|",field,"OnClear").c_str()); |
| 278 | Parameters::OnClear::Type* pOnClear((Parameters::OnClear::Type*)lua_touserdata(pState, -1)); |
| 279 | lua_pop(pState, 1); |
| 280 | lua_pushnil(pState); |
| 281 | lua_setfield(pState, -2, buffer.c_str()); |
| 282 | |
| 283 | lua_pop(pState, 1); // metatable |
| 284 | |
| 285 | if (pOnChange) { |
| 286 | parameters.OnChange::unsubscribe(*pOnChange); |
| 287 | delete pOnChange; |
| 288 | } |
| 289 | if (pOnClear) { |
| 290 | parameters.OnClear::unsubscribe(*pOnClear); |
| 291 | delete pOnClear; |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | int Script::Item(lua_State *pState) { |
| 296 | SCRIPT_BEGIN(pState) |