Advertisement
einsteinK

GCM - Tag Example

Jul 9th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.76 KB | None | 0 0
  1. --[[ This ModuleScript is part of GroupClothesManager (which isn't released yet)]]--
  2.  
  3. local Tag = require(script.Parent)
  4.  
  5. --[=[               [[ STANDARD/RAW TAG CREATION ]]
  6.     This is the default kind of tag.
  7.     Every other tag points to or wraps this kind of tag.
  8.    
  9.     Creating a tag is very simple using the code below.
  10.     (It may look difficult, but if you read it once or twice...)
  11.    
  12.     You can put this tag in your group description.
  13.     That way, when someone joins a game (with GCM) that's in your group,
  14.     the tag will be read from the description and clothes will be registered.
  15.    
  16.     Syntax for creating a tag:
  17.    
  18.     Tag.FactoryForGroup(GroupId)
  19.         --> Returns a new Factory
  20.        
  21.     Factory:AddAsset(rank,asset)
  22.         --> Adds the given asset(id) to the tag for the given rank (0-255)
  23.         --> The assetid may only be a Shirt/Pants, or it won't do anything
  24.     Factory:Finish()
  25.         --> Returns a tag with the already given data in it
  26.         --> You can do "AddAsset(A) Finish() AddAsset(B) Finish()"
  27.             Then the first Finish() will contain only A.
  28.             The second finish() will contain A and B.
  29.             If you want to restart, create a new factory.
  30. --]=]
  31.  
  32.     -- 1158880 is "einsteinK's Studios"
  33.     local res = Tag.FactoryForGroup(1158880)
  34.    
  35.     -- 1 is a rank (0-255) in that group, in this case being "Fan/Customer"
  36.     -- 152266143 is a Shirt called "Galaxy" (took a random one)
  37.     res:AddAsset(1,152266143)
  38.    
  39.     -- 152266143 is a Pants called "Galaxy" (previous had link, why not use it...)
  40.     res:AddAsset(1,152266080)
  41.    
  42.     -- 254 is the "Admin/Developer" rank in my group
  43.     -- 305818459 is "Cyan & Black adidas Shirt", yet another Shirt
  44.     res:AddAsset(254,305818459)
  45.    
  46.     -- Get the resulting tag and print it
  47.     print("\nStandard tag:",res:Finish())
  48.     --> =gcmrGpv74A2jom9dA2jomc3R72A522s17=
  49.    
  50.     -- Quick validation
  51.     -- Should print your group ID and every asset with its required rank
  52.     local data = Tag.Parse(res:Finish())
  53.     for k,v in pairs(data) do
  54.         print("Group ID:",k)
  55.         for a,b in pairs(v.Assets) do
  56.             print("\tAsset",a,"for rank",b)
  57.         end
  58.     end
  59.    
  60.     -- Once you edited (and copied some of the lines again) the code, just
  61.     -- run this script and put the resulting string in your group description.
  62.     -- (or read further and do the more advanced stuff... your choice)
  63.    
  64.    
  65.    
  66.    
  67. --[=[               [[ PASTEBIN TAG CREATION ]]
  68.     A pastebin tag is a tag that says "load all tags from this pastebin file".
  69.     Simple to create, simple to use.
  70.     Best used with a paste you can edit, allowing you to update GCM tags
  71.     without having to recreate tags and put them in your group's desc again etc.
  72.     It's also handy if you have 20 tags and don't want to clutter your group description.
  73.     Just put all the tags in a pastebin file and in your description use a pastebin tag.
  74. --]=]
  75.  
  76.     -- You just give it the paste ID
  77.     -- This one is from the official pastebin file
  78.     local res = Tag.NewReadFromPastebin("eDRqBqiF")
  79.     print("\nPastebin tag:",res)
  80.     --> =gcmpeDRqBqiF=
  81.    
  82.    
  83.    
  84.    
  85. --[=[               [[ ASSET TAG CREATION ]]
  86.     An asset tag is a tag that says "load all tags from this asset's description".
  87.     Simple to create, simple to use, very similar to the pastebin tag.
  88.     The description of a model/decal/shirt/.. (any asset) will work.
  89.     There's a limit on how long such a description can be, so it isn't that good.
  90.     It works fine if you don't have a lot of clothes, so it fits in one description.
  91.     You can always have several assets and put their tag in one asset to link them.
  92.     (Your group uses asset A, asset A uses asset B1,B2,B3,...)
  93. --]=]
  94.  
  95.     -- This would read all tags from SWOTH
  96.     -- (There aren't any tags in the description, so a bit useless)
  97.     local res = Tag.NewReadFromAsset(1818)
  98.     print("\nAsset tag:",res)
  99.     --> =gcma1fj=
  100.    
  101.    
  102.    
  103.    
  104. --[=[               [[ INHERITANCE TAG CREATION ]]
  105.     An inheritance tag is nice for group with sub groups.
  106.     (Stuff like armies with extra groups for certain divisions)
  107.     Imagine your group has group ID 12345.
  108.     You have another group for the high ranks with ID 345345.
  109.     You would like for 345345 to have the same clothes as 12345.
  110.    
  111.     You can create an inheritance tag for the group 12345.
  112.     If you put it in 345345's description, it'll inherit from 12345.
  113.     That means, when 345345 loads its clothes, it loads them 12345.
  114.    
  115.     It's a bit more advanced than this:
  116.     - You'll get all 12345's clothes, read from their description
  117.     - You'll get all the clothes in that same description for your group
  118.         This means 12345 can say "345345 should also have those clothes".
  119.         12345 won't get those clothes, but 345345 would
  120.     - You won't get clothes that aren't meant for 12345 or 35345
  121.         (e.g. 12345 has "those clothes for other subgroup 987", won't count)
  122. --]=]
  123.  
  124.     -- You just give it the group ID
  125.     -- This one is ROBLOX' admin group
  126.     local res = Tag.NewInheritFromGroup(7)
  127.     print("\nInheritance tag:",res)
  128.     --> =gcmi7=
  129.     -- If they had clothes registered for GCM in their description, if you
  130.     -- put this tag in your group's description, you would also get their clothes
  131.    
  132.    
  133.    
  134.    
  135. --[=[               [[ COPY TAG CREATION ]]
  136.     A copy tag is a nice way of converting clothes between groups, sort of.
  137.     You could create a copy tag for groups A and B for tag TAG.
  138.     That would make ALL clothes that appear in TAG, no matter for which
  139.     group they're meant (including group C,D,...) available to A and B.
  140.     It's literally copying the clothes from a tag to your own group(s).
  141.     (It's like a group inheritance tag, but without limitations)
  142. --]=]
  143.  
  144.     -- This contains the asset 1 for rank 1 for group 1158880
  145.     -- This also contains asset 2 for rank 2 for group 7
  146.     -- Group with ID 1158880, ID 7 and ID 8
  147.     local test = "=gcmrGpv74A1G7R2A2="
  148.  
  149.     -- Creating a copy for 123 and 456
  150.     local res = Tag.NewCopyFromTag({123,456},test)
  151.     print("\nCopy tag:",res)
  152.     -->  =gcmt3g,dp=gcmrGpv74A1G7R2A2==
  153.    
  154.     -- Again: Validate to make sure it worked
  155.     -- This should print 2 groups: 123 and 456.
  156.     -- They'll both have asset 1 for rank 1 and asset 2 for rank 2
  157.     -- (All clothes from the test tag are copied for them)
  158.     local data = Tag.Parse(res)
  159.     for k,v in pairs(data) do
  160.         print("Group ID:",k)
  161.         for a,b in pairs(v.Assets) do
  162.             print("\tAsset",a,"for rank",b)
  163.         end
  164.     end
  165.    
  166.    
  167.    
  168.    
  169.    
  170. --[=[               [[ SECURE TAG CREATION ]]
  171.     A secure tag is basicly a way to say:
  172.     "I want to parse this tag, but only those groups may be in it"
  173.     It's very handy if you add a not-so-trusted tag as trusted tag.
  174.     (This isn't really a good idea, it's less secure, but surely easier)
  175.    
  176.     When you add groups X,X+1,X+2,N to the tag, it's only valid for those groups.
  177.     If the actual tag embedded in it has data for groups ranging from X to N+2,
  178.     it would only return the data for X to N, ignoring data for N+1 and N+2.
  179.    
  180.     This tag is meant to be used in combination with a "remote tag".
  181.     Something like an asset/pastebin tag, that don't have security by default.
  182.    
  183.     You could create a tag for group 123 that contains the tag for a paste of that group.
  184.     They can edit the paste to add, edit or remove tags.
  185.     They might, however, also add tags for group 456, even if they have nothing to do with them.
  186.     If you use a secure tag and (only) add 123 to the list, they can't do stuff for group 456.
  187.     You can add multiple groups to the secure list: The main group, a sub division, ...
  188. --]=]
  189.    
  190.    
  191.     -- This contains the asset 1 for rank 1 for those 3 groups:
  192.     -- Group with ID 1158880, ID 7 and ID 8
  193.     local test = "=gcmrGpv74A1G7A1G8A1="
  194.  
  195.     -- Creating a secure tag for 1158880 and 7 (Notice: not 8)
  196.     local res = Tag.NewSecureTag({1158880,7},test)
  197.     print("\nSecure tag:",res)
  198.     --> =gcmspv74,7=gcmrGpv74A1G7A1G8A1==
  199.    
  200.     -- Again: Validate to make sure it worked
  201.     -- This should only print assets for 1158880 and 7 since
  202.     -- group 8 isn't in the secure list, so doesn't get added
  203.     local data = Tag.Parse(res)
  204.     for k,v in pairs(data) do
  205.         print("Group ID:",k)
  206.         for a,b in pairs(v.Assets) do
  207.             print("\tAsset",a,"for rank",b)
  208.         end
  209.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement