MCPcopy Create free account
hub / github.com/MonaSolutions/MonaServer / IndexCollection

Method IndexCollection

MonaServer/sources/Script.cpp:303–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301
302
303int Script::IndexCollection(lua_State* pState) {
304 // 1 table
305 // 2 key
306
307 if (lua_getmetatable(pState, 1)) {
308
309 lua_getfield(pState, -1, "|items");
310 // |items
311
312 lua_pushvalue(pState, 2); // key
313 lua_gettable(pState, -2);
314 // result!
315
316 if (lua_isnil(pState, -1)) { // if no result
317 // check sub key
318 lua_pushvalue(pState, 2); // key
319 lua_gettable(pState, -4); // table
320 lua_replace(pState, -2);
321 }
322
323 lua_replace(pState, -2);
324 lua_replace(pState, -2);
325 } else
326 lua_pushnil(pState);
327
328
329 if (lua_isnil(pState, -1)) {
330 const char* name = lua_tostring(pState,2);
331 if (name && strcmp(name, "count") == 0) {
332 lua_pushnumber(pState, lua_objlen(pState, 1));
333 lua_replace(pState, -2);
334 }
335 }
336
337 return 1;
338}
339
340int Script::LenCollection(lua_State* pState) {
341 // 1 table

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected