Thread Tools Display Modes
04-03-21, 07:40 AM   #1
koromire69
A Murloc Raider
Join Date: Apr 2021
Posts: 4
Issues using SetStatusBarTexture

Hello,

First of all i know that some people previously asked some tips about the same problem i have. So i would say that i already try the way they solve their problems but it didn"t worked for me.

I have a lua code who is supposed to make a bar spawn somewhere on my screen IG. All my problem is about the function "SetStatusBarTexture" so i traced it :
Lua Code:
  1. local BarreDeFureurEpaisseur = 10
  2. local BarreDeFureurLongueur = 100
  3. local CheminImageBarre = 'Interface\\AddOns\\ATH_Demon_Hunter\\textures\\barreDeFureur'
  4.  
  5. local function F_ApparitionBarreFureur ()
  6.     local BarreDeFureur = CreateFrame("StatusBar", "BarreDeFureur", UIParent)
  7.     print("1")
  8.     local a = BarreDeFureur:SetStatusBarTexture(CheminImageBarre)
  9.     if (a == nil) then print("!!!Texture for bar not load!!!") end
  10.  
  11.     BarreDeFureur:SetLenght(BarreDeFureurLongueur)
  12.     BarreDeFureur:SetHeight(BarreDeFureurEpaisseur)
  13.     BarreDeFureur:SetHitRectInsets(2, 2, 2, 2)
  14.     BarreDeFureur:SetStatusBarColor(0, 1, 0)
  15.     BarreDeFureur:SetFillStyle("STANDARD")
  16.     BarreDeFureur:SetMinMaxValues(0, 100)
  17.     BarreDeFureur:SetPoint("CENTER", 0, 10)
  18.     BarreDeFureur:SetShown(true)
  19. end

The message "!!!Texture for bar not load!!!" appared each time even if entirely closed WoW.

i also "tested my test" by puting the return of CreateFrame in a first (and it returned a table as expected, the "equivalent of pointer" in lua). I put that test because the bar never appeared.

