View Single Post
08/30/18, 12:33 PM   #13
lnfinity
AddOn Author - Click to view addons
Join Date: Feb 2017
Posts: 22
Alright thanks.
Should I add this despite the fact that it seems to work now?
Also if running the SetCVar in the first line, does that mean that the .lua file is a 1 liner? Sorry if this question is stupid, I am new to this.


Edit: I tested it multiple times and the thing seems to work flawlessly now.
The code looks like this:
Lua Code:
  1. AdvancedLanguageSelector = {}
  2. AdvancedLanguageSelector.name = "AdvancedLanguageSelector"
  3.  
  4. function AdvancedLanguageSelector:Initialize()
  5.     EVENT_MANAGER:RegisterForEvent(AdvancedLanguageSelector.name, EVENT_PLAYER_ACTIVATED, AdvancedLanguageSelector.OnPlayerActivated)
  6. end
  7.  
  8. function AdvancedLanguageSelector.OnPlayerActivated()
  9.     EVENT_MANAGER:UnregisterForEvent(AdvancedLanguageSelector.name, EVENT_PLAYER_ACTIVATED)
  10.     SetCVar("language.2","en")
  11. end
  12.  
  13. function AdvancedLanguageSelector.OnAddOnLoaded(event, addonName)
  14.     if addonName == AdvancedLanguageSelector.name then
  15.         AdvancedLanguageSelector:Initialize()
  16.     end
  17. end
  18.  
  19. EVENT_MANAGER:RegisterForEvent(AdvancedLanguageSelector.name, EVENT_ADD_ON_LOADED, AdvancedLanguageSelector.OnAddOnLoaded)

Is this foolproof or is there anything else I need to change/check before uploading it?
(Yes I wanna upload it here to share my work with other people who might wanna play the game in the same way I do )

Thanks Baertram and sirinsidiator for your help!!

Last edited by lnfinity : 08/30/18 at 12:54 PM.
  Reply With Quote