|
Форум Обсуждение аддонов Разработка аддонов WoW как засовывать куски кодов в функции (не могу разобраться с тем что можно в php html но не в lua) |
как засовывать куски кодов в функции |
к примеру есть кусок кода аддона
Код function WARTCD() if(WAR==1)then TCD=TCD+1 TCDW=TCD end end function DPYTCD() if(DPY==1)then TCD=TCD+1 TCDD=TCD end end function JPETCD() if(JPE==1)then TCD=TCD+1 TCDJ=TCD end end function MAGTCD() if(MAG==1)then TCD=TCD+1 TCDM=TCD end end function OXOTCD() if(OXO==1)then TCD=TCD+1 TCDO=TCD end end function PALTCD() if(WAR==1)then TCD=TCD+1 TCDP=TCD end end function ROGTCD() if(ROG==1)then TCD=TCD+1 TCDR=TCD end end function LOKTCD() if(LOK==1)then TCD=TCD+1 TCDL=TCD end end function SHATCD() if(SHA==1)then TCD=TCD+1 TCDS=TCD end end function SBI() TCd=TCD local SBI = CreateFrame("Frame", nil, UIParent) SBI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCd) then do DEFAULT_CHAT_FRAME:AddMessage("|cff00FF00Инвайт проведён за |r"..TCD.."|cff00FF00 секунд!|r") GuildInviterButton1:Show() TCD=0 SBI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) end function GuildInviterButton1_OnClick() if(LVL1==1 and LVL2==0 and LVL3==0 and LVL4==0)then DEFAULT_CHAT_FRAME:AddMessage("|cff00FF00Идёт поиск и приглашение игроков...|r") GuildInviterButton1:Hide() WARTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDW) then do if(WAR==1)then KTO=L20 SendWho(KTO..CWAR) GIP() end SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) DPYTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDD) then do if(DPY==1)then KTO=L20 SendWho(KTO..CDPY) GIP() end SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) JPETCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDJ) then do if(JPE==1)then KTO=L20 SendWho(KTO..CJPE) GIP() end SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) MAGTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDM) then do if(MAG==1)then KTO=L20; SendWho(KTO..CMAG) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) OXOTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDO) then do if(OXO==1)then KTO=L20; SendWho(KTO..COXO) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) PALTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDP) then do if(PAL==1)then KTO=L20; SendWho(KTO..CPAL) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) ROGTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDR) then do if(ROG==1)then KTO=L20; SendWho(KTO..CROG) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) LOKTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDL) then do if(LOK==1)then KTO=L20; SendWho(KTO..CLOK) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) SHATCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDS) then do if(SHA==1)then KTO=L20; SendWho(KTO..CSHA) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) KTO=""; SBI() end; if(LVL1==1 and LVL2==1 and LVL3==0 and LVL4==0)then DEFAULT_CHAT_FRAME:AddMessage("|cff00FF00Идёт поиск и приглашение игроков...|r") GuildInviterButton1:Hide() WARTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDW) then do if(WAR==1)then KTO=L145; SendWho(KTO..CWAR) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) DPYTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDD) then do if(DPY==1)then KTO=L145; SendWho(KTO..CDPY) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) JPETCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDJ) then do if(JPE==1)then KTO=L145; SendWho(KTO..CJPE) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) MAGTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDM) then do if(MAG==1)then KTO=L145; SendWho(KTO..CMAG) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) OXOTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDO) then do if(OXO==1)then KTO=L145; SendWho(KTO..COXO) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) PALTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDP) then do if(PAL==1)then KTO=L145; SendWho(KTO..CPAL) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) ROGTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDR) then do if(ROG==1)then KTO=L145; SendWho(KTO..CROG) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) LOKTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDL) then do if(LOK==1)then KTO=L145; SendWho(KTO..CLOK) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) SHATCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDS) then do if(SHA==1)then KTO=L145; SendWho(KTO..CSHA) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) KTO=""; SBI() end; if(LVL1==1 and LVL2==1 and LVL3==1 and LVL4==0)then DEFAULT_CHAT_FRAME:AddMessage("|cff00FF00Идёт поиск и приглашение игроков...|r") GuildInviterButton1:Hide() WARTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDW) then do if(WAR==1)then KTO=L169; SendWho(KTO..CWAR) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) DPYTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDD) then do if(DPY==1)then KTO=L169; SendWho(KTO..CDPY) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) JPETCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDJ) then do if(JPE==1)then KTO=L169; SendWho(KTO..CJPE) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) MAGTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDM) then do if(MAG==1)then KTO=L169; SendWho(KTO..CMAG) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) OXOTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDO) then do if(OXO==1)then KTO=L169; SendWho(KTO..COXO) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) PALTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDP) then do if(PAL==1)then KTO=L169; SendWho(KTO..CPAL) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) ROGTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDR) then do if(ROG==1)then KTO=L169; SendWho(KTO..CROG) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) LOKTCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDL) then do if(LOK==1)then KTO=L169; SendWho(KTO..CLOK) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) SHATCD() local SGI = CreateFrame("Frame", nil, UIParent) SGI:SetScript('OnUpdate', function(self, elapsed) if(self.elapsed and self.elapsed > TCDS) then do if(SHA==1)then KTO=L169; SendWho(KTO..CSHA) GIP() end; SGI:Hide() end self.elapsed = 0 else self.elapsed = (self.elapsed or 0) + elapsed end end) KTO=""; SBI() end; как можно его сократить функциями если функции в lua не пашут если в примере Код функция(перем) GuildInviterCheckButton9:SetChecked(перем) в php, html можно пихать в функции на место переменных всё что угодно а в lua и ещё проблематичнее в c++ такое почемут не пашет( чё я ещё забываю делать чтоб функция работала с встроенными интерфейсными переменными?
Сообщение # 1 написано 29.07.2018 в 14:54
|
| |||
| |||