I was trying to get a new quest function that combines the "drop_item_with_ownership" from questlua_game.cpp with the "item_set_value" function from questlua_item.cpp. The file compiles just fine but when trying to call the new function from a *.quest file and compiling quests, the function is said to be not declared.
I did the following in questlua_game.cpp:
int game_drop_item_with_attr_own(lua_State* L)
{
LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
LPITEM item = NULL;
switch (lua_gettop(L))
{
case 1:
item = ITEM_MANAGER::instance().CreateItem((DWORD) lua_tonumber(L, 1));
break;
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
item = ITEM_MANAGER::instance().CreateItem((DWORD) lua_tonumber(L, 1), (int) lua_tonumber(L, 2));
break;
default:
return 0;
}
if (item == NULL)
{
return 0;
}
if (lua_isnumber(L, 3))
{
int sec = (int) lua_tonumber(L, 3);
if (sec <= 0)
{
item->SetOwnership(ch);
}
else
{
item->SetOwnership(ch, sec);
}
}
else
{
item->SetOwnership(ch);
}
// Set attributes if provided
for (int i = 4; i <= lua_gettop(L); i += 3)
{
if (lua_isnumber(L, i) && lua_isnumber(L, i + 1) && lua_isnumber(L, i + 2))
{
int index = (int) lua_tonumber(L, i);
int apply_type = (int) lua_tonumber(L, i + 1);
int apply_value = (int) lua_tonumber(L, i + 2);
item->SetForceAttribute(index, apply_type, apply_value);
}
}
PIXEL_POSITION pos;
pos.x = ch->GetX() + number(-200, 200);
pos.y = ch->GetY() + number(-200, 200);
item->AddToGround(ch->GetMapIndex(), pos);
item->StartDestroyEvent();
return 0;
}
int game_web_mall(lua_State* L)
{
LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
if ( ch != NULL )
{
do_in_game_mall(ch, const_cast<char*>(""), 0, 0);
}
return 0;
}
void RegisterGameFunctionTable()
{
luaL_reg game_functions[] =
{
{ "get_safebox_level", game_get_safebox_level },
{ "request_make_guild", game_request_make_guild },
{ "set_safebox_level", game_set_safebox_level },
{ "open_safebox", game_open_safebox },
{ "open_mall", game_open_mall },
{ "get_event_flag", game_get_event_flag },
{ "set_event_flag", game_set_event_flag },
{ "drop_item", game_drop_item },
{ "drop_item_with_ownership", game_drop_item_with_ownership },
{ "drop_item_with_attr_own", game_drop_item_with_attr_own },
{ "open_web_mall", game_web_mall },
{ NULL, NULL }
};
CQuestManager::instance().AddLuaFunctionTable("game", game_functions);
}
}
and added the function into the quest_functions file. But no matter what I do, the functions are not recognized. Even when chaning the name of existing functions, the new names are not availble, but the old names. Could anyone tell me, what I am doing wrong?
Best regards