Thread Tools Display Modes
Prev Previous Post   Next Post Next
09-18-18, 07:56 PM   #1
Lyak
A Cyclonian
Join Date: Jul 2018
Posts: 46
Why does RegisterUnitEvent responds to all units if the unit parameter is set to nil?

How's everyone going?!

So, the title says pretty much all.

Why does RegisterUnitEvent responds to all units if the unit parameter is set to nil?

I currently have the following code.

Lua Code:
  1. if info.event then
  2.     for event, unit in pairs(info.event) do
  3.         if type(unit) == "table" then
  4.             object:RegisterUnitEvent(event, unit[1], unit[2]);
  5.         else
  6.             object:RegisterEvent(event);
  7.         end
  8.     end
  9.  
  10.     object:SetScript("OnEvent", function(self, event, ...)
  11.         prototype[event](self, info, ...);
  12.     end);
  13. end

This will make an object respond to all units if unit[2] is nil.

Why...?

I could just make an extra if statement to check if unit[2] exists, but before that I really want to know what's the difference between leaving the second unit parameter empty and assigning nil?
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Why does RegisterUnitEvent responds to all units if the unit parameter is set to nil?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off