ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Tutorials & Other Helpful Info (https://www.esoui.com/forums/forumdisplay.php?f=172)
-   -   Nice messages and infos on screen (https://www.esoui.com/forums/showthread.php?t=5172)

Ayantir 09/21/15 04:08 AM

Nice messages and infos on screen
 
A little hack of the tutorial system to display nice (small) messages ingame :

This exemple hacks the TUTORIAL_TYPE_HUD_INFO_BOX tuto type, but you can also do the same with the dialog aswell. Just look the code!

Lua Code:
  1. -- Love Lilith!
  2. local MYADDON_FAKE_TUTO_INDEX = 666
  3.  
  4. local original_GetTutorialInfo = GetTutorialInfo
  5. GetTutorialInfo = function(tutorialIndex)
  6.     if tutorialIndex == MYADDON_FAKE_TUTO_INDEX then
  7.         -- My code, MUST return 2 strings & 1 integer : title and description, can contain colors, keycodes, and icons. last value is integer (priority of tutorial, 0 = high priority).
  8.     end
  9.     return original_GetTutorialInfo(tutorialIndex)
  10. end
  11.  
  12. local original_GetTutorialType = GetTutorialType
  13. GetTutorialType = function(tutorialIndex)
  14.     if tutorialIndex == MYADDON_FAKE_TUTO_INDEX then
  15.         return TUTORIAL_TYPE_HUD_INFO_BOX
  16.     end
  17.     return original_GetTutorialType(tutorialIndex)
  18. end
  19.  
  20.  
  21.  
  22.  
  23.  
  24. local function aFunctinCalledWhenYouWantToDisplayAMessage()
  25.  
  26.     local title, desc = GetTutorialInfo(MYADDON_FAKE_TUTO_INDEX)
  27.     if title ~= "" then
  28.         -- Hack tutorial timer to adapt to short / small descriptions
  29.         TUTORIAL_SYSTEM.tutorialHandlers[TUTORIAL_TYPE_HUD_INFO_BOX].currentlyDisplayedTutorialTimeLeft = math.floor(string.len(desc) / 20) * 1000 -- You can also change the duration.
  30.         -- Display it
  31.         TUTORIAL_SYSTEM:DisplayOrQueueTutorial(MYADDON_FAKE_TUTO_INDEX, 0)
  32.     end
  33.  
  34. end




t31os 09/21/15 05:47 AM

Nice, i'm gonna plonk that in one of my personal addons, thanks! :)

Baertram 09/22/15 01:45 PM

Is this only working if we enable the tutorials in the settings?

Ayantir 09/22/15 03:49 PM

It works even if set to "no" in options


All times are GMT -6. The time now is 05:26 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI