Ignore:
Timestamp:
08/19/13 06:37:47 (12 years ago)
Author:
epyon
Message:
  • lua - major refactoring of the lua state/table
  • lua - added state_wrapper common to state/table
  • lua_values - fixed returning of simple types
  • lua_area - fixed area.coords and area.edges
  • lua_map_area - "fixed" case when object is used as base
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lua/lua_map_area.cc

    r198 r206  
    99#include "nv/lua/lua_area.hh"
    1010#include "nv/lua/lua_glm.hh"
     11#include "nv/lua/lua_values.hh"
    1112#include "nv/lua/lua_raw.hh"
    1213
     
    5354nv::map_area* nlua_to_map_area( lua_State* L, int index )
    5455{
    55         return *(nv::map_area**)luaL_checkudata( L, index, NLUA_MAP_AREA_METATABLE );
     56        if ( lua_type( L, index ) == LUA_TTABLE )
     57        {
     58                nv::map_area* o = nullptr;
     59                if ( lua_istable( L , index ) )
     60                {
     61                        lua_pushstring( L, "__map_area_ptr" );
     62                        lua_rawget( L, index );
     63                        if ( lua_isuserdata( L, -1 ) )
     64                        {
     65                                o = static_cast<nv::map_area*>( lua_touserdata( L, -1 ) );
     66                        }
     67                        lua_pop( L, 1 );
     68                }
     69                return o;
     70        }
     71        else
     72        {
     73                return *(nv::map_area**)luaL_checkudata( L, index, NLUA_MAP_AREA_METATABLE );
     74        }
    5675}
    5776
     
    83102{
    84103        nv::map_area* ma = nlua_to_map_area( L, 1 );
    85         nlua_push_area( L, ma->get_rectangle() );
     104        nv::rectangle r  = ma->get_rectangle();
     105        r.lr.x -= 1;
     106        r.lr.y -= 1;
     107        nlua_push_area( L, r );
    86108        return 1;
    87109}
Note: See TracChangeset for help on using the changeset viewer.