Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- # This is old code from when I was trying to make the mod one a single gnome bar item
- -- # That would be given a random flavor name when it was spawned
- -- # Then it would dynamically set the icon based on the name and flavor it was assigned
- -- # Unfortunately, icons did not persist through a game reload and would be random
- -- # On the next game load.
- -- # Leaving this here in case someday I figure it out or if someone else can learn anything from it.
- --[[
- function onVapeSpawn(_item)
- if not _item then return; end;
- local item = _item;
- local flavorsList = {
- "Tropical Rainbow Blast",
- "Blue Razz",
- "Watermelon Ice",
- "Pink Lemonade",
- "Black Ice",
- "Cool Mint",
- "Banana Ice",
- "Grape",
- "Lemon Mint",
- "Strawberry Banana"
- }
- 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.
- -- // print(random);
- -- // print("printed random");
- itemName = item:getDisplayName();
- -- // print(itemName);
- -- // print("printed display name");
- -- // print(flavorsList[random]);
- -- // print("Printed the flavor name");
- local displayName = "GnomeBar (" .. flavorsList[random] .. ")"; -- !! Creating new name based on the randomly picked flavor
- -- // print(displayName);
- -- // print("Printed display name");
- item:setName(displayName); -- # Set new item name
- -- !! MUST USE "setName" instead of "setDisplayName". "setDisplayName" is for Item class. "setName" is for inventoryItem class.
- -- !! onCreate returns inventoryItem, not item
- local flavorName = flavorsList[random]; -- get the flavor name
- flavorName = string.gsub(flavorName, "%s", ""); -- replace spaces in the name.
- flavorName = string.lower(flavorName); -- change to lower case
- -- //local textureFile = "item_";
- -- //textureFile = textureFile + flavorName
- print("media/textures/item_"..flavorName..".png")
- local itemTexture = getTexture("media/textures/item_"..flavorName..".png") -- # load the texture
- item:setTexture(itemTexture) -- # set the texture to the item
- -- × item:DoParam("Icon = bananaice")
- end
- --]]
Advertisement
Add Comment
Please, Sign In to add comment