Thread Tools Display Modes
09/21/15, 04:08 AM   #1
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
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



  Reply With Quote
09/21/15, 05:47 AM   #2
t31os
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 26
Nice, i'm gonna plonk that in one of my personal addons, thanks!
  Reply With Quote
09/22/15, 01:45 PM   #3
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Is this only working if we enable the tutorials in the settings?
  Reply With Quote
09/22/15, 03:49 PM   #4
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
It works even if set to "no" in options
  Reply With Quote

ESOUI » Developer Discussions » Tutorials & Other Helpful Info » Nice messages and infos on screen

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