Exemplo n.º 1
0
static int PlayerCharacterL_SetLocation(lua_State* luaVM)
{
   int nargs = lua_gettop(luaVM);
   
   switch(nargs)
   {
      case 3:
      {
         PlayerCharacter* playerCharacter = luaW_check<PlayerCharacter>(luaVM, 1);
         if (playerCharacter)
         {
            int x = lua_tointeger(luaVM, 2);
            int y = lua_tointeger(luaVM, 3);
            playerCharacter->setLocation(shapes::Point2D(x, y));
         }
         break;
      }
   }
   return 0;
}
Exemplo n.º 2
0
static int PlayerCharacterL_SetLocation(lua_State* luaVM)
{
   PlayerCharacter* playerCharacter = luaW_check<PlayerCharacter>(luaVM, 1);
   if (playerCharacter == nullptr)
   {
      return lua_error(luaVM);
   }

   int x;
   if(!ScriptUtilities::getParameter(luaVM, 2, 1, "x", x))
   {
      return lua_error(luaVM);
   }

   int y;
   if(!ScriptUtilities::getParameter(luaVM, 2, 2, "y", y))
   {
      return lua_error(luaVM);
   }

   playerCharacter->setLocation({ x, y });

   return 0;
}