Originally Posted by dominoid
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:
local GetJournalQuestInfo_Orig = QuestMaker.GetJournalQuestInfo
function QuestMaker:GetJournalQuestInfo(questIndex)
-- Implicit created variable self, because of the colon syntax.
GetJournalQuestInfo_Orig(self, questIndex)
end
Which is the same as:
Lua Code:
local GetJournalQuestInfo_Orig = QuestMaker.GetJournalQuestInfo
function QuestMaker.GetJournalQuestInfo(self, questIndex)
GetJournalQuestInfo_Orig(self, questIndex)
end
Which is the same as:
Lua Code:
local GetJournalQuestInfo_Orig = QuestMaker.GetJournalQuestInfo
QuestMaker.GetJournalQuestInfo = function(self, questIndex)
GetJournalQuestInfo_Orig(self, questIndex)
end