View Single Post
08/15/15, 09:18 PM   #18
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by haggen View Post
Is it worse than the ZO standard of using CreateString and GetString ? And why ?
What you did would work. Is it worse, I'm no expert on this, but I can't think of a reason why it would be for most addons. Either way STRING_JEWELRY gets defined as a global & your way it would not have to look up the index in the EsoStrings table. You would just loose some extra functionality.

As for the differences in methods, there are also these functions:
Lua Code:
  1. SafeAddVersion(stringId, stringVersion)
  2. SafeAddString(stringId, stringValue, stringVersion)
SafeAddVersion(...) can be used to assign a version number to a stringId. SafeAddString(...) can be used to update a stringId's corresponding string, while at the same time checking the version numbers to ensure that you are not overwriting a newer version of the string with an older version of the string.
This would not be possible using the method you implemented without writing your own versioning code (which would probably be just copying the games code), but since its already available using ZO_CreateStringId that would be pointless. Although to you, creating an addon, this would make no difference because I highly doubt you would need this functionality.

GetString does have an extra parameter contextId:
Lua Code:
  1. GetString(string stringVariablePrefix, integer contextId)
  2.    Returns: string stringValue

This allows you to do things like:
Lua Code:
  1. equipTypeName = GetString("SI_EQUIPTYPE", equipType)
and if, for example, equipType == 8, then it would return "Waist" which is "SI_EQUIPTYPE8"
Your way you would probably end up doing several if statements:
Lua Code:
  1. if equipType == 8 then d(MY_EQUIPTYPE_WAIST)
  2. elseif equipType == 9 then d(MY_EQUIPTYPE_LEGS)
  3. ...
Although there are ways around that, you could write your own GetString(...) func to mimic that functionality of GetString(...) and it would work the same with your method. Of course once again you would just be rewriting code/functions that are already available to us.

GetString(...) will return "[Empty String]" (literally a string with that text) if the stringId does not exist.

Last edited by circonian : 08/15/15 at 09:43 PM.
  Reply With Quote