Hello! Today I found that in lua the modification of item.set_socket(0, value) does not work.
Fixed:
int item_set_socket(lua_State* L)
{
CQuestManager& q = CQuestManager::instance();
if (q.GetCurrentItem() && lua_isnumber(L, 1) && lua_isnumber(L, 2))
{
int idx = (int)lua_tonumber(L, 1);
int value = (int)lua_tonumber(L, 2);
if (idx >= 0 && idx < ITEM_SOCKET_MAX_NUM)
q.GetCurrentItem()->SetSocket(idx, value);
}
return 0;
}
Original:
int item_set_socket(lua_State* L)
{
CQuestManager& q = CQuestManager::instance();
if (&q == NULL)
return 0;
LPITEM item = q.GetCurrentItem();
if (item == NULL)
return 0;
if (item && lua_isnumber(L, 1) && lua_isnumber(L, 2))
{
int idx = (int) lua_tonumber(L, 1);
int value = (int) lua_tonumber(L, 2);
if (idx == NULL)
return 0;
if (value == NULL)
return 0;
if (idx >=0 && idx < ITEM_SOCKET_MAX_NUM)
item->SetSocket(idx, value);
}
return 0;
}
Explanation:
If the socket index is 0, it returns and does not run the code... fck logic.
if (idx == NULL)
return 0;