• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ returning a table?

darkbraver

New Member
Joined
Aug 23, 2007
Messages
6
Reaction score
0
Hello

I have wroted this script:

Code:
int ActionScript::luaActionCheckItemsFromBox(lua_State *L)
{
    PositionEx pos;
	internalGetPositionEx(L,pos);

	ActionScript *action = getActionScript(L);

	Tile *tile = action->game->map->getTile(pos);
	if(tile) // sprwadzamy czy jest tile, dla bezpieczenstwa
	{
             
        Item *item = tile->getTopDownItem(); // deklarujemy item jako ten lezacy na tile na samym dole
        if(item && item->isContainer()) // czy on jest kontenerem?
        {
                
            Container *box = dynamic_cast<Container*>(item); // deklaracja kontenera jako obiektu w klasie
            if(box) // czy jest, bezpieczenstwo
            {
                lua_newtable(L); // tworzymy tabele
                for(int i = 0; i <= box->lcontained.size(); i++) // dla i numer slotu
                {  
                    Item* karta = box->getItem(i); // deklaracja itemu w slocie i
                    if(karta) // sprawdzamy id karty w slocie i
                    {
                        std::cout << "KARTA ID: "<< karta->getID() <<"." << std::endl;
                        std::cout << "I: "<< i <<"." << std::endl;
                        setField(L,"slot", i); // pierwszy field
                        setField(L, "itemid", karta->getID()); // drugi
                    }
                }
            }
        }
	}
	return 1;
}

I want to receive a lua table containing slot number and itemid. Whole script is working, but it returns empty table.
Any suggestions?
 
Back
Top