Display image depending on the zone
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() Now I got the keybinding code: Code:
function IM.OnKeyDown() 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) 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. |
If you added/changed any .dds files while the game was running, you might need to restart the client. It caches textures (and their absence as well).
|
Hm, nothing, didn't work :c
Must be something from the code. |
Quote:
You could try to call your zone change function like this in EVENT_PLAYER_ACTIVATED: Code:
IMOnZoneChanged(0, GetUnitZone("player")) |
Hm, nothing, doesn't seem to work, I'm using this code, might be wrong though:
Code:
function IMOnZoneChanged(0, GetUnitZone("player")) Code:
user:/AddOns/IM/IM.lua:30: <name> or "..." expected near '0 |
Quote:
Lua Code:
About names from API you should read this. |
Ohhh, I think I get it.
I'm checking that link you put there, it is useful, I think I'm getting things, slowly, but I am ^^. I tried this code you put there, but I'm getting another error D: Code:
user:/AddOns/IM/IM.lua:35: attempt to index a nil value Code:
EVENT_MANAGER:RegisterForEvent(IM.name, EVENT_ZONE_CHANGED, IMOnZoneChanged) Sorry for all these questions x'D |
Quote:
If it is you first: Welcome! :) The order of declaration is important in Lua. Is IM declared before line 35? If the error persists, post the whole source. |
Oh great! It works now! Now when I press the key while in Eastmarch, it shows Image1, when I press the key while in Stonefalls it shows Image2. Though, I think I'm not done yet, as if I travel from Stonefalls to Eastmarch and press the key again, it shows still Image2, when it should show Image1. I imagine this will be some kind of update event, right? Works perfectly if after travelling I make reloadui.
I think I should use EVENT_ZONE_UPDATE, but I'm not sure how to make this :S Any ideas? Many thanks for the help, really :) |
Quote:
|
Omg, it works!!!
Now it works perfectly! :D Thank you for your help, really :D I hope to finish this addon and do it good! ^^ |
Welcome to EsoUI! :D
Just wanted to say that if you want to make this more robust in the future you should not depend on zoneName to determine which zone you are in, because it will be a different string for different client languages. There is a small library that votan and I made which makes finding out the zone independent of the client language a bit easier amongst other things. You might want to look into that if you plan to share your addon with others that are not playing in the same language as yourself. |
Thanks Sirinsidiator : P
And yes, that is true, didn't think about that, hrm. I'll check the link you put there, and see what can I do! Thank you! :D |
All times are GMT -6. The time now is 07:04 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI