View Single Post
01/08/16, 12:44 PM   #9
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by dominoid View Post
Ok so changing QuestMaker:GetJournalQuestInfo to QuestMaker.GetJournalQuestInfo worked? What's the difference and why did it work for MailR and not mine?

Sorry for all the noob stuff. I swear I know what I'm outside of here. My problem is my base knowledge is VB.net syntax. If I really new C# or C++, the LUA syntax would look better to me (I think). That and I'm self taught.
The colon is syntax sugar.
function A:f(b,c,d) is equal to function f(self,b,c,d)
In both case is self the instance the method is called for.
So, if you save a reference of a function declared like A:f(b) it must be handled as f(self, b):
Lua Code:
  1. local GetJournalQuestInfo_Orig = QuestMaker.GetJournalQuestInfo
  2. function QuestMaker:GetJournalQuestInfo(questIndex)
  3. -- Implicit created variable self, because of the colon syntax.
  4. GetJournalQuestInfo_Orig(self, questIndex)
  5. end
Which is the same as:
Lua Code:
  1. local GetJournalQuestInfo_Orig = QuestMaker.GetJournalQuestInfo
  2. function QuestMaker.GetJournalQuestInfo(self, questIndex)
  3. GetJournalQuestInfo_Orig(self, questIndex)
  4. end
Which is the same as:
Lua Code:
  1. local GetJournalQuestInfo_Orig = QuestMaker.GetJournalQuestInfo
  2. QuestMaker.GetJournalQuestInfo = function(self, questIndex)
  3. GetJournalQuestInfo_Orig(self, questIndex)
  4. end
  Reply With Quote