[40k/Src]item.get_attr function gesucht

08/25/2015 00:57 holosko74#1
hallo,

da ich vorher die vanilla game hatte und jzt 40k game source suche ich nach diesen function in der vanilla ist es die:

item.get_attr_type
item.get_attr_value

bei den 40k was brauch ich da und wo muss ich die neue einfügen?

danke im vorraus und nen schönen abend wünsche ich euch
08/25/2015 02:24 xXGaardenXx#2
Such in der questlua_item.cpp nach (Zeile 461 bei mir) :

PHP Code:
int item_copy_and_give_before_remove(lua_StateL)
    {
        
lua_pushboolean(L0);
        if (!
lua_isnumber(L1))
            return 
1;

        
DWORD vnum = (DWORD)lua_tonumber(L1);

        
CQuestManagerCQuestManager::instance();
        
LPITEM pItem q.GetCurrentItem();
        
LPCHARACTER pChar q.GetCurrentCharacterPtr();

        
LPITEM pkNewItem ITEM_MANAGER::instance().CreateItem(vnum10false);

        if (
pkNewItem)
        {
            
ITEM_MANAGER::CopyAllAttrTo(pItempkNewItem);
            
LogManager::instance().ItemLog(pCharpkNewItem"COPY SUCCESS"pkNewItem->GetName());

            
BYTE bCell pItem->GetCell();

            
ITEM_MANAGER::instance().RemoveItem(pItem"REMOVE (COPY SUCCESS)");

            
pkNewItem->AddToCharacter(pCharTItemPos(INVENTORYbCell)); 
            
ITEM_MANAGER::instance().FlushDelayedSave(pkNewItem);
            
pkNewItem->AttrLog();

            
// ¼º°ø!
            
lua_pushboolean(L1);            
        }

        return 
1;
    } 

Füg darunter Die beiden Funktionen ein :


PHP Code:
int item_get_attr_type(lua_StateL)
    {
        
CQuestManagerCQuestManager::instance();
        
LPITEM item q.GetCurrentItem();

        if (!
item)
        {
            
sys_err("cannot get current item");
            
lua_pushnumber(L0);
            return 
1;
        }

        if (
false == lua_isnumber(L1))
        {
            
sys_err("index is not a number");
            
lua_pushnumber(L0);
            return 
1;
        }

        
int index lua_tonumber(L1);
        const 
TPlayerItemAttributeattrItem item->GetAttribute(index);
        
        
lua_pushnumber(LattrItem.bType);

        return 
1;
    } 
PHP Code:
    int item_get_attr_value(lua_StateL)
    {
        
CQuestManagerCQuestManager::instance();
        
LPITEM item q.GetCurrentItem();

        if (!
item)
        {
            
sys_err("cannot get current item");
            
lua_pushnumber(L0);
            return 
1;
        }

        if (
false == lua_isnumber(L1))
        {
            
sys_err("index is not a number");
            
lua_pushnumber(L0);
            return 
1;
        }

        
int index lua_tonumber(L1);
        const 
TPlayerItemAttributeattrItem item->GetAttribute(index);
            
        
lua_pushnumber(LattrItem.sValue);

        return 
1;
    } 
& nun suchst du nach luaL_Reg item_functions[] = : und fügst Folgendes ein :

PHP Code:
"get_attr_type",        item_get_attr_type},
"get_attr_value",        item_get_attr_value}, 
08/25/2015 11:42 ProfessorEnte#3
du hast die item_get_attr_value vergessen, bzw hast die falsche reingestellt. :p
08/25/2015 14:40 holosko74#4
Quote:
Originally Posted by xXGaardenXx View Post
Such in der questlua_item.cpp nach (Zeile 461 bei mir) :