This is not the entir code, i posted just the part which have trouble (and i tested the rest of the code with debug trace to be sure that the issue come from here.

Most of the time this error is caused by the path which is not the good one. So there is the absolute path of the files that i try to use (on windows 10) :
Lua Code:
  1. C:\Program Files (x86)\World of Warcraft\_retail_\Interface\AddOns\ATH_Demon_Hunter\textures\barreDeFureur.blp
  2. C:\Program Files (x86)\World of Warcraft\_retail_\Interface\AddOns\ATH_Demon_Hunter\textures\barreDeFureur.png
note : The AddOns folder was primary named Addons, and i changed it to see if this have change something. It didn't change anything but i let it like this.

And i try those different path, none of the worked (the a is still equal to nil) :
Lua Code:
  1. local CheminImageBarre = 'Interface\\AddOns\\ATH_Demon_Hunter\\textures\\barreDeFureur'
  2. local CheminImageBarre = "Interface\\AddOns\\ATH_Demon_Hunter\\textures\\barreDeFureur"
  3. local CheminImageBarre = 'Interface//AddOns//ATH_Demon_Hunter//textures//barreDeFureur'
  4. local CheminImageBarre = "Interface//AddOns//ATH_Demon_Hunter//textures//barreDeFureur"
  5.  
  6. local CheminImageBarre = 'Interface\\Addons\\ATH_Demon_Hunter\\textures\\barreDeFureur'
  7. local CheminImageBarre = "Interface\\Addons\\ATH_Demon_Hunter\\textures\\barreDeFureur"
  8. local CheminImageBarre = 'Interface//Addons//ATH_Demon_Hunter//textures//barreDeFureur'
  9. local CheminImageBarre = "Interface//Addons//ATH_Demon_Hunter//textures//barreDeFureur"
  10.  
  11. local CheminImageBarre = 'Interface/AddOns/ATH_Demon_Hunter/textures/barreDeFureur'
  12. local CheminImageBarre = "Interface/AddOns/ATH_Demon_Hunter/textures/barreDeFureur"
  13.  
  14. local CheminImageBarre = 'Interface/Addons/ATH_Demon_Hunter/textures/barreDeFureur'
  15. local CheminImageBarre = "Interface/Addons/ATH_Demon_Hunter/textures/barreDeFureur"
  16.  
  17. local CheminImageBarre = 'Interface\\AddOns\\ATH_Demon_Hunter\\textures\\barreDeFureur.blp'
  18. local CheminImageBarre = "Interface\\AddOns\\ATH_Demon_Hunter\\textures\\barreDeFureur.blp"
  19. local CheminImageBarre = 'Interface//AddOns//ATH_Demon_Hunter//textures//barreDeFureur.blp'
  20. local CheminImageBarre = "Interface//AddOns//ATH_Demon_Hunter//textures//barreDeFureur.blp"
  21.  
  22. local CheminImageBarre = 'Interface\\Addons\\ATH_Demon_Hunter\\textures\\barreDeFureur.blp'
  23. local CheminImageBarre = "Interface\\Addons\\ATH_Demon_Hunter\\textures\\barreDeFureur.blp"
  24. local CheminImageBarre = 'Interface//Addons//ATH_Demon_Hunter//textures//barreDeFureur.blp'
  25. local CheminImageBarre = "Interface//Addons//ATH_Demon_Hunter//textures//barreDeFureur.blp"
  26.  
  27. local CheminImageBarre = 'Interface/AddOns/ATH_Demon_Hunter/textures/barreDeFureur.blp'
  28. local CheminImageBarre = "Interface/AddOns/ATH_Demon_Hunter/textures/barreDeFureur.blp"
  29.  
  30. local CheminImageBarre = 'Interface/Addons/ATH_Demon_Hunter/textures/barreDeFureur.blp'
  31. local CheminImageBarre = "Interface/Addons/ATH_Demon_Hunter/textures/barreDeFureur.blp"
  32.  
  33. local CheminImageBarre = 'Interface\\AddOns\\ATH_Demon_Hunter\\textures\\barreDeFureur.png'
  34. local CheminImageBarre = "Interface\\AddOns\\ATH_Demon_Hunter\\textures\\barreDeFureur.png"
  35. local CheminImageBarre = 'Interface//AddOns//ATH_Demon_Hunter//textures//barreDeFureur.png'
  36. local CheminImageBarre = "Interface//AddOns//ATH_Demon_Hunter//textures//barreDeFureur.png"
  37.  
  38. local CheminImageBarre = 'Interface\\Addons\\ATH_Demon_Hunter\\textures\\barreDeFureur.png'
  39. local CheminImageBarre = "Interface\\Addons\\ATH_Demon_Hunter\\textures\\barreDeFureur.png"
  40. local CheminImageBarre = 'Interface//Addons//ATH_Demon_Hunter//textures//barreDeFureur.png'
  41. local CheminImageBarre = "Interface//Addons//ATH_Demon_Hunter//textures//barreDeFureur.png"
  42.  
  43.  
  44. local CheminImageBarre = 'Interface/AddOns/ATH_Demon_Hunter/textures/barreDeFureur.png'
  45. local CheminImageBarre = "Interface/AddOns/ATH_Demon_Hunter/textures/barreDeFureur.png"
  46.  
  47.  
  48. local CheminImageBarre = 'Interface/Addons/ATH_Demon_Hunter/textures/barreDeFureur.png'
  49. local CheminImageBarre = "Interface/Addons/ATH_Demon_Hunter/textures/barreDeFureur.png"

You may ask "why try all those folder ?" and i would respond "I don't know who to fixe this because i don't understand what's happening so i try everythin i thinked about"

You may also say "some of those path would not work anyway" and i just generated all the possible combination it would be possible to write the path with...

So if someone have an idea...

Thank you for the one who'll take the time to read this

Edit :

In case it help here's the complete code :
Lua Code:
  1. -----------------------------------------------------------------------------------------------------------
  2. -- var
  3. -----------------------------------------------------------------------------------------------------------
  4.  
  5. local DebugActif = 1
  6.  
  7. local playerClass = select(2, UnitClass("player"))
  8. local BarreDeFureurEpaisseur = 10
  9. local BarreDeFureurLongueur = 100
  10. local FureurMaxDuJoueur = 100
  11. local CheminImageBarre = 'Interface\\Addons\\ATH_Demon_Hunter\\textures\\barreDeFureur'
  12.  
  13. -----------------------------------------------------------------------------------------------------------
  14. -- Frames
  15. -----------------------------------------------------------------------------------------------------------
  16.  
  17. local InitFrame = CreateFrame ("Frame", "InitFrame")
  18.  
  19. InitFrame : RegisterEvent ("PLAYER_ENTERING_WORLD")
  20. InitFrame : RegisterEvent ("ADDON_LOADED")
  21.  
  22.  
  23.  
  24. local CombatFrame = CreateFrame ("Frame", "CombatFrame")
  25.  
  26. CombatFrame : RegisterUnitEvent("UNIT_POWER_UPDATE", "player")
  27. CombatFrame : RegisterUnitEvent("UNIT_HEALTH", "player")
  28. CombatFrame : RegisterUnitEvent("UNIT_MAXHEALTH", "player")
  29.  
  30. -----------------------------------------------------------------------------------------------------------
  31. -- functions
  32. -----------------------------------------------------------------------------------------------------------
  33.  
  34. function PrintDebug (texte)
  35.     if DebugActif == 1 then print(texte.."\n") end
  36. end
  37.  
  38. local function F_ApparitionBarreFureur ()
  39.  
  40.     local BarreDeFureur = CreateFrame("StatusBar", "BarreDeFureur", UIParent)
  41.     PrintDebug("1")
  42.  
  43.     local a = BarreDeFureur:SetStatusBarTexture(CheminImageBarre)
  44.     if (a == nil) then PrintDebug("!!!Texture for bar not load!!!") end
  45.     BarreDeFureur:SetLenght(BarreDeFureurLongueur)
  46.     BarreDeFureur:SetHeight(BarreDeFureurEpaisseur)
  47.     BarreDeFureur:SetHitRectInsets(2, 2, 2, 2)
  48.     BarreDeFureur:SetStatusBarColor(0, 1, 0)
  49.     BarreDeFureur:SetFillStyle("STANDARD")
  50.     BarreDeFureur:SetMinMaxValues(0, 100)
  51.     BarreDeFureur:SetPoint("CENTER", 0, 10)
  52.     BarreDeFureur:SetShown(true)
  53.     PrintDebug ("fin F_ApparitionBarreFureur")
  54. end
  55.  
  56. local function F_GetFureurActuelle ()
  57.     local FureurActuel = UnitPower("player", SPELL_POWER_PAIN)
  58.     local PourcentageDeFureur = FureurActuel/FureurMaxDuJoueur*100
  59.      BarreDeFureur:SetStatusBarColor(1, PourcentageDeFureur/100, 0)
  60.     return math.floor(PourcentageDeFureur + 0.5)
  61. end
  62.  
  63. local function F_InitialisationRessources ()
  64.     F_ApparitionBarreFureur()
  65.     F_GetFureurActuelle()
  66. end
  67.  
  68. local function F_CBInit(self, event, ...)
  69.     if (event == "PLAYER_ENTERING_WORLD") then
  70.         PrintDebug ("PLAYER_ENTERING_WORLD fired")
  71.         F_InitialisationRessources()
  72.         PrintDebug ("fin d'appel de InitFrame")
  73.     end
  74. end
  75.  
  76. local function F_CBCombat (self, event, ...)
  77.     if (event == "UNIT_POWER_UPDATE") then
  78.         PrintDebug ("UNIT_POWER_UPDATE fired")
  79.         F_GetFureurActuelle()
  80.         PrintDebug ("fin d'appel de F_GetFureurActuelle")
  81.     end
  82. end
  83.  
  84. -----------------------------------------------------------------------------------------------------------
  85. -- Scripts
  86. -----------------------------------------------------------------------------------------------------------
  87. InitFrame : SetScript ("OnEvent", F_CBInit)
  88.  
  89. CombatFrame : SetScript ("OnEvent", F_CBCombat)

Last edited by koromire69 : 04-03-21 at 08:18 AM.
  Reply With Quote
04-03-21, 09:37 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
In lua code, paths are either double backslash\\ or single forward slash /

not \ or //

In XML you use \

And .png files won't work, just .blp or .tga of the correct format.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-03-21 at 09:41 AM.
  Reply With Quote
04-03-21, 11:04 AM   #3
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
Do you have Lua errors enabled?

AFAIK SetLenght doesn't exist, replace it with SetWidth (or use SetSize).
  Reply With Quote
04-03-21, 11:57 AM   #4
koromire69
A Murloc Raider
Join Date: Apr 2021
Posts: 4
Fizzlemizz :

Thank you, i'm taking good notes about this !

sezz :

No, can i turn them on via WoW or do i have to download something ?
You're right, i changed the function.
  Reply With Quote
04-03-21, 12:16 PM   #5
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
Originally Posted by koromire69 View Post
No, can i turn them on via WoW or do i have to download something?
Last time I checked there was a checkbox in the game settings, but I can't find it right now (maybe Blizzard removed it?). Anyways, you can also use this:

Code:
/run SetCVar("scriptErrors", 1);
  Reply With Quote
04-03-21, 12:24 PM   #6
koromire69
A Murloc Raider
Join Date: Apr 2021
Posts: 4
Thank you Now i've turned Lua error am i able to see the "errors returned by function" or something like that ?
  Reply With Quote
04-03-21, 12:54 PM   #7
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
Originally Posted by koromire69 View Post
Thank you Now i've turned Lua error am i able to see the "errors returned by function" or something like that ?
Exactly - if you change SetWidth back to SetLenght you should see an error popup.
  Reply With Quote
04-04-21, 02:34 AM   #8
koromire69
A Murloc Raider
Join Date: Apr 2021
Posts: 4
Thank you a lot, by giving me access to this tool i was able to investigate and find out what was going wrong :
I had a comment in the toc. file who generated a error (but didn't blocked the rest of the code, so the error was invisible to me without the error's log), i removed it and the texture charged !
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Issues using SetStatusBarTexture

Thread Tools
Display Modes

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