View Single Post
07/02/15, 11:36 AM   #6
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by ZunaSW View Post
Hm, nothing, doesn't seem to work, I'm using this code, might be wrong though:

Code:
function IMOnZoneChanged(0, GetUnitZone("player"))
	if zoneName == "Eastmarch" then
		MainImage0:SetTexture("IM/textures/Image1.dds")
	end
	if zoneName == "Stonefalls" then
		MainImage0:SetTexture("IM/textures/Image2.dds")
	end
end
And I'm getting this error:

Code:
user:/AddOns/IM/IM.lua:30: <name> or "..." expected near '0
I might have done something wrong with the event. I'm pretty new on this, so I don't really know :S
I was not precise (or lazy?) Calling, not declaring.
Lua Code:
  1. local function IMOnZoneChanged(eventCode, zoneName, subZoneName, newSubzone)
  2.     if zoneName == "Eastmarch" then
  3.         MainImage0:SetTexture("IM/textures/Image1.dds")
  4.     end
  5.     if zoneName == "Stonefalls" then
  6.         MainImage0:SetTexture("IM/textures/Image2.dds")
  7.     end
  8. end
  9.  
  10. local function PlayerActivated()
  11.   EVENT_MANAGER:UnregisterForEvent(IM.name, EVENT_PLAYER_ACTIVATED)
  12.   IMOnZoneChanged(0, GetUnitZone("player"))
  13. end
  14.  
  15. EVENT_MANAGER:RegisterForEvent(IM.name, EVENT_ZONE_CHANGED, IMOnZoneChanged)
  16.  
  17. EVENT_MANAGER:RegisterForEvent(IM.name, EVENT_PLAYER_ACTIVATED, PlayerActivated)
^^ Typed without testing

About names from API you should read this.
  Reply With Quote