Hello,
I'm now trying some other things, mainly I want to display an image depending on the zone the player is.
My idea is this:
If for example the player is in Eastmarch zone, Image1 will be displayed as a key is pressed. If then the player changes to Stonefalls zone, Image2 will be displayed as the same key is pressed.
I got no problems with the keybindings, but I'm having problems displaying the different images. For now, when I press the key, I get a 1024x1024 blank image, as I stated here:
Code:
local wm = GetWindowManager()
local MainImage = wm:CreateTopLevelWindow(nil)
MainImage:SetDimensions(1024,1024)
MainImage:SetAnchor(CENTER,GuiRoot,CENTER,0,0)
MainImage0 = wm:CreateControl(nil, MainImage, CT_TEXTURE)
MainImage0:SetAnchorFill(MainImage)
MainImage0:SetHidden(true)
I got this code from other of my addons, I'm no expert, so that might be wrong :/ But for now, works.
Now I got the keybinding code:
Code:
function IM.OnKeyDown()
MainImage0:SetHidden(false)
end
function IM.OnKeyUp()
MainImage0:SetHidden(true)
end
That works perfectly.
And here is the code that I think it is wrong, even when I don't get any errors in game:
Code:
function IMOnZoneChanged(eventCode, zoneName, subZoneName, newSubzone)
if zoneName == "Eastmarch" then
MainImage0:SetTexture("IM/textures/Image1.dds")
end
if zoneName == "Stonefalls" then
MainImage0:SetTexture("IM/textures/Image2.dds")
end
end
EVENT_MANAGER:RegisterForEvent(IM.name, EVENT_ZONE_CHANGED, IMOnZoneChanged)
For now, as I said, this last part of the code seems to not work, or at least do what I want it to do. I press the key and get a blank image, instead of the images I stated in the last code.
Any ideas on how to make this work? Maybe I'm using the wrong event, I'm not sure, as I said, I'm no expert.
Thank you.