static int KeyValues_GetColor (lua_State *L) {
  switch(lua_type(L, 2)) {
	case LUA_TNUMBER:
	  lua_pushcolor(L, luaL_checkkeyvalues(L, 1)->GetColor(luaL_checkint(L, 2)));
	  break;
	case LUA_TNONE:
	case LUA_TSTRING:
	default:
	  lua_pushcolor(L, luaL_checkkeyvalues(L, 1)->GetColor(luaL_optstring(L, 2, 0)));
	  break;
  }
  return 1;
}
Esempio n. 2
0
int luaNode__index( lua_State* l ) {
    is::Node* node = lua_tonode(l,1);
    if ( node == NULL ) {
        lua_Debug ar1;
        lua_getstack( l, 1, &ar1 );
        lua_getinfo( l, "fl", &ar1 );
        lua_Debug ar2;
        lua_getinfo( l, ">S", &ar2 );
        lua_pushfstring( l, "%s:%d: attempt to index a NULL Node!", ar2.short_src, ar1.currentline );
        return lua_error( l );
    }
    std::string field = luaL_checkstring(l,2);
    if ( field == "pos" ) {
        lua_pushvector( l, node->getPos() );
        return 1;
    } else if ( field == "ang" ) {
        lua_pushvector( l, node->getAng() );
        return 1;
    } else if ( field == "scale" ) {
        lua_pushvector( l, node->getScale() );
        return 1;
    } else if ( field == "color" ) {
        lua_pushcolor( l, node->getColor() );
        return 1;
    } else if ( field == "x" ) {
        lua_pushnumber( l, node->getPos().x );
        return 1;
    } else if ( field == "y" ) {
        lua_pushnumber( l, node->getPos().y );
        return 1;
    } else if ( field == "z" ) {
        lua_pushnumber( l, node->getPos().z );
        return 1;
    } else if ( field == "sx" ) {
        lua_pushnumber( l, node->getScale().x );
        return 1;
    } else if ( field == "sy" ) {
        lua_pushnumber( l, node->getScale().y );
        return 1;
    } else if ( field == "sz" ) {
        lua_pushnumber( l, node->getScale().z );
        return 1;
    } else if ( field == "r" ) {
        lua_pushnumber( l, node->getColor().x );
        return 1;
    } else if ( field == "g" ) {
        lua_pushnumber( l, node->getColor().y );
        return 1;
    } else if ( field == "b" ) {
        lua_pushnumber( l, node->getColor().z );
        return 1;
    } else if ( field == "a" ) {
        lua_pushnumber( l, node->getColor().w );
        return 1;
    }
    if ( luaText__index( l ) ) {
        return 1;
    }
    if ( luaButton__index( l ) ) {
        return 1;
    }
    if ( luaCheckbox__index( l ) ) {
        return 1;
    }
    if ( luaDropdown__index( l ) ) {
        return 1;
    }
    lua_getmetatable( l, 1 );
    lua_pushvalue( l, 2 );
    lua_gettable( l, -2 );
    if ( lua_isnil( l, -1 ) ) {
        lua_pop( l, 1 );
        lua_rawgeti( l, LUA_REGISTRYINDEX, node->m_luaReference );
        lua_pushvalue( l, 2 );
        lua_gettable( l, -2 );
    }
    return 1;
}
Esempio n. 3
0
static int luasrc_Color (lua_State *L) {
  lua_pushcolor(L, Color(luaL_checkint(L, 1), luaL_checkint(L, 2), luaL_checkint(L, 3), luaL_optint(L, 4, 255)));
  return 1;
}