对于Opendoor的再修改
今日玩法师,想起了Opendoor这个小插件,可惜由于系统变化,无法使用,尝试修改了许久,终无法解决。还请论坛高手帮忙修改。 只用在所有的 for i in xxx doxxx前后加上pairs( )成为
for i in pairs(xxx) do
这样的形式
把string.find换成string.gmatch
应该就可以了
现在不能试,就看了下代码..
你可以把界面设置的 显示lua错误打开
有问题的话 知道是那里的错 Od_ButtonsText = {
};
Od_ButtonIcon= {
};
Od_CanSpell = {
0,0,0,0,0,0
};
Od_Button_Alliance_Icon = {
"Interface\\Icons\\Spell_Arcane_TeleportIronForge",
"Interface\\Icons\\Spell_Arcane_TeleportStormWind",
"Interface\\Icons\\Spell_Arcane_TeleportDarnassus",
"Interface\\Icons\\Spell_Arcane_PortalIronForge",
"Interface\\Icons\\Spell_Arcane_PortalStormWind",
"Interface\\Icons\\Spell_Arcane_PortalDarnassus"
};
Od_Button_Horde_Icon = {
"Interface\\Icons\\Spell_Arcane_TeleportOrgrimmar",
"Interface\\Icons\\Spell_Arcane_TeleportUnderCity",
"Interface\\Icons\\Spell_Arcane_TeleportThunderBluff",
"Interface\\Icons\\Spell_Arcane_PortalOrgrimmar",
"Interface\\Icons\\Spell_Arcane_PortalUnderCity",
"Interface\\Icons\\Spell_Arcane_PortalThunderBluff"
};
function Od_Main_Init()
Od_MapButton:Show();
if UnitFactionGroup("player") == "Alliance" then
for i in pairs(Od_SPELL_Alliance) do
Od_ButtonsText[i] = Od_SPELL_Alliance[i];
Od_ButtonIcon[i] = Od_Button_Alliance_Icon[i];
end
else
for i in pairs(Od_SPELL_Horde) do
Od_ButtonsText[i] = Od_SPELL_Horde[i];
Od_ButtonIcon[i] = Od_Button_Horde_Icon[i];
end
end
end
function Od_onEvent()
if (event == "PLAYER_ENTERING_WORLD") then
if (UnitClass("player") ~= PlayClass) then
return false
end
Od_Main_Init();
for id = 1, 180 do
local spellName, subSpellName = GetSpellName(id, "spell");
if (spellName) then
if (string.gmatch(spellName, Od_ButtonsText[1], 1, true)) then
Od_CanSpell[1] = id;
end
if (string.gmatch(spellName, Od_ButtonsText[2], 1, true)) then
Od_CanSpell[2] = id;
end
if (string.gmatch(spellName, Od_ButtonsText[3], 1, true)) then
Od_CanSpell[3] = id;
end
if (string.gmatch(spellName, Od_ButtonsText[4], 1, true)) then
Od_CanSpell[4] = id;
end
if (string.gmatch(spellName, Od_ButtonsText[5], 1, true)) then
Od_CanSpell[5] = id;
end
if (string.gmatch(spellName, Od_ButtonsText[6], 1, true)) then
Od_CanSpell[6] = id;
end
end
end
end
end
function Od_MapButton_Click()
local button = arg1;
if (button == "RightButton") then
showOrhideSlider();
elseif (button =="LeftButton") then
showOrhideMainFrame();
end
Od_Tooltip:Hide();
end
function Od_MapButton_UpdatePosition()
Od_MapButton:SetPoint(
"TOP",
"Minimap",
"TOP",
0 - (78 * cos(Od_MapButton.AtlasButtonPosition)),
(78 * sin(Od_MapButton.AtlasButtonPosition)) - 55
);
end
function showOrhideMainFrame()
Od_MapButtonPos:Hide();
if (Od_MainFrame:IsShown()) then
Od_MainFrame:Hide();
else
Od_MainFrame:Show();
end
for i in pairs(Od_CanSpell) do
local button = getglobal("Od_Button"..i);
local icon = getglobal("Od_Button"..i.."Icon");
if (Od_CanSpell[i] == 0) then
button:Disable();
icon:SetVertexColor(0.4, 0.4, 0.4);
else
button:Enable();
icon:SetVertexColor(1.0, 1.0, 1.0);
end
end
end
function showOrhideSlider()
Od_MainFrame:Hide();
if (Od_MapButtonPos:IsShown()) then
Od_MapButtonPos:Hide();
else
Od_MapButtonPos:Show();
end
end
function Od_Buttons_SetTooltip(text1,text2)
Od_Tooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT");
Od_Tooltip:SetText(text1,1.00, 0.95, 0.95);
Od_Tooltip:AddLine(text2, 0.26, 0.86, 0.26);
Od_Tooltip:Show();
end
function Od_Buttons_Init()
local id = tonumber(string.sub(this:GetID(),-1,-1));
local icon = getglobal(this:GetName().."Icon");
if ( id>0 ) then
icon:SetTexture(Od_ButtonIcon[id]);
end
end
function Od_Buttons_OnClick()
local id = tonumber(string.sub(this:GetID(),-1,-1));
CastSpell(Od_CanSpell[id], "spell");
Od_MainFrame:Hide();
end
这是改好后的代码,现在插件载入没有问题,在点击图标时出现提示如下图:
[/i][/i][/i][/i][/i][/i][/i][/i][/i] CastSpell(Od_CanSpell[id], "spell");
这里出的问题,直接施法的API全部被列为被保护的API了,无法直接调用的。
修改方法:
把 Od_Buttons 改为 SecureActionButton
把 Od_Buttons 的 type1 属性设为 spell
把 Od_Buttons 的 spell1 属性设为 Od_ButtonsText[id]
PS:建议对数据结构进行调整。
参见 [url]http://wiki.cwowaddon.com/Secure_Frames_Overview[/url] 尝试修改为:
function Od_Buttons_OnClick()
local id = tonumber(string.sub(this:GetID(),-1,-1));
Od_Buttons:SetAttribute("type1", "spell")
Od_Buttons:SetAttribute("spell1", "Od_ButtonsText[id]")
--CastSpell(Od_CanSpell[id], "spell");
Od_MainFrame:Hide();
end
仍失败。 有人能帮忙写出来吧,参考了半天TrackBar的代码,还是写不出 要修改相应的按钮为SecureActionButton才行啊,光改属性是不行的 楼上的朋友,你能帮帮忙改下么?
我也改了很久,改不出来
对代码不熟悉啊~~~
页:
[1]