View Single Post
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