useItem()函數的BUG
使用useItem()函數時,例子:if BeeUnitHealth("player","%")<50 then
useItem(5512);
return;
end
“5512”為治療石的ID。由於useItem()函數沒有返回值,當物品為空或沒有時,會卡技能。
建議代碼如下修改:
function useItem(itemID)
if GetItemCount(itemID,false,false) > 0 then
if select(2,GetItemCooldown(itemID))==0 then
RunMacroText("/use "..tostring(select(1,GetItemInfo(itemId))));
return true;
end
end
return false;
end
代碼修改后,使用例子如下:
if BeeUnitHealth("player","%")<50 then
if useItem(5512) then
return;
end
end
修改后可正常施放技能。
{:5_236:} 哇~~~~~{:5_124:} 非常认真,但是不能那样改,会影响到其他函数的参数格式,GH尽量不使用RunMacroText。
页:
[1]