Guest User

Untitled

a guest
Mar 30th, 2023
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. -- # This is old code from when I was trying to make the mod one a single gnome bar item
  2. -- # That would be given a random flavor name when it was spawned
  3. -- # Then it would dynamically set the icon based on the name and flavor it was assigned
  4. -- # Unfortunately, icons did not persist through a game reload and would be random
  5. -- # On the next game load.
  6. -- # Leaving this here in case someday I figure it out or if someone else can learn anything from it.
  7.  
  8. --[[
  9. function onVapeSpawn(_item)
  10. if not _item then return; end;
  11.  
  12. local item = _item;
  13.  
  14. local flavorsList = {
  15. "Tropical Rainbow Blast",
  16. "Blue Razz",
  17. "Watermelon Ice",
  18. "Pink Lemonade",
  19. "Black Ice",
  20. "Cool Mint",
  21. "Banana Ice",
  22. "Grape",
  23. "Lemon Mint",
  24. "Strawberry Banana"
  25. }
  26.  
  27. random = ZombRand(10)+1; -- !! ZombRand is from 0 to n-1. LUA arrays start from 1. To correct this difference, we add 1 so they match up.
  28. -- // print(random);
  29. -- // print("printed random");
  30.  
  31. itemName = item:getDisplayName();
  32.  
  33. -- // print(itemName);
  34. -- // print("printed display name");
  35.  
  36. -- // print(flavorsList[random]);
  37. -- // print("Printed the flavor name");
  38.  
  39. local displayName = "GnomeBar (" .. flavorsList[random] .. ")"; -- !! Creating new name based on the randomly picked flavor
  40.  
  41. -- // print(displayName);
  42. -- // print("Printed display name");
  43.  
  44.  
  45. item:setName(displayName); -- # Set new item name
  46. -- !! MUST USE "setName" instead of "setDisplayName". "setDisplayName" is for Item class. "setName" is for inventoryItem class.
  47. -- !! onCreate returns inventoryItem, not item
  48.  
  49. local flavorName = flavorsList[random]; -- get the flavor name
  50. flavorName = string.gsub(flavorName, "%s", ""); -- replace spaces in the name.
  51. flavorName = string.lower(flavorName); -- change to lower case
  52. -- //local textureFile = "item_";
  53. -- //textureFile = textureFile + flavorName
  54.  
  55. print("media/textures/item_"..flavorName..".png")
  56. local itemTexture = getTexture("media/textures/item_"..flavorName..".png") -- # load the texture
  57. item:setTexture(itemTexture) -- # set the texture to the item
  58.  
  59. -- × item:DoParam("Icon = bananaice")
  60.  
  61. end
  62. --]]
Advertisement
Add Comment
Please, Sign In to add comment