MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / Dist

Method Dist

LuaSTGPlus/LuaWrapper.cpp:655–675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

653 return 1;
654 }
655 static int Dist(lua_State* L)LNOEXCEPT
656 {
657 if (lua_gettop(L) == 2)
658 {
659 if (!lua_istable(L, 1) || !lua_istable(L, 2))
660 return luaL_error(L, "invalid lstg object for 'Dist'.");
661 lua_rawgeti(L, 1, 2); // t(object) t(object) id
662 lua_rawgeti(L, 2, 2); // t(object) t(object) id id
663 double tRet;
664 if (!LPOOL.Dist((size_t)luaL_checkint(L, -2), (size_t)luaL_checkint(L, -1), tRet))
665 return luaL_error(L, "invalid lstg object for 'Dist'.");
666 lua_pushnumber(L, tRet);
667 }
668 else
669 {
670 lua_Number dx = luaL_checknumber(L, 3) - luaL_checknumber(L, 1);
671 lua_Number dy = luaL_checknumber(L, 4) - luaL_checknumber(L, 2);
672 lua_pushnumber(L, sqrt(dx*dx + dy*dy));
673 }
674 return 1;
675 }
676 static int GetV(lua_State* L)LNOEXCEPT
677 {
678 if (!lua_istable(L, 1))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected