Thread: SellAllJunk()
View Single Post
12/17/14, 08:11 PM   #7
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
I think you got it right, so I hope what I'm going to write doesn't add more confusion, since I'm making it up along the way...

You can think of the function as a black box which contains its compiled code and context. And variables are like pieces of paper with names on them that you label objects with. Every variable references one object, and there may be multiple labels (references) on the same object.

When the assignment OrigSellAllJunk = SellAllJunk is executed, it finds the object labelled SellAllJunk, and adds a new label OrigSellAllJunk to it. You can then move the SellAllJunk label to a different object (SellAllJunk = CustomSellAllJunk), and the original will still be accessible as OrigSellAllJunk.

Lua Code:
  1. function SellAllJunk() ... end
  2. -- is just syntax sugar for
  3. SellAllJunk = function() ... end

Meaning you're creating a new function (black box) and sticking the label SellAllJunk to it (removing it from the original).
  Reply With Quote