View Single Post
01/09/16, 07:19 PM   #11
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
I may not be 100% accurate on how I try to explain, but this should at least give you an idea of what the problem is.

As Votan said when you do this:
Lua Code:
  1. function QuestMaker:SomeFunction(questIndex)

It is expecting a QuestMaker object to be used to call the function, something like
Lua Code:
  1. QuestMaker:GetJournalQuestInfo(questIndex)
It is expecting two parameters: self and questIndex.
Where QuestMaker (the object before the : colon) becomes the first parameter called self. So even though you did not write (self, questIndex) as your parameters that is what happens. The QuestMaker object automatically becomes the first parameter called self.

Since GetJournalQuestInfo (the original function) does not belong to the QuestMaker object. Meaning it (the original function) is not defined as:
Lua Code:
  1. function QuestMaker:GetJournalQuestInfo(questIndex)

It is defined as:
Lua Code:
  1. function GetJournalQuestInfo(questIndex)
So it is called without a colon & no object before it. So its only expecting a single parameter: questIndex.

But since you assigned the original function to reference
Lua Code:
  1. QuestMaker:GetJournalQuestInfo(questIndex)
Now when we call the original function it is now expecting two parameters: self (a QuestMaker object) & questIndex, but we don't call the function in that way. We only call it as
Lua Code:
  1. GetJournalQuestInfo(questIndex)

Which causes the problem. When you call GetJournalQuestInfo(questIndex), remember since you redirected it to QuestMaker:GetJournalQuestInfo it is expecting two parameters (self, questIndex), so questIndex is the first parameter and it is becoming self and there is no other parameter so questIndex is nil.


You should make it something like
Lua Code:
  1. local GetJournalQuestInfo_Orig = GetJournalQuestInfo
  2.  
  3. function GetJournalQuestInfo(questIndex)
  4.    local questName, bgText, stepText, stepType, stepOverrideText, completed, tracked, _, _, _, instanceDisplayType = GetJournalQuestInfo_Orig(questIndex)
  5.    return questName, bgText, stepText, stepType, stepOverrideText, completed, tracked, _, _, _, instanceDisplayType
  6. end

Last edited by circonian : 01/09/16 at 07:25 PM.
  Reply With Quote