PHP Code:
int item_copy_and_give_before_remove(lua_StateL)
    {
        
lua_pushboolean(L0);
        if (!
lua_isnumber(L1))
            return 
1;

        
DWORD vnum = (DWORD)lua_tonumber(L1);

        
CQuestManagerCQuestManager::instance();
        
LPITEM pItem q.GetCurrentItem();
        
LPCHARACTER pChar q.GetCurrentCharacterPtr();

        
LPITEM pkNewItem ITEM_MANAGER::instance().CreateItem(vnum10false);

        if (
pkNewItem)
        {
            
ITEM_MANAGER::CopyAllAttrTo(pItempkNewItem);
            
LogManager::instance().ItemLog(pCharpkNewItem"COPY SUCCESS"pkNewItem->GetName());

            
BYTE bCell pItem->GetCell();

            
ITEM_MANAGER::instance().RemoveItem(pItem"REMOVE (COPY SUCCESS)");

            
pkNewItem->AddToCharacter(pCharTItemPos(INVENTORYbCell)); 
            
ITEM_MANAGER::instance().FlushDelayedSave(pkNewItem);
            
pkNewItem->AttrLog();

            
// ¼º°ø!
            
lua_pushboolean(L1);            
        }

        return 
1;
    } 

Füg darunter Die beiden Funktionen ein :


PHP Code:
int item_get_attr_type(lua_StateL)
    {
        
CQuestManagerCQuestManager::instance();
        
LPITEM item q.GetCurrentItem();

        if (!
item)
        {
            
sys_err("cannot get current item");
            
lua_pushnumber(L0);
            return 
1;
        }

        if (
false == lua_isnumber(L1))
        {
            
sys_err("index is not a number");
            
lua_pushnumber(L0);
            return 
1;
        }

        
int index lua_tonumber(L1);
        const 
TPlayerItemAttributeattrItem item->GetAttribute(index);
        
        
lua_pushnumber(LattrItem.bType);

        return 
1;
    } 
PHP Code:
int item_set_attr(lua_StateL)
    {
        
CQuestManagerCQuestManager::instance();
        
LPITEM item q.GetCurrentItem();

        if (!
item)
        {
            
sys_err("item_set_attr: cannot get current item");
            
lua_pushboolean(L0);
            return 
1;
        }

        if (
false == lua_isnumber(L1))
        {
            
sys_err("item_set_attr: first argument must be attr_id");
            
lua_pushboolean(L0);
            return 
1;
        }
        
int vnum lua_tonumber(L1);
        
        if (
false == lua_isnumber(L2))
        {
            
sys_err("item_set_attr: second argument must be attr_value");
            
lua_pushboolean(L0);
            return 
1;
        }
        
int value lua_tonumber(L2);
        
int pos 0;
        
        if (
true == lua_isnumber(L3))
        {
            
pos lua_tonumber(L3);
        }
        
        
item->SetAttribute(pos, (BYTE)vnum, (short)value);
        
        
lua_pushboolean(L1);
        return 
1;
        
    } 
& nun suchst du nach luaL_Reg item_functions[] = : und fügst Folgendes ein :

PHP Code:
"get_attr_type",        item_get_attr_type},
"get_attr_value",        item_get_attr_value}, 

Danke dir fehlt nur item.get_attr_value wie mein vor poster es gesagt hat
08/25/2015 16:25 xXGaardenXx#5
Quote:
Originally Posted by ProfessorEnte View Post
du hast die item_get_attr_value vergessen, bzw hast die falsche reingestellt. :p
Im ersten Beitrag nun auch die Richtige eingefügt

Hier nochmal die Richtige war gestern schon zu spät :D

PHP Code:
    int item_get_attr_value(lua_StateL)
    {
        
CQuestManagerCQuestManager::instance();
        
LPITEM item q.GetCurrentItem();

        if (!
item)
        {
            
sys_err("cannot get current item");
            
lua_pushnumber(L0);
            return 
1;
        }

        if (
false == lua_isnumber(L1))
        {
            
sys_err("index is not a number");
            
lua_pushnumber(L0);
            return 
1;
        }

        
int index lua_tonumber(L1);
        const 
TPlayerItemAttributeattrItem item->GetAttribute(index);
            
        
lua_pushnumber(LattrItem.sValue);

        return 
1;
    